From 510bb2116ea3e6c0d2559fe1b0c465f010d74bfb Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Mon, 13 Nov 2017 12:18:55 +0100 Subject: utils, examples: Add ExperimentManager CM Adds an ExperimentManager context manager for scripts: - No more ugly stack traces after execution if something goes wrong - No more ugly and easy to forget try-finally blocks --- examples/snake.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/snake.py') diff --git a/examples/snake.py b/examples/snake.py index c6b67b3..6f9c48d 100755 --- a/examples/snake.py +++ b/examples/snake.py @@ -3,6 +3,7 @@ # An example script using the rumba package from rumba.model import * +from rumba.utils import ExperimentManager # import testbed plugins import rumba.testbeds.emulab as emulab @@ -18,6 +19,7 @@ import rumba.prototypes.irati as irati import argparse import sys + description = "Script to create a snake" argparser = argparse.ArgumentParser(description = description) @@ -62,8 +64,6 @@ exp = rl.Experiment(tb, nodes = nodes) print(exp) -try: +with ExperimentManager(exp): exp.swap_in() exp.bootstrap_prototype() -finally: - exp.swap_out() -- cgit v1.2.3