# HG changeset patch # User Giulio Moro # Date 1466730755 -3600 # Node ID 67a746eea29edd0e9906f7cfd24b2814ff738083 # Parent b486344aa796a7839e9ccf66e750a02b3c9493f1 Updated uploader.py diff -r b486344aa796 -r 67a746eea29e scripts/hvresources/uploader.py --- 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