if opt.verbose>=2 or (opt.verbose==1 and stat.S_ISDIR(pst.st_mode)):
sys.stdout.write('%s\n' % path)
sys.stdout.flush()
- progress('Indexing: %d\r' % total)
+ qprogress('Indexing: %d\r' % total)
elif not (total % 128):
- progress('Indexing: %d\r' % total)
+ qprogress('Indexing: %d\r' % total)
total += 1
while rig.cur and rig.cur.name > path: # deleted paths
if rig.cur.exists():
#!/usr/bin/env python
-import sys, stat, time
+import sys, stat
from bup import options, git, vfs
from bup.helpers import *
q,quiet don't show progress meter
"""
-total_restored = last_progress = 0
+total_restored = 0
def verbose1(s):
- global last_progress
if opt.verbose >= 1:
print s
- last_progress = 0
def verbose2(s):
- global last_progress
if opt.verbose >= 2:
print s
- last_progress = 0
def plog(s):
- global last_progress
if opt.quiet:
return
- now = time.time()
- if now - last_progress > 0.2:
- progress(s)
- last_progress = now
+ qprogress(s)
def do_node(top, n):
do_node(n.parent, n)
if not opt.quiet:
- log('Restoring: %d, done.\n' % total_restored)
+ progress('Restoring: %d, done.\n' % total_restored)
if saved_errors:
log('WARNING: %d errors encountered while restoring.\n' % len(saved_errors))
return tree
lastremain = None
-lastprint = 0
def progress_report(n):
- global count, subcount, lastremain, lastprint
+ global count, subcount, lastremain
subcount += n
cc = count + subcount
pct = total and (cc*100.0/total) or 0
remainstr = '%dm%d' % (mins, secs)
else:
remainstr = '%ds' % secs
- if now - lastprint > 0.1:
- progress('Saving: %.2f%% (%d/%dk, %d/%d files) %s %s\r'
- % (pct, cc/1024, total/1024, fcount, ftotal,
- remainstr, kpsstr))
- lastprint = now
-
-
-def vlog(s):
- global lastprint
- lastprint = 0
- log(s)
+ qprogress('Saving: %.2f%% (%d/%dk, %d/%d files) %s %s\r'
+ % (pct, cc/1024, total/1024, fcount, ftotal,
+ remainstr, kpsstr))
indexfile = opt.indexfile or git.repo('bupindex')
if opt.progress:
for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_pre):
if not (ftotal % 10024):
- progress('Reading index: %d\r' % ftotal)
+ qprogress('Reading index: %d\r' % ftotal)
exists = ent.exists()
hashvalid = already_saved(ent)
ent.set_sha_missing(not hashvalid)
else:
status = ' '
if opt.verbose >= 2:
- vlog('%s %-70s\n' % (status, ent.name))
+ log('%s %-70s\n' % (status, ent.name))
elif not stat.S_ISDIR(ent.mode) and lastdir != dir:
if not lastdir.startswith(dir):
- vlog('%s %-70s\n' % (status, os.path.join(dir, '')))
+ log('%s %-70s\n' % (status, os.path.join(dir, '')))
lastdir = dir
if opt.progress:
date = time.time()
-last_prog = total_bytes = 0
+total_bytes = 0
def prog(filenum, nbytes):
- global last_prog, total_bytes
+ global total_bytes
total_bytes += nbytes
- now = time.time()
- if now - last_prog < 0.2:
- return
if filenum > 0:
- progress('Splitting: file #%d, %d kbytes\r'
- % (filenum+1, total_bytes/1024))
+ qprogress('Splitting: file #%d, %d kbytes\r'
+ % (filenum+1, total_bytes/1024))
else:
- progress('Splitting: %d kbytes\r' % (total_bytes/1024))
- last_prog = now
+ qprogress('Splitting: %d kbytes\r' % (total_bytes/1024))
is_reverse = os.environ.get('BUP_SERVER_REVERSE')
for b in chunkyreader(self.conn, n):
f.write(b)
count += len(b)
- progress('Receiving index from server: %d/%d\r' % (count, n))
+ qprogress('Receiving index from server: %d/%d\r' % (count, n))
progress('Receiving index from server: %d/%d, done.\n' % (count, n))
self.check_ok()
f.close()
def idxmerge(idxlist, final_progress=True):
"""Generate a list of all the objects reachable in a PackIdxList."""
def pfunc(count, total):
- progress('Reading indexes: %.2f%% (%d/%d)\r'
- % (count*100.0/total, count, total))
+ qprogress('Reading indexes: %.2f%% (%d/%d)\r'
+ % (count*100.0/total, count, total))
def pfinal(count, total):
if final_progress:
- log('Reading indexes: %.2f%% (%d/%d), done.\n' % (100, total, total))
+ progress('Reading indexes: %.2f%% (%d/%d), done.\n'
+ % (100, total, total))
return merge_iter(idxlist, 10024, pfunc, pfinal)
def merge(*iters):
def pfunc(count, total):
- progress('bup: merging indexes (%d/%d)\r' % (count, total))
+ qprogress('bup: merging indexes (%d/%d)\r' % (count, total))
def pfinal(count, total):
- log('bup: merging indexes (%d/%d), done.\n' % (count, total))
+ progress('bup: merging indexes (%d/%d), done.\n' % (count, total))
return merge_iter(iters, 1024, pfunc, pfinal, key='name')