Mercurial > hg > beaglert
changeset 299:df710a88e355
Updated Heavy uploader.py file
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 13:23:37 +0100 |
parents | ff1d22e2c5a0 |
children | 18996c7dfac1 |
files | scripts/hvresources/uploader.py |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/hvresources/uploader.py Fri May 27 01:00:46 2016 +0100 +++ b/scripts/hvresources/uploader.py Fri May 27 13:23:37 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): @@ -131,8 +136,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 +154,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,