Mercurial > hg > beaglert
diff scripts/hvresources/uploader.py @ 403:83e1acf38d35 prerelease
Updated build_pd_heavy to support the release flag
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Wed, 15 Jun 2016 02:37:34 +0100 |
parents | c768ed1055b0 |
children | b6eb94378ca9 |
line wrap: on
line diff
--- a/scripts/hvresources/uploader.py Wed Jun 15 02:21:13 2016 +0100 +++ b/scripts/hvresources/uploader.py Wed Jun 15 02:37:34 2016 +0100 @@ -24,14 +24,19 @@ underline = "\033[4m" end = "\033[0m" +# the maxmimum file upload size of 1MB +__HV_MAX_UPLOAD_SIZE = 1024*1024 + def __zip_dir(in_dir, zip_path, file_filter=None): + """Recursively zip an entire directory with an optional file filter + """ zf = zipfile.ZipFile(zip_path, mode="w", compression=zipfile.ZIP_DEFLATED) for subdir, dirs, files in os.walk(in_dir): - for file in files: - if (file_filter is None) or (len(file_filter) > 0 and file.lower().split(".")[-1] in file_filter): + for f in files: + if (file_filter is None) or (f.lower().split(".")[-1] in file_filter): zf.write( - filename=os.path.join(subdir,file), - arcname=os.path.relpath(os.path.join(subdir,file), start=in_dir)) + filename=os.path.join(subdir,f), + arcname=os.path.relpath(os.path.join(subdir,f), start=in_dir)) return zip_path def __unzip(zip_path, target_dir): @@ -72,6 +77,9 @@ default=["./"], # by default help="List of destination directories for retrieved files. Order should be the same as for --gen.") parser.add_argument( + "-r", "--release", + help="Optionally request a specific release of Heavy to use while compiling.") + parser.add_argument( "-d", "--domain", default="https://enzienaudio.com", help="Domain. Default is https://enzienaudio.com.") @@ -120,6 +128,10 @@ tick = time.time() + # parse the optional release argument + if args.release: + post_data["release"] = args.release + # make a temporary directory temp_dir = tempfile.mkdtemp(prefix="lroyal-") @@ -131,8 +143,11 @@ args.input_dir, os.path.join(temp_dir, "archive.zip"), file_filter={"pd"}) + if os.stat(zip_path).st_size > __HV_MAX_UPLOAD_SIZE: + raise Exception("The target directory, zipped, is {0} bytes. The maximum upload size of 1MB.".format( + os.stat(zip_path).st_size)) except Exception as e: - print e + print "{0}Error:{1} {2}".format(Colours.red, Colours.end, e) shutil.rmtree(temp_dir) # clean up the temporary directory return @@ -146,7 +161,7 @@ "wwise", "wwise-win-x86_64", "vst2", "vst2-osx", "vst2-win-x86_64", } - post_data["gen"] = list(({"c"} | set(args.gen)) & __SUPPORTED_GENERATOR_SET) + post_data["gen"] = list(({"c"} | {s.lower() for s in set(args.gen)}) & __SUPPORTED_GENERATOR_SET) # upload the job, get the response back # NOTE(mhroth): multipart-encoded file can only be sent as a flat dictionary,