Skip to content
Snippets Groups Projects
Commit b28f2d91 authored by Philipp Goymann's avatar Philipp Goymann
Browse files

add upload file counter

parent 4b8410bb
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,10 @@ def run_s3_functions():
print('Bucket ' + args.bucketname + ' exists!')
else:
print('Bucket ' + args.bucketname + ' dont exists!')
if args.upload:
utils.check_argparser(args, ['secret', "key", "files", "bucketname"])
s3.upload_s3_objects(args.bucketname, args.files)
#--------------------------------------------------------------------------------------------------------#
# parse command line arguments:
......@@ -48,9 +52,11 @@ def argparsefunc():
parser.add_argument("--endpoint", help="URL S3",default='https://s3.mpi-bn.mpg.de')
#actions
parser.add_argument("--upload", action='store_true', help="upload files to bucket")
parser.add_argument("--bucket_exists", action='store_true', help="check if bucket exists")
#values
parser.add_argument("--files", nargs='+', help="bucket upload files")
parser.add_argument("--bucketname")
parser.add_argument("--no_log", action='store_true', help='disable logging')
......
......@@ -432,6 +432,7 @@ class Loosolab_s3:
if not self.check_s3_bucket_ex(bucket_name):
self.__exception_log__("Bucket for upload does not exist!")
return
count = 1
for local_file_name in file_list:
try:
file_name = os.path.basename(local_file_name)
......@@ -443,7 +444,7 @@ class Loosolab_s3:
else:
self.transfer.upload_file(local_file_name, bucket_name, file_name)
#self.session.Bucket(bucket_name).upload_file(local_file_name, file_name, Config=self.transfer)
self.logger.info("File " + str(local_file_name) + ' gets uploaded!')
self.logger.info("File " + str(local_file_name) + ' gets uploaded! ' + str(count) + ' of ' + str(len(file_list)))
except Exception as e:
self.__exception_log__("S3: Uploading files failed!" ,e)
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment