From 14c6c9317dea27a62d06e3d708abe140a7331519 Mon Sep 17 00:00:00 2001 From: Andrey Pohilko Date: Mon, 8 Oct 2012 20:59:27 +0400 Subject: [PATCH] Change work with tmp dirs --- Tank/ConsoleWorker.py | 1 - Tank/Plugins/Phantom.py | 1 - tankcore.py | 18 ++++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tank/ConsoleWorker.py b/Tank/ConsoleWorker.py index fe332c8..d6831fe 100644 --- a/Tank/ConsoleWorker.py +++ b/Tank/ConsoleWorker.py @@ -13,7 +13,6 @@ import tempfile import time import traceback -# FIXME: 1 remove lock in case of config format error # TODO: 2 add system resources busy check class ConsoleTank: """ diff --git a/Tank/Plugins/Phantom.py b/Tank/Plugins/Phantom.py index 939ec36..faa2844 100644 --- a/Tank/Plugins/Phantom.py +++ b/Tank/Plugins/Phantom.py @@ -570,7 +570,6 @@ class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener): self.RPS = second_aggregate_data.overall.RPS self.selfload = second_aggregate_data.overall.selfload - self.log.debug("%s %s", second_aggregate_data.time.timetuple(), self.owner.phantom_start_time) self.time_lag = int(time.time() - time.mktime(second_aggregate_data.time.timetuple())) diff --git a/tankcore.py b/tankcore.py index 87d23fc..6e41aa1 100644 --- a/tankcore.py +++ b/tankcore.py @@ -323,12 +323,17 @@ class TankCore: self.log.debug("Collecting artifacts") if not self.artifacts_dir: date_str = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.") - self.artifacts_dir = tempfile.mkdtemp("", date_str, self.artifacts_base_dir) - elif not os.path.isdir(self.artifacts_dir): + self.artifacts_dir = tempfile.mkdtemp("", date_str, self.artifacts_base_dir) + if not os.path.isdir(self.artifacts_dir): os.makedirs(self.artifacts_dir) + os.chmod(self.artifacts_dir, 0744) + self.log.info("Artifacts dir: %s", self.artifacts_dir) for filename, keep in self.artifact_files.items(): - self.__collect_file(filename, keep) + try: + self.__collect_file(filename, keep) + except Exception, ex: + self.log.warn("Failed to collect file %s: %s", filename, ex) def plugins_post_process(self, retcode): ''' @@ -457,6 +462,7 @@ class TankCore: raise RuntimeError("There is lock files") self.lock_file = tempfile.mkstemp('.lock', 'lunapark_', self.LOCK_DIR)[1] + os.chmod(self.lock_file, 0644) self.config.file = self.lock_file @@ -484,17 +490,13 @@ class TankCore: except Exception, exc: self.log.debug("Failed to delete lock %s: %s", full_name, exc) else: - retcode = True + retcode = True except Exception, exc: self.log.warn("Failed to load info from lock %s: %s", full_name, exc) retcode = True return retcode - - - - class ConfigManager: '''