X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=logger.py;h=17ae04c91f6811abc25360dbc7f7c8c6419c7c7c;hb=1691105d62f7713b18257dfc33b017d1390865d0;hp=bfc416b13d3a4efcd3a5e22dde8c4e8b1c2f383d;hpb=2760b0afa177028c029ad5aea49150eef6db625f;p=nodemanager.git diff --git a/logger.py b/logger.py index bfc416b..17ae04c 100644 --- a/logger.py +++ b/logger.py @@ -21,6 +21,7 @@ LOG_VERBOSE=2 LOG_LEVEL=1 def set_level(level): + global LOG_LEVEL assert level in [LOG_NONE,LOG_NODE,LOG_VERBOSE] LOG_LEVEL=level @@ -42,7 +43,12 @@ def log(msg,level=LOG_NODE): def log_call(*args): log('running command %s' % ' '.join(args)) - try: subprocess.call(args, close_fds=True) + try: + child = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) + child.wait() # wait for proc to hang up + if child.returncode: + raise Exception("command failed:\n stdout - %s\n stderr - %s" % \ + (child.stdout.readlines(), child.stderr.readlines())) except: log_exc() def log_exc(name = None): @@ -56,7 +62,7 @@ def log_slivers (data): import pprint, time try: f=open(LOG_SLIVERS,'w') - now=time.strftime("GetSlivers stored at %H:%M:%S", time.localtime()) + now=time.strftime("GetSlivers stored on %Y.%m.%d at %H:%M:%S", time.localtime()) f.write(now+'\n') pp=pprint.PrettyPrinter(stream=f,indent=2) pp.pprint(data)