-def show_test_spec (message,all_plc_specs):
- now=time.strftime("%H:%M:%S", time.localtime())
- print ">",now,"--",message
- for plc_spec in all_plc_specs:
- show_test_spec_pass (plc_spec,1)
- show_test_spec_pass (plc_spec,2)
+# set a default timeout to 15 minutes - this should be plenty even for installations
+# call with timeout=None if the intention really is to wait until full completion
+def system(command, background=False, silent=False, dry_run=None, timeout=15*60):
+ dry_run = dry_run if dry_run is not None else getattr(options, 'dry_run', False)
+ if dry_run:
+ print('dry_run:', command)
+ return 0
+
+ if silent :
+ if command.find(';') >= 0:
+ command = "({}) 2> /dev/null".format(command)
+ else: command += " 2> /dev/null"
+ if background:
+ command += " &"
+ if silent:
+ print('.', end=' ')
+ sys.stdout.flush()
+ else:
+ now = time.strftime("%H:%M:%S", time.localtime())
+ # don't show in summary
+ print("->", now, '--', end=' ')
+ sys.stdout.flush()
+ if not silent:
+ command = "set -x; " + command
+ try:
+ return subprocess.call(command, shell=True, timeout=timeout)
+ except subprocess.TimeoutExpired as e:
+ header("TIMEOUT when running command {}- {}".format(command, e))
+ return -1