From 4e4ca6c402893881e2efe32159f7eda5f987a80e Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Fri, 24 Apr 2015 18:09:43 +0200 Subject: [PATCH] Create the log directory during the __init__ --- src/patchbot.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/patchbot.py b/src/patchbot.py index fafa199..4d3869f 100755 --- a/src/patchbot.py +++ b/src/patchbot.py @@ -294,6 +294,14 @@ def __init__(self, sage_root, server, config_path, dry_run, self.dry_run = dry_run self.plugin_only = plugin_only self.config_path = config_path + + self.log_dir = os.path.join(self.sage_root, 'logs', 'patchbot') + if not os.path.exists(self.log_dir): + os.makedirs(self.log_dir) + # Make sure this file is writable. + handle = open(os.path.join(self.log_dir, 'install.log'), 'a') + handle.close() + self.reload_config() self.last_pull = 0 self.to_skip = {} @@ -718,9 +726,6 @@ def test_a_ticket(self, ticket=None, verbose=False): print(ticket['title']) print("score", rating) print("\n" * 2) - self.log_dir = self.sage_root + "/logs/patchbot" - if not os.path.exists(self.log_dir): - os.makedirs(self.log_dir) log = '%s/%s-log.txt' % (self.log_dir, ticket['id']) history = open("%s/history.txt" % self.log_dir, "a") history.write("%s %s\n" % (datetime(), ticket['id'])) @@ -1110,13 +1115,6 @@ def main(args): print "WARNING: Do not use this copy of sage while the patchbot is running." ensure_free_space(options.sage_root) - log_dir = options.sage_root + "/logs" - if not os.path.exists(log_dir): - os.makedirs(log_dir) - # Make sure this file is writable. - handle = open(os.path.join(log_dir, 'install.log'), 'a') - handle.close() - if conf['use_ccache']: do_or_die("'%s'/sage -i ccache" % options.sage_root, exn_class=ConfigException) # If we rebuild the (same) compiler we still want to share the cache.