Mercurial > hg > beaglert
changeset 540:67a746eea29e prerelease
Updated uploader.py
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 24 Jun 2016 02:12:35 +0100 |
parents | b486344aa796 |
children | c301cc07ae11 |
files | scripts/hvresources/uploader.py |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/hvresources/uploader.py Fri Jun 24 01:43:53 2016 +0100 +++ b/scripts/hvresources/uploader.py Fri Jun 24 02:12:35 2016 +0100 @@ -1,6 +1,7 @@ # Copyright 2015,2016 Enzien Audio, Ltd. All Rights Reserved. import argparse +import datetime import getpass import json import os @@ -130,6 +131,34 @@ # parse the optional release argument if args.release: + try: + # check the validity of the current release + releases_json = requests.get(urlparse.urljoin(domain, "/a/releases")).json() + if args.release in releases_json: + today = datetime.datetime.now() + valid_until = datetime.datetime.strptime(releases_json[args.release]["validUntil"], "%Y-%m-%d") + if today > valid_until: + print "{0}Warning:{1} The release \"{2}\" expired on {3}. It may be removed at any time!".format( + Colours.yellow, Colours.end, + args.release, + releases_json[args.release]["validUntil"]) + elif (valid_until - today) <= datetime.timedelta(weeks=4): + print "{0}Warning:{1} The release \"{2}\" will expire soon on {3}.".format( + Colours.yellow, Colours.end, + args.release, + releases_json[args.release]["validUntil"]) + else: + print "{0}Error:{1} The release \"{2}\" is not available. Available releases are:".format( + Colours.red, Colours.end, + args.release) + for k,v in releases_json.items(): + print "* {0} ({1})".format( + k, + v["releaseDate"]) + return + except: + pass # if the /a/releases request fails for whatever reason, just move on + post_data["release"] = args.release # make a temporary directory