1. b7w
  2. s3trust

Commits

b7w  committed 87053bf

Add totally upload size

  • Participants
  • Parent commits f8745df
  • Branches dev

Comments (0)

Files changed (1)

File s3trust.py

View file
  • Ignore whitespace
     print('\nBackUp dry_run={0} debug={1}'.format(dry_run, debug))
     config = load_config(config) if type(config) is str else config
     storage = Storage(config.ACCESS_KEY, config.SECRET_KEY)
+    upload_size = 0
     for folder_config in config.FOLDERS:
         finder = Finder(folder_config.LOCAL, folder_config.OPTIONS)
         for package in finder.find():
             if not exclude and not exists:
                 archive = Archive(package, password=folder_config.PASSWORD, hide=folder_config.HIDE,
                                   level=folder_config.LEVEL, options=folder_config.OPTIONS, path_7z=config.PATH_7Z)
+                upload_size += package.size
                 for tmp_file, part in archive.archive_to(config.TMP_PATH, archive.file_name):
                     key = storage.get_key(folder_config.BUCKET, folder_config.REMOTE, archive, part)
                     if not dry_run:
                                   .format(folder_config.REMOTE, package.path, part or '000'))
                         storage.upload(key, archive, tmp_file, part)
                     package_size = package.size / 1024 ** 2
-                    print('Uploaded /{0}/{1}  {{count: {2}, size: {3}mb, part: {4}}}'
+                    print('Uploaded /{0}/{1}  {{count: {2}, size: {3} MB, part: {4}}}'
                           .format(folder_config.REMOTE, package.path, package.count, package_size, part or '000'))
                     archive.clear(tmp_file)
+
+    print('Totally uploaded: {0}'.format(humanize.naturalsize(upload_size)))
     info(config)
     clear(config)