X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=nepi%2Futil%2Fsshfuncs.py;fp=nepi%2Futil%2Fsshfuncs.py;h=9ba59827030364c8db2360790cc1eee2cf1ef70b;hb=a5405fe3a84b359b41355fa02a3f569fbd4a25e6;hp=663eeb78060152617b2042213728848c18a3eee6;hpb=8fe8f7b8abaa718ec312fe9d16470482d19e1d69;p=nepi.git diff --git a/nepi/util/sshfuncs.py b/nepi/util/sshfuncs.py index 663eeb78..9ba59827 100644 --- a/nepi/util/sshfuncs.py +++ b/nepi/util/sshfuncs.py @@ -683,6 +683,12 @@ fi return (out, err), proc +# add quotes around a shell arg only if it has spaces +def pretty_arg(shell_arg): + return shell_arg if ' ' not in shell_arg else "'{}'".format(shell_arg) +def pretty_args(shell_args): + return " ".join([pretty_arg(shell_arg) for shell_arg in shell_args]) + def _retry_rexec(args, log_msg, stdout = subprocess.PIPE, @@ -695,7 +701,7 @@ def _retry_rexec(args, for x in range(retry): # display command actually invoked when debug is turned on - message = " ".join( [ "'{}'".format(arg) for arg in args ] ) + message = pretty_args(args) log("sshfuncs: invoking {}".format(message), logging.DEBUG) extras = {} if PY2 else {'universal_newlines' : True} # connects to the remote host and starts a remote connection