From cdbc906dc9e4cecc842ae7ae44b5f4c49fab0543 Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Fri, 11 Mar 2016 13:30:48 +1100 Subject: [PATCH] Validate extra-atcs Change-Id: I7c3324d73a4fc18329270f845aba6904d3f9a539 --- requirements.txt | 2 ++ test-requirements.txt | 1 - tools/check-candidacy.py | 22 ++++++++++++++++++++-- tox.ini | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..a92ad975 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pytz +PyYAML>=3.1.0,<=3.10 diff --git a/test-requirements.txt b/test-requirements.txt index 530fddc1..d29aa208 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,4 +4,3 @@ # needed for doc build sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 oslosphinx>=2.5.0 # Apache-2.0 -PyYAML>=3.1.0,<=3.10 diff --git a/tools/check-candidacy.py b/tools/check-candidacy.py index 6836255a..ec1a13ac 100755 --- a/tools/check-candidacy.py +++ b/tools/check-candidacy.py @@ -6,6 +6,7 @@ import sys import urllib import re import datetime +import pytz DATE_MIN = '2015-03-04' DATE_MAX = '2016-01-03' @@ -17,6 +18,18 @@ PROJECTS_URL = ('%s/openstack/governance/plain/reference/projects.yaml?%s' % date_min = datetime.datetime.strptime(DATE_MIN, '%Y-%m-%d').strftime('%s') date_max = datetime.datetime.strptime(DATE_MAX, '%Y-%m-%d').strftime('%s') +now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc, + hour=0, + minute=0, + second=0, + microsecond=0) + + +def check_atc_date(atc): + if 'expires-in' not in atc: + return False + expires_in = datetime.datetime.strptime(atc['expires-in'], '%B %Y').replace(tzinfo=pytz.utc) + return now < expires_in def check_date(date): @@ -40,7 +53,7 @@ except: exit(1) project_name = project_name.replace('_', ' ') -author = escape_author(author) +author = author.replace('_', ' ') if not os.path.isfile('.projects.yaml'): open('.projects.yaml', 'w').write( @@ -58,9 +71,14 @@ else: exit(1) for project in project_list: + for atc in project['extra-atcs']: + if atc['name'] == author and check_atc_date(atc): + print "Valid extra ATC record", atc + exit(0) for deliverable in project['deliverables'].values(): for repo_name in deliverable["repos"]: - url = '%s/%s/log/?qt=author&q=%s' % (BASE_URL, repo_name, author) + url = '%s/%s/log/?qt=author&q=%s' % (BASE_URL, repo_name, + escape_author(author)) print "Querying: %s" % url found = False for l in urllib.urlopen(url).read().split('\n'): diff --git a/tox.ini b/tox.ini index d16e0f4c..3ddfdcf4 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,8 @@ skipsdist = True usedevelop = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/test-requirements.txt +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt [testenv:venv] commands = {posargs}