-def log(msg, level, out = None, err = None):
+def log(msg, level = logging.DEBUG, out = None, err = None):
Special value that when given to rspawn in stderr causes stderr to
redirect to whatever stdout was redirected to.
"""
Special value that when given to rspawn in stderr causes stderr to
redirect to whatever stdout was redirected to.
"""
- p = subprocess.Popen("ip -o addr list", shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(
+ "ip -o addr list",
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
stdout, stderr = p.communicate()
m = _re_inet.findall(stdout)
ip = m[0][1].split("/")[0]
stdout, stderr = p.communicate()
m = _re_inet.findall(stdout)
ip = m[0][1].split("/")[0]
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
if (32 <= ord(c) < 127 or c in ('\r','\n','\t')) and c not in ("'",'"'):
return c
else:
return "'$'\\x%02x''" % (ord(c),)
if (32 <= ord(c) < 127 or c in ('\r','\n','\t')) and c not in ("'",'"'):
return c
else:
return "'$'\\x%02x''" % (ord(c),)
stdout = stderr = stdin = None
return _retry_rexec(args, log_msg,
stdout = stderr = stdin = None
return _retry_rexec(args, log_msg,
- log_msg,
- stdout = subprocess.PIPE,
- stdin = subprocess.PIPE,
- stderr = subprocess.PIPE,
- env = None,
- retry = 3,
- tmp_known_hosts = None,
- blocking = True):
+ log_msg,
+ stdout = subprocess.PIPE,
+ stdin = subprocess.PIPE,
+ stderr = subprocess.PIPE,
+ env = None,
+ retry = 3,
+ tmp_known_hosts = None,
+ blocking = True):
for x in xrange(retry):
# display command actually invoked when debug is turned on
message = " ".join( [ "'{}'".format(arg) for arg in args ] )
log("sshfuncs: invoking {}".format(message), logging.DEBUG)
# connects to the remote host and starts a remote connection
for x in xrange(retry):
# display command actually invoked when debug is turned on
message = " ".join( [ "'{}'".format(arg) for arg in args ] )
log("sshfuncs: invoking {}".format(message), logging.DEBUG)
# connects to the remote host and starts a remote connection
# attach tempfile object to the process, to make sure the file stays
# alive until the process is finished with it
proc._known_hosts = tmp_known_hosts
# attach tempfile object to the process, to make sure the file stays
# alive until the process is finished with it
proc._known_hosts = tmp_known_hosts