X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Fupload.py;h=dfd73020213480ca39b47c3253d4b6aa18c2f475;hp=d256801a438b1de624d602db13555c6fcb48a69f;hb=4568a372eb5a204e04d917213de03ec51f9110c1;hpb=786aeddab7b7491a139c958ecec6439bee5da83a diff --git a/osm_nbi/tests/upload.py b/osm_nbi/tests/upload.py index d256801..dfd7302 100755 --- a/osm_nbi/tests/upload.py +++ b/osm_nbi/tests/upload.py @@ -41,8 +41,11 @@ def usage(): 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 @@ -51,7 +54,7 @@ if __name__ == "__main__": 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 @@ -72,7 +75,7 @@ if __name__ == "__main__": 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), @@ -87,10 +90,12 @@ if __name__ == "__main__": # "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))