X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Futils.py;h=7aa670f505d88350afb2b3a6b4b9e6d5ad96e92d;hb=560938db174121e93854fd39b66d29be86769864;hp=85ad7ab92d03d80bf1d9be3577025585903cae2d;hpb=66ad1efd9bc816f4f84f68f0132f77600897f84b;p=tests.git diff --git a/system/utils.py b/system/utils.py index 85ad7ab..7aa670f 100644 --- a/system/utils.py +++ b/system/utils.py @@ -4,6 +4,12 @@ import os import re from pprint import PrettyPrinter +options={} + +def init_options(options_arg): + global options + options=options_arg + # how could this accept a list again ? def header(message): now=time.strftime("%H:%M:%S", time.localtime()) @@ -14,6 +20,17 @@ def pprint(message,spec,depth=2): print ">",now,"--",message PrettyPrinter(indent=8,depth=depth).pprint(spec) +# quick & dirty - should probably use the parseroption object instead +# and move to TestMain as well +exclude_options_keys = [ 'ensure_value' , 'read_file', 'read_module' ] +def show_options (message,options): + now=time.strftime("%H:%M:%S", time.localtime()) + print ">",now,"--",message + for k in dir(options): + if k.find("_")==0: continue + if k in exclude_options_keys: continue + print " ",k,":",getattr(options,k) + def show_site_spec (site): print '======== site',site['site_fields']['name'] for (k,v) in site.iteritems(): @@ -94,8 +111,11 @@ def show_test_spec_pass (plc_spec,passno): def system(command,background=False): now=time.strftime("%H:%M:%S", time.localtime()) if background: command += " &" - print "+",now,':',command - return os.system("set -x; " + command) + if options.dry_run: + print 'dry_run:',command + return 0 + else: + return os.system("set -x; " + command) def match (string, pattern): # tmp - there's probably much simpler