From 981ba7290debe412f03a1334536ec9510fdf231d Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Fri, 26 Sep 2014 16:17:23 +0000 Subject: [PATCH] Specify ATC contribution start/end in seconds Change-Id: Ic62b00782f1ef709ce6f7b14217d36f02e230d79 --- tools/atc/README | 10 +++++----- tools/atc/email_stats.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/atc/README b/tools/atc/README index eeba3f6833..ca5d58e166 100644 --- a/tools/atc/README +++ b/tools/atc/README @@ -13,12 +13,12 @@ elections and Summit invitations. virtualenv venv . venv/bin/activate pip install paramiko requests pyyaml - ./email_stats.py --begin + ./email_stats.py --begin # optionally specify --end, --keyfile, --ref and --user - DATE=`date --iso` - mv out $DATE - cat $DATE/*.csv | sort | uniq > $DATE/all.csv + TIME=`date +%Y%m%d%H%M%S` + mv out $TIME + cat $TIME/*.csv | sort | uniq > $TIME/all.csv 4) You can use diff.py to get the new ATCs since the previous run: - ./diff.py $OLD-DATE/all.csv $DATE/all.csv $DATE/new.csv + ./diff.py $OLD-TIME/all.csv $TIME/all.csv $TIME/new.csv diff --git a/tools/atc/email_stats.py b/tools/atc/email_stats.py index 9dd45b4d8d..644e738b3c 100755 --- a/tools/atc/email_stats.py +++ b/tools/atc/email_stats.py @@ -109,10 +109,12 @@ def project_stats(project, output, begin, end, keyfile, user): done = False last_sortkey = '' - start_date = datetime.datetime(int(begin[0:4]), int(begin[4:6]), - int(begin[6:8]), 0, 0, 0) - end_date = datetime.datetime(int(end[0:4]), int(end[4:6]), int(end[6:8]), - 0, 0, 0) + begin_time = datetime.datetime( + int(begin[0:4]), int(begin[4:6]), int(begin[6:8]), + int(begin[8:10]), int(begin[10:12]), int(begin[12:14])) + end_time = datetime.datetime( + int(end[0:4]), int(end[4:6]), int(end[6:8]), + int(end[8:10]), int(end[10:12]), int(end[12:14])) count = 0 earliest = datetime.datetime.now() @@ -138,7 +140,7 @@ def project_stats(project, output, begin, end, keyfile, user): if aprv['type'] != 'SUBM': continue ts = datetime.datetime.fromtimestamp(aprv['grantedOn']) - if ts < start_date or ts > end_date: + if ts < begin_time or ts > end_time: continue approved = True if ts < earliest: @@ -177,14 +179,14 @@ def get_extra_atcs(url): def main(): - today = ''.join( - '%02d' % x for x in datetime.datetime.utcnow().utctimetuple()[:3]) + now = ''.join( + '%02d' % x for x in datetime.datetime.utcnow().utctimetuple()[:6]) optparser = optparse.OptionParser() optparser.add_option( - '-b', '--begin', help='begin date (e.g. 20131017)') + '-b', '--begin', help='begin date/time (e.g. 20131017000000)') optparser.add_option( - '-e', '--end', default=today, help='end date (default is today)') + '-e', '--end', default=now, help='end date/time (default is now)') optparser.add_option( '-k', '--keyfile', default='~/.ssh/id_rsa', help='SSH key (default is ~/.ssh/id_rsa)')