forked from third-party-mirrors/zfs_autobackup
progress output
This commit is contained in:
parent
f530cf40f3
commit
f4e81bddb7
@ -56,4 +56,4 @@ class TestTreeHasher(unittest2.TestCase):
|
|||||||
shelltest("rm /tmp/treehashertest/whole")
|
shelltest("rm /tmp/treehashertest/whole")
|
||||||
|
|
||||||
self.assertEqual(list(tree_hasher.compare("/tmp/treehashertest", generator)),
|
self.assertEqual(list(tree_hasher.compare("/tmp/treehashertest", generator)),
|
||||||
[('whole', '-', '-', "ERROR: [Errno 2] No such file or directory: 'whole'")])
|
[('whole', '-', '-', "ERROR: [Errno 2] No such file or directory: '/tmp/treehashertest/whole'")])
|
||||||
|
@ -43,8 +43,7 @@ class ZfsCheck(CliBase):
|
|||||||
args = super(ZfsCheck, self).parse_args(argv)
|
args = super(ZfsCheck, self).parse_args(argv)
|
||||||
|
|
||||||
if args.test:
|
if args.test:
|
||||||
self.warning("TEST MODE - NOT DOING ANYTHING USEFULL")
|
self.warning("TEST MODE - WILL ONLY DO READ-ONLY STUFF")
|
||||||
self.log.show_debug = True # show at least what we would do
|
|
||||||
|
|
||||||
if args.target is None:
|
if args.target is None:
|
||||||
self.error("Please specify TARGET")
|
self.error("Please specify TARGET")
|
||||||
@ -198,15 +197,27 @@ class ZfsCheck(CliBase):
|
|||||||
else:
|
else:
|
||||||
input_fh=open(file_name, 'r')
|
input_fh=open(file_name, 'r')
|
||||||
|
|
||||||
|
last_progress_time = time.time()
|
||||||
|
progress_count = 0
|
||||||
|
|
||||||
for line in input_fh:
|
for line in input_fh:
|
||||||
i=line.rstrip().split("\t")
|
i=line.rstrip().split("\t")
|
||||||
#ignores lines without tabs
|
#ignores lines without tabs
|
||||||
if (len(i)>1):
|
if (len(i)>1):
|
||||||
|
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
|
progress_count=progress_count+1
|
||||||
|
if self.args.progress and time.time() - last_progress_time > 1:
|
||||||
|
last_progress_time = time.time()
|
||||||
|
self.progress("Checked {} hashes.".format(progress_count))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
last_progress_time = time.time()
|
||||||
|
progress_count = 0
|
||||||
|
|
||||||
#run as generator
|
#run as generator
|
||||||
if self.args.check==None:
|
if self.args.check==None:
|
||||||
for i in self.generate(input_generator=None):
|
for i in self.generate(input_generator=None):
|
||||||
@ -214,6 +225,12 @@ class ZfsCheck(CliBase):
|
|||||||
print("{}\t{}\t{}".format(*i))
|
print("{}\t{}\t{}".format(*i))
|
||||||
else:
|
else:
|
||||||
print("{}\t{}".format(*i))
|
print("{}\t{}".format(*i))
|
||||||
|
progress_count=progress_count+1
|
||||||
|
|
||||||
|
if self.args.progress and time.time()-last_progress_time>1:
|
||||||
|
last_progress_time=time.time()
|
||||||
|
self.progress("Generated {} hashes.".format(progress_count))
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user