remotelogin/devices/managers/decorators.py
def device_connection(device, f, kwargs):
    """ decorator that retrieves the conn from the kwargs or
        opens a new instance if no connection was present
    """
    try:
        conn = kwargs.pop('conn', None) or device.conn.get_open_instance()
        close_after = False

    except ConnectionInstanceOpenError:
        conn = device.conn.open()
        close_after = True

    try:
        if __has_conn_or_kwargs(f):
            kwargs['conn'] = conn
        yield conn

    finally:
        if close_after:
            conn.close()
 decorator that retrieves the conn from the kwargs or
        opens a new instance if no connection was present
    
decorator that retrieves the conn from the kwargs or
opens a new instance if no connection was present
decorator that retrieves the conn from the kwargs or opens a new instance if no connection was present
def device_connection(device, f, kwargs):
    try:
        conn = kwargs.pop('conn', None) or device.conn.get_open_instance()
        close_after = False
    except ConnectionInstanceOpenError:
        conn = device.conn.open()
        close_after = True
    try:
        if __has_conn_or_kwargs(f):
            kwargs['conn'] = conn
        yield conn
    finally:
        if close_after:
            conn.close()
def device_connection ( device , f , kwargs ) : try : conn = kwargs . pop ( 'conn' , None ) or device . conn . get_open_instance ( ) close_after = False except ConnectionInstanceOpenError : conn = device . conn . open ( ) close_after = True try : if __has_conn_or_kwargs ( f ) : kwargs [ 'conn' ] = conn yield conn finally : if close_after : conn . close ( )
decorator that retrieves the conn from the kwargs or
opens a new instance if no connection was present
decorator that retrieves the conn from the kwargs or opens a new instance if no connection was present
""" decorator that retrieves the conn from the kwargs or
        opens a new instance if no connection was present
    """
device
f
kwargs