From: Zack Cerza Date: Tue, 11 Nov 2014 17:41:14 +0000 (-0700) Subject: Add dry-run option X-Git-Tag: 1.1.0~1072^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2030dd973a11e15d9c4567619e4f165563bb328;p=teuthology.git Add dry-run option Signed-off-by: Zack Cerza --- diff --git a/scripts/results.py b/scripts/results.py index 73b417ab3..7ff01e98e 100644 --- a/scripts/results.py +++ b/scripts/results.py @@ -1,11 +1,12 @@ """ -usage: teuthology-results [-h] [-v] [--email EMAIL] [--timeout TIMEOUT] --archive-dir DIR --name NAME +usage: teuthology-results [-h] [-v] [--dry-run] [--email EMAIL] [--timeout TIMEOUT] --archive-dir DIR --name NAME Email teuthology suite results optional arguments: -h, --help show this help message and exit -v, --verbose be more verbose + --dry-run Instead of sending the email, just print it --email EMAIL address to email test failures to --timeout TIMEOUT how many seconds to wait for all tests to finish (default no wait) diff --git a/teuthology/results.py b/teuthology/results.py index 20274f394..7fd31c9df 100644 --- a/teuthology/results.py +++ b/teuthology/results.py @@ -23,18 +23,19 @@ def main(args): if args['--verbose']: teuthology.log.setLevel(logging.DEBUG) - log_path = os.path.join(args['--archive-dir'], 'results.log') - teuthology.setup_log_file(log_path) + if not args['--dry-run']: + log_path = os.path.join(args['--archive-dir'], 'results.log') + teuthology.setup_log_file(log_path) try: results(args['--archive-dir'], args['--name'], args['--email'], - args['--timeout']) + args['--timeout'], args['--dry-run']) except Exception: log.exception('error generating results') raise -def results(archive_dir, name, email, timeout): +def results(archive_dir, name, email, timeout, dry_run): archive_base = os.path.split(archive_dir)[0] serializer = ResultsSerializer(archive_base) starttime = time.time() @@ -51,10 +52,15 @@ def results(archive_dir, name, email, timeout): (subject, body) = build_email_body(name, archive_dir) try: - if email: + if email and dry_run: + print "From: %s" % (config.results_sending_email or 'teuthology') + print "To: %s" % email + print "Subject: %s" % subject + print body + elif email: email_results( subject=subject, - from_=config.results_sending_email or 'teuthology', + from_=(config.results_sending_email or 'teuthology'), to=email, body=body, )