From 649bddf71bda6fdb527f797a8b8e7ae11f96b2cd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 29 Aug 2013 09:52:45 -0700 Subject: [PATCH] run: set up archive dir and logger output sooner Signed-off-by: Sage Weil --- teuthology/run.py | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index 653fb4c2a64eb..e7e50335e59c3 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -99,6 +99,31 @@ def main(): level=loglevel, ) + if ctx.owner is None: + from teuthology.misc import get_user + ctx.owner = get_user() + + if ctx.archive is not None: + os.mkdir(ctx.archive) + + handler = logging.FileHandler( + filename=os.path.join(ctx.archive, 'teuthology.log'), + ) + formatter = logging.Formatter( + fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s', + datefmt='%Y-%m-%dT%H:%M:%S', + ) + handler.setFormatter(formatter) + logging.getLogger().addHandler(handler) + + with file(os.path.join(ctx.archive, 'pid'), 'w') as f: + f.write('%d' % os.getpid()) + + with file(os.path.join(ctx.archive, 'owner'), 'w') as f: + f.write(ctx.owner + '\n') + + with file(os.path.join(ctx.archive, 'orig.config.yaml'), 'w') as f: + yaml.safe_dump(ctx.config, f, default_flow_style=False) if 'targets' in ctx.config and 'roles' in ctx.config: targets = len(ctx.config['targets']) @@ -122,36 +147,11 @@ def main(): ctx.summary = dict(success=True) - if ctx.owner is None: - from teuthology.misc import get_user - ctx.owner = get_user() ctx.summary['owner'] = ctx.owner if ctx.description is not None: ctx.summary['description'] = ctx.description - if ctx.archive is not None: - os.mkdir(ctx.archive) - - handler = logging.FileHandler( - filename=os.path.join(ctx.archive, 'teuthology.log'), - ) - formatter = logging.Formatter( - fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s', - datefmt='%Y-%m-%dT%H:%M:%S', - ) - handler.setFormatter(formatter) - logging.getLogger().addHandler(handler) - - with file(os.path.join(ctx.archive, 'pid'), 'w') as f: - f.write('%d' % os.getpid()) - - with file(os.path.join(ctx.archive, 'owner'), 'w') as f: - f.write(ctx.owner + '\n') - - with file(os.path.join(ctx.archive, 'orig.config.yaml'), 'w') as f: - yaml.safe_dump(ctx.config, f, default_flow_style=False) - for task in ctx.config['tasks']: assert 'kernel' not in task, \ 'kernel installation shouldn be a base-level item, not part of the tasks list' -- 2.39.5