summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason <zxcv1884@gmail.com>2022-02-07 17:55:16 +0800
committerJason <zxcv1884@gmail.com>2022-02-07 21:10:10 +0800
commit163a49259d025e220e9de4fc2a6296c2c3053500 (patch)
treebd3d9df60c34cd37635cf7c374d8eb8c0e4cb1a8
parent72c616c8451ca0c2fc0077e1996c0e53630430f7 (diff)
Fix _psplash_pipe part was skipped when _progress_file is null
-rw-r--r--bmaptools/BmapCopy.py56
1 files changed, 27 insertions, 29 deletions
diff --git a/bmaptools/BmapCopy.py b/bmaptools/BmapCopy.py
index dba24a5..ca22aba 100644
--- a/bmaptools/BmapCopy.py
+++ b/bmaptools/BmapCopy.py
@@ -396,36 +396,34 @@ class BmapCopy(object):
else:
_log.debug("wrote %d blocks" % blocks_written)
- if not self._progress_file:
- return
-
- if self.mapped_cnt:
- progress = '\r' + self._progress_format % percent + '\n'
- else:
- # Do not rotate the wheel too fast
- now = datetime.datetime.now()
- min_delta = datetime.timedelta(milliseconds=250)
- if now - self._progress_time < min_delta:
- return
- self._progress_time = now
-
- progress_wheel = ('-', '\\', '|', '/')
- progress = '\r' + progress_wheel[self._progress_index % 4] + '\n'
- self._progress_index += 1
-
- # This is a little trick we do in order to make sure that the next
- # message will always start from a new line - we switch to the new
- # line after each progress update and move the cursor up. As an
- # example, this is useful when the copying is interrupted by an
- # exception - the error message will start form new line.
- if self._progress_started:
- # The "move cursor up" escape sequence
- self._progress_file.write('\033[1A') # pylint: disable=W1401
- else:
- self._progress_started = True
+ if self._progress_file:
+ if self.mapped_cnt:
+ progress = '\r' + self._progress_format % percent + '\n'
+ else:
+ # Do not rotate the wheel too fast
+ now = datetime.datetime.now()
+ min_delta = datetime.timedelta(milliseconds=250)
+ if now - self._progress_time < min_delta:
+ return
+ self._progress_time = now
+
+ progress_wheel = ('-', '\\', '|', '/')
+ progress = '\r' + progress_wheel[self._progress_index % 4] + '\n'
+ self._progress_index += 1
+
+ # This is a little trick we do in order to make sure that the next
+ # message will always start from a new line - we switch to the new
+ # line after each progress update and move the cursor up. As an
+ # example, this is useful when the copying is interrupted by an
+ # exception - the error message will start form new line.
+ if self._progress_started:
+ # The "move cursor up" escape sequence
+ self._progress_file.write('\033[1A') # pylint: disable=W1401
+ else:
+ self._progress_started = True
- self._progress_file.write(progress)
- self._progress_file.flush()
+ self._progress_file.write(progress)
+ self._progress_file.flush()
# Update psplash progress when configured. This is using a best effort
# strategy to not affect the writing process when psplash breaks, is