dvc: fix progress bar

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-03-10 18:41:09 +02:00
parent 5fa796d95c
commit 5a7bee4508
3 changed files with 7 additions and 7 deletions
+1 -4
View File
@@ -15,9 +15,6 @@ class LocalKey(object):
def path(self):
return os.path.join(self.bucket, self.name)
def delete(self):
os.unlink(self.path)
class DataCloudLOCAL(DataCloudBase):
"""
@@ -52,7 +49,7 @@ class DataCloudLOCAL(DataCloudBase):
tmp_file = self.tmp_file(path)
try:
copyfile(key.path, tmp_file)
copyfile(key.path, tmp_file, no_progress_bar=no_progress_bar)
except Exception as exc:
Logger.error('Failed to copy "{}": {}'.format(key.path, exc))
return None
+1
View File
@@ -13,6 +13,7 @@ class Progress(object):
def set_n_total(self, total):
self._n_total = total
self._n_finished = 0
def _clearln(self):
print('\r\x1b[K', end='')
+5 -3
View File
@@ -45,7 +45,7 @@ def cached_property(func):
return property(get)
def copyfile(src, dest):
def copyfile(src, dest, no_progress_bar=False):
'''Copy file with progress bar'''
copied = 0
name = os.path.basename(src)
@@ -64,9 +64,11 @@ def copyfile(src, dest):
break
fdest.write(buf)
copied += len(buf)
progress.update_target(name, copied, total)
if not no_progress_bar:
progress.update_target(name, copied, total)
progress.finish_target(name)
if not no_progress_bar:
progress.finish_target(name)
fsrc.close()
fdest.close()