From 9353fcc9315eb76eed0202fd063f391ecd371fbd Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Thu, 16 Jun 2011 13:01:09 -0700 Subject: [PATCH] Move summary inside context. This will hopefully make run_tasks usable by tasks. The ceph task can't use it yet, because it has its yield inside the with nested statement. --- teuthology/run.py | 9 +++++---- teuthology/run_tasks.py | 9 ++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index c3b3926d3efe9..dbd24cce37ee5 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -90,11 +90,12 @@ def main(): for rem, roles in zip(remotes, ctx.config['roles']): ctx.cluster.add(rem, roles) + ctx.summary = {} + + from teuthology.run_tasks import run_tasks try: - summary = {} - from teuthology.run_tasks import run_tasks - run_tasks(tasks=ctx.config['tasks'], ctx=ctx, summary=summary) + run_tasks(tasks=ctx.config['tasks'], ctx=ctx) finally: if ctx.archive is not None: with file(os.path.join(ctx.archive, 'summary.yaml'), 'w') as f: - yaml.safe_dump(summary, f, default_flow_style=False) + yaml.safe_dump(ctx.summary, f, default_flow_style=False) diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index 5baa97fda45dd..0c20d5d411444 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -13,7 +13,7 @@ def _run_one_task(taskname, **kwargs): fn = getattr(mod, subtask) return fn(**kwargs) -def run_tasks(tasks, ctx, summary): +def run_tasks(tasks, ctx): stack = [] try: for taskdict in tasks: @@ -27,7 +27,7 @@ def run_tasks(tasks, ctx, summary): manager.__enter__() stack.append(manager) except: - summary['success'] = False + ctx.summary['success'] = False log.exception('Saw exception from tasks') finally: try: @@ -38,7 +38,7 @@ def run_tasks(tasks, ctx, summary): try: suppress = manager.__exit__(*exc_info) except: - summary['success'] = False + ctx.summary['success'] = False log.exception('Manager failed: %s', manager) else: if suppress: @@ -51,5 +51,4 @@ def run_tasks(tasks, ctx, summary): finally: # be careful about cyclic references del exc_info - if 'success' not in summary: - summary['success'] = True + ctx.summary.setdefault('success', True) -- 2.47.3