mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-13 15:28:27 +01:00
dvc: fix progress bar
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+1
-4
@@ -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
|
||||
|
||||
@@ -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
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user