diff --git a/S3/MultiPart.py b/S3/MultiPart.py index 2a054b4fa..c25d34080 100644 --- a/S3/MultiPart.py +++ b/S3/MultiPart.py @@ -91,7 +91,7 @@ def upload_all_parts(self, extra_label=''): if filename != "": size_left = file_size = os.stat(deunicodise(filename))[ST_SIZE] - nr_parts = file_size / self.chunk_size + (file_size % self.chunk_size and 1) + nr_parts = file_size // self.chunk_size + (file_size % self.chunk_size and 1) debug("MultiPart: Uploading %s in %d parts" % (filename, nr_parts)) else: debug("MultiPart: Uploading from %s" % filename) diff --git a/S3/Progress.py b/S3/Progress.py index 9dab4ae3f..a348a569c 100644 --- a/S3/Progress.py +++ b/S3/Progress.py @@ -6,7 +6,7 @@ ## License: GPL Version 2 ## Copyright: TGRMN Software and contributors -from __future__ import absolute_import +from __future__ import absolute_import, division import sys import datetime @@ -77,16 +77,18 @@ def display(self, new_file = False, done_message = None): print_size = S3.Utils.formatSize(self.current_position, True) if print_size[1] != "": print_size[1] += "B" timedelta = self.time_current - self.time_start - sec_elapsed = timedelta.days * 86400 + timedelta.seconds + float(timedelta.microseconds)/1000000.0 + sec_elapsed = timedelta.days * 86400 + timedelta.seconds + float(timedelta.microseconds) / 1000000.0 print_speed = S3.Utils.formatSize((self.current_position - self.initial_position) / sec_elapsed, True, True) self._stdout.write("100%% %s%s in %.2fs (%.2f %sB/s)\n" % (print_size[0], print_size[1], sec_elapsed, print_speed[0], print_speed[1])) self._stdout.flush() return - rel_position = self.current_position * 100 / self.total_size + rel_position = (self.current_position * 100) // self.total_size if rel_position >= self.last_milestone: - self.last_milestone = (int(rel_position) / 5) * 5 + # Move by increments of 5. + # NOTE: to check: Looks like to not do what is looks like to be designed to do + self.last_milestone = (rel_position // 5) * 5 self._stdout.write("%d%% ", self.last_milestone) self._stdout.flush() return @@ -127,7 +129,7 @@ def display(self, new_file = False, done_message = None): self._stdout.write("%(current)s of %(total)s %(percent)3d%% in %(elapsed)ds %(speed).2f %(speed_coeff)sB/s" % { "current" : str(self.current_position).rjust(len(str(self.total_size))), "total" : self.total_size, - "percent" : self.total_size and (self.current_position * 100 / self.total_size) or 0, + "percent" : self.total_size and ((self.current_position * 100) // self.total_size) or 0, "elapsed" : sec_elapsed, "speed" : print_speed[0], "speed_coeff" : print_speed[1] @@ -164,7 +166,7 @@ def display(self, new_file = False, done_message = None): output = " %(current)s of %(total)s %(percent)3d%% in %(elapsed)4ds %(speed)7.2f %(speed_coeff)sB/s" % { "current" : str(self.current_position).rjust(len(str(self.total_size))), "total" : self.total_size, - "percent" : self.total_size and (self.current_position * 100 / self.total_size) or 0, + "percent" : self.total_size and ((self.current_position * 100) // self.total_size) or 0, "elapsed" : sec_elapsed, "speed" : print_speed[0], "speed_coeff" : print_speed[1] diff --git a/S3/S3.py b/S3/S3.py index c99f746da..e81fb8a8c 100644 --- a/S3/S3.py +++ b/S3/S3.py @@ -6,7 +6,7 @@ ## License: GPL Version 2 ## Copyright: TGRMN Software and contributors -from __future__ import absolute_import +from __future__ import absolute_import, division import sys import os @@ -1605,7 +1605,7 @@ def recv_file(self, request, stream, labels, start_position = 0, retries = _max_ #throttle if self.config.limitrate > 0: real_duration = time.time() - start_time - expected_duration = float(this_chunk)/self.config.limitrate + expected_duration = float(this_chunk) / self.config.limitrate if expected_duration > real_duration: time.sleep(expected_duration - real_duration) diff --git a/S3/Utils.py b/S3/Utils.py index 19b0f8770..53d204591 100644 --- a/S3/Utils.py +++ b/S3/Utils.py @@ -6,7 +6,7 @@ ## License: GPL Version 2 ## Copyright: TGRMN Software and contributors -from __future__ import absolute_import +from __future__ import absolute_import, division import os import sys diff --git a/s3cmd b/s3cmd index 091b35d85..861fcb624 100755 --- a/s3cmd +++ b/s3cmd @@ -19,7 +19,7 @@ ## GNU General Public License for more details. ## -------------------------------------------------------------------- -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, division import sys @@ -1105,7 +1105,7 @@ def cmd_sync_remote2remote(args): stats_info.files_deleted = deleted_count total_elapsed = max(1.0, time.time() - timestamp_start) - outstr = "Done. Copied %d files in %0.1f seconds, %0.2f files/s." % (total_files_copied, total_elapsed, seq/total_elapsed) + outstr = "Done. Copied %d files in %0.1f seconds, %0.2f files/s." % (total_files_copied, total_elapsed, seq / total_elapsed) if cfg.stats: outstr += stats_info.format_output() output(outstr) @@ -1451,7 +1451,7 @@ def cmd_sync_remote2local(args): deleted_count, deleted_size = _do_deletes(local_list) total_elapsed = max(1.0, time.time() - timestamp_start) - speed_fmt = formatSize(size_transferred/total_elapsed, human_readable = True, floating_point = True) + speed_fmt = formatSize(size_transferred / total_elapsed, human_readable = True, floating_point = True) stats_info.files = orig_remote_count stats_info.size = remote_total_size @@ -1747,7 +1747,7 @@ def cmd_sync_local2remote(args): if cfg.delete_removed and cfg.delete_after and remote_list: subcmd_batch_del(remote_list = remote_list) total_elapsed = max(1.0, time.time() - timestamp_start) - total_speed = total_elapsed and size_transferred/total_elapsed or 0.0 + total_speed = total_elapsed and size_transferred / total_elapsed or 0.0 speed_fmt = formatSize(total_speed, human_readable = True, floating_point = True)