Change work with tmp dirs

This commit is contained in:
Andrey Pohilko 2012-10-08 20:59:27 +04:00
parent a31849c6c5
commit 14c6c9317d
3 changed files with 10 additions and 10 deletions

View File

@ -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:
"""

View File

@ -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()))

View File

@ -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:
'''