Support for context manager in cls_cmd SSH class
This commit is contained in:
committed by
Robert Schmidt
parent
c99db698ce
commit
d5eb5ee0f2
@@ -86,6 +86,12 @@ class Cmd(metaclass=abc.ABCMeta):
|
|||||||
return
|
return
|
||||||
|
|
||||||
class LocalCmd(Cmd):
|
class LocalCmd(Cmd):
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||||
|
self.close()
|
||||||
|
|
||||||
def __init__(self, d = None):
|
def __init__(self, d = None):
|
||||||
self.cwd = d
|
self.cwd = d
|
||||||
if self.cwd is not None:
|
if self.cwd is not None:
|
||||||
@@ -128,6 +134,12 @@ class LocalCmd(Cmd):
|
|||||||
self.copyin(src, tgt, recursive)
|
self.copyin(src, tgt, recursive)
|
||||||
|
|
||||||
class RemoteCmd(Cmd):
|
class RemoteCmd(Cmd):
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||||
|
self.close()
|
||||||
|
|
||||||
def __init__(self, hostname, d=None):
|
def __init__(self, hostname, d=None):
|
||||||
cIdx = 0
|
cIdx = 0
|
||||||
logging.getLogger('paramiko').setLevel(logging.ERROR) # prevent spamming through Paramiko
|
logging.getLogger('paramiko').setLevel(logging.ERROR) # prevent spamming through Paramiko
|
||||||
|
|||||||
Reference in New Issue
Block a user