if __name__ == "__main__":
try:
# load parameters and configuration
- opts, args = getopt.getopt(sys.argv[1:], "hvu:s:f:t:",
- ["url=", "help", "version", "verbose", "file=", "chunk-size=", "token="])
+ opts, args = getopt.getopt(
+ sys.argv[1:],
+ "hvu:s:f:t:",
+ ["url=", "help", "version", "verbose", "file=", "chunk-size=", "token="],
+ )
url = None
chunk_size = 500
pkg_file = None
for o, a in opts:
if o == "--version":
- print("upload version " + __version__ + ' ' + version_date)
+ print("upload version " + __version__ + " " + version_date)
sys.exit()
elif o in ("-v", "--verbose"):
verbose += 1
index = 0
transaction_id = None
file_md5 = md5()
- with open(pkg_file, 'rb') as f:
+ with open(pkg_file, "rb") as f:
headers = {
"Content-type": "application/gzip",
"Content-Filename": basename(pkg_file),
# "chunk_size": chunk_size}
if transaction_id:
headers["Transaction-Id"] = transaction_id
- if index+len(chunk_data) == total_size:
+ if index + len(chunk_data) == total_size:
headers["Content-File-MD5"] = file_md5.hexdigest()
# payload["id"] = transaction_id
- headers["Content-range"] = "bytes {}-{}/{}".format(index, index+len(chunk_data)-1, total_size)
+ headers["Content-range"] = "bytes {}-{}/{}".format(
+ index, index + len(chunk_data) - 1, total_size
+ )
# refers to rfc2616: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
if verbose:
print("TX chunk Headers: {}".format(headers))