Commit 4e99a0e9 authored by Klaus Wölfel's avatar Klaus Wölfel

Add option to delete uploaded files

parent 9fa8c08e
...@@ -8,6 +8,7 @@ import argparse ...@@ -8,6 +8,7 @@ import argparse
def check_files(base_path=None, def check_files(base_path=None,
file_expression=None, file_expression=None,
delete_uploaded=False,
url=None, url=None,
user=None, user=None,
password=None, password=None,
...@@ -49,8 +50,12 @@ def check_files(base_path=None, ...@@ -49,8 +50,12 @@ def check_files(base_path=None,
md5sum_uploaded_file = r.text # get md5 sum of the uploaded file md5sum_uploaded_file = r.text # get md5 sum of the uploaded file
if has_bucket_key_res == 'True' : if has_bucket_key_res == 'True' :
if md5sum_local_file == md5sum_uploaded_file : if md5sum_local_file == md5sum_uploaded_file:
print("UPLOADED") if delete_uploaded is True:
os.remove(path)
print("UPLOADED and DELETED")
else:
print("UPLOADED")
else : else :
print("File is uploaded BUT md5sum is Different") print("File is uploaded BUT md5sum is Different")
diff_md5sum_list.append(path) diff_md5sum_list.append(path)
...@@ -67,6 +72,7 @@ if __name__ == "__main__": ...@@ -67,6 +72,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Test if all files are uploaded') parser = argparse.ArgumentParser(description='Test if all files are uploaded')
parser.add_argument("-b", "--base_path", help = "Base path of the files to be uploaded, e.g. /mic/syscomtestuser/syscom/SYSCOM02-12400555/background", required = True, default = "") parser.add_argument("-b", "--base_path", help = "Base path of the files to be uploaded, e.g. /mic/syscomtestuser/syscom/SYSCOM02-12400555/background", required = True, default = "")
parser.add_argument("-f", "--file_expression", help = 'File expression of the files to be uploaded, e.g. "*/*/*.BMR"', required = True, default = "") parser.add_argument("-f", "--file_expression", help = 'File expression of the files to be uploaded, e.g. "*/*/*.BMR"', required = True, default = "")
parser.add_argument("-d", "--delete_uploaded", help = "Delete files on local file system which are uploaded an have same md5sum on server as locally", action='store_true')
parser.add_argument("-u", "--url", help = "Request url to data bucket stream, e.g. https://monitoring.woelfel.de/neo-erp5/data_stream_module/26", required = True, default = "") parser.add_argument("-u", "--url", help = "Request url to data bucket stream, e.g. https://monitoring.woelfel.de/neo-erp5/data_stream_module/26", required = True, default = "")
parser.add_argument("-U", "--user", help = "Username", required = True, default = "") parser.add_argument("-U", "--user", help = "Username", required = True, default = "")
parser.add_argument("-P", "--password", help = "Password", required = True, default = "") parser.add_argument("-P", "--password", help = "Password", required = True, default = "")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment