Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit c780ba9

Browse files
committed
BmapCopy: add a couple of debug messages
Add a couple of useful debug messages to BmapCopy. Also, do not print the progress indicator when debugging is on. Change-Id: I38aca82e3f7f9704f827f72e6d702b0c65d26b24 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
1 parent 4bb4abb commit c780ba9

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

bmaptool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def copy_command(args, log):
443443
raise SystemExit(1)
444444

445445
# Print the progress indicator while copying
446-
if not args.quiet:
446+
if not args.quiet and not args.debug:
447447
writer.set_progress_indicator(sys.stderr, "bmaptool: info: %d%% copied")
448448

449449
start_time = time.time()

bmaptools/BmapCopy.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,18 @@ def _update_progress(self, blocks_written):
347347
the 'progress_file' attribute.
348348
"""
349349

350+
if self.mapped_cnt:
351+
assert blocks_written <= self.mapped_cnt
352+
percent = int((float(blocks_written) / self.mapped_cnt) * 100)
353+
self._log.debug("wrote %d blocks out of %d (%d%%)" %
354+
(blocks_written, self.mapped_cnt, percent))
355+
else:
356+
self._log.debug("wrote %d blocks" % blocks_written)
357+
350358
if not self._progress_file:
351359
return
352360

353361
if self.mapped_cnt:
354-
assert blocks_written <= self.mapped_cnt
355-
percent = int((float(blocks_written) / self.mapped_cnt) * 100)
356362
progress = '\r' + self._progress_format % percent + '\n'
357363
else:
358364
# Do not rotate the wheel too fast
@@ -491,6 +497,9 @@ def _get_data(self, verify):
491497
hash_obj.update(buf)
492498

493499
blocks = (len(buf) + self.block_size - 1) / self.block_size
500+
self._log.debug("queueing %d blocks, queue length is %d" %
501+
(blocks, self._batch_queue.qsize()))
502+
494503
self._batch_queue.put(("range", start, start + blocks - 1,
495504
buf))
496505

0 commit comments

Comments
 (0)