formatting: Fix a few error codes and the progress bar
Change-Id: I52945ddf8dae6cf50a34e74cee28fbb62f5d95d4
diff --git a/mdt/command.py b/mdt/command.py
index ed9eca9..79064b4 100644
--- a/mdt/command.py
+++ b/mdt/command.py
@@ -80,7 +80,7 @@
return 1
except console.ConnectionClosedError as e:
if e.exit_code:
- print("\r\nConnection to {0} at {1} closed with exit code"
+ print("\r\nConnection to {0} at {1} closed with exit code "
"{2}".format(self.device, self.address, e.exit_code))
else:
print("\r\nConnection to {0} at {1} "
diff --git a/mdt/files.py b/mdt/files.py
index ed77cd4..67afcfd 100644
--- a/mdt/files.py
+++ b/mdt/files.py
@@ -32,17 +32,16 @@
def MakeProgressFunc(full_filename, width, char='>'):
def closure(bytes_xferred, total_bytes):
- pcnt = bytes_xferred / total_bytes
filename = full_filename
if len(filename) > FILENAME_WIDTH:
filename = filename[0:FILENAME_WIDTH - 3] + '...'
- left = char * int(pcnt * width - 1)
- right = ' ' * int((1 - pcnt) * width)
+
+ pcnt = bytes_xferred / total_bytes
+ left = char * round(pcnt * width)
+ right = ' ' * round((1 - pcnt) * width)
pcnt = '%3d' % (int(pcnt * 100))
- sys.stdout.write('\r{0}% |{1}{2}| {3}'.format(pcnt,
- left,
- right,
- filename))
+ sys.stdout.write('\r{0}% |{1}{2}| {3}'.format(
+ pcnt, left, right, filename))
sys.stdout.flush()
return closure