7 # how could this accept a list again ?
9 now=time.strftime("%H:%M:%S", time.localtime())
10 print "*",now,'--',message
12 def show_spec(message,spec,depth=2):
13 now=time.strftime("%H:%M:%S", time.localtime())
14 print ">",now,"--",message
15 pprint.PrettyPrinter(indent=6,depth=depth).pprint(spec)
18 now=time.strftime("%H:%M:%S", time.localtime())
19 print "+",now,':',command
20 return os.system("set -x; " + command)
22 # checks whether a given hostname/ip responds to ping
23 ping_timeout_option = None
24 def check_ping (hostname):
25 # check OS (support for macos)
26 global ping_timeout_option
27 if not ping_timeout_option:
28 (status,osname) = commands.getstatusoutput("uname -s")
30 raise Exception, "Cannot figure your OS name"
32 ping_timeout_option="-w"
33 elif osname == "Darwin":
34 ping_timeout_option="-t"
36 command="ping -c 1 %s 1 %s"%(ping_timeout_option,hostname)
37 (status,output) = commands.getstatusoutput(command)
40 # inserts a backslash before each occurence of the following chars
41 # \ " ' < > & | ; ( ) $ * ~
42 def backslash_shell_specials (command):
45 if char in "\\\"'<>&|;()$*~":