From 2d887e3e5563ba478ff17e106f7a5c629880bcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 24 Jul 2015 08:38:40 +0200 Subject: Change logging method Now every execution is in separated file. Also logging folder creation moved from callprocess tto initialize.base --- scripts/initialize.py | 4 +++- scripts/utils.py | 10 +++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/initialize.py b/scripts/initialize.py index 96ba0b0..36da24d 100755 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -26,7 +26,9 @@ def all(): def base(): print('Initialize base...') - try: os.mkdir(sf(conf.build_folder)) + try: + os.mkdir(sf(conf.build_folder)) + os.mkdir(sf(conf.log_folder)) except FileExistsError: pass diff --git a/scripts/utils.py b/scripts/utils.py index 9c83065..0d7f67a 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -57,16 +57,12 @@ def build_conf_map(): def callsubprocess(process_name, process, show_output = True, regular = "", env=os.environ): - try: - os.mkdir(sf(conf.log_folder)) - except OSError: - pass - sprc = subprocess.Popen(process, stdout = subprocess.PIPE, env = env) rtn = "" - with open(os.path.join(sf(conf.log_folder), process_name + ".log"), "a") as f: - f.write("::" + time.strftime("%y-%m-%d-%H-%M-%S") + "::\n") + with open(os.path.join(sf(conf.log_folder), + process_name + '-' + time.strftime("%y-%m-%d-%H-%M-%S") + ".log"), + "w") as f: for linen in sprc.stdout: line = linen.decode(sys.getdefaultencoding()) f.write(line) -- cgit v1.2.3