X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Futils.py;h=4468b206a6b484ae2721c6ec59b7d527bd0e56c8;hb=d777a85ce4ac688edd7684bbd8b2689ba94f594e;hp=589f77a6c503c00ab9658e94f1e8592edb0789f1;hpb=e0eebfd5c5ba792c89ceedb5ecaf5804d645a63d;p=tests.git diff --git a/system/utils.py b/system/utils.py index 589f77a..4468b20 100644 --- a/system/utils.py +++ b/system/utils.py @@ -16,7 +16,7 @@ def show_spec(message,spec,depth=2): def system(command): now=time.strftime("%H:%M:%S", time.localtime()) - print "+",now + print "+",now,':',command return os.system("set -x; " + command) # checks whether a given hostname/ip responds to ping @@ -36,3 +36,15 @@ def check_ping (hostname): command="ping -c 1 %s 1 %s"%(ping_timeout_option,hostname) (status,output) = commands.getstatusoutput(command) return status == 0 + +# inserts a backslash before each occurence of the following chars +# \ " ' < > & | ; ( ) $ * ~ +def backslash_shell_specials (command): + result='' + for char in command: + if char in "\\\"'<>&|;()$*~": + result +='\\'+char + else: + result +=char + return result +