From 68652703d6e8dcd546b1ff80aba1e1413c12615c Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Fri, 27 Jul 2018 10:42:35 +1000 Subject: [PATCH] Update render-statistics for new election style * Fix candidate detection to look for files containing an '@' rather than ending in '.txt' * Clarify the tool description * Exit early if it's a TC election * This election cycle used a slightly different label for the nomination phase :/ my bad Change-Id: I8250952341850e0d58cc3910a20931060d670e88 --- openstack_election/cmds/render_statistics.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openstack_election/cmds/render_statistics.py b/openstack_election/cmds/render_statistics.py index 9aff7d6c..fbf657ea 100755 --- a/openstack_election/cmds/render_statistics.py +++ b/openstack_election/cmds/render_statistics.py @@ -45,7 +45,7 @@ def collect_project_stats(basedir, verbose): project = directory[len(basedir):] if project == "TC": continue - candidates = list(filter(lambda x: x.endswith('.txt'), filenames)) + candidates = list(filter(lambda x: '@' in x, filenames)) candidates_count = len(candidates) if not filenames == []: @@ -63,7 +63,7 @@ def collect_project_stats(basedir, verbose): def main(): - parser = argparse.ArgumentParser(description='Investigate Nominations') + parser = argparse.ArgumentParser(description='Investigate PTL Nominations') parser.add_argument('-v', '--verbose', action="count", default=0, help='Increase program verbosity') parser.add_argument('-r', '--release', default=utils.conf['release'], @@ -74,13 +74,17 @@ def main(): args = parser.parse_args() + if utils.is_tc_election(): + print('This tool only works for PTL elections not TC') + return 0 + args.basedir = os.path.join(args.basedir, 'candidates', args.release, '') args.basedir = os.path.expanduser(args.basedir) collect_project_stats(args.basedir, args.verbose) now = datetime.datetime.now(tz=pytz.utc) now = now.replace(microsecond=0) - event = utils.get_event('PTL nomination') + event = utils.get_event('PTL Nominations') start, end = event['start'], event['end'] duration = (end - start) remaining = (end - now) @@ -116,3 +120,5 @@ def main(): " ".join(without_candidate))) print("=" * 51) print("%-25s @ %s" % ("Stats gathered", as_utctime(now))) + + return 0