author | Leandro Lucarella
<luca@llucax.hn.org> 2005-03-04 19:39:51 UTC |
committer | Leandro Lucarella
<luca@llucax.hn.org> 2005-03-04 19:39:51 UTC |
parent | d4d00bb45eb5ec2bb827a7186915d65e2bfcb2ce |
abk | +18 | -11 |
diff --git a/abk b/abk index b73578b..9357610 100644 --- a/abk +++ b/abk @@ -340,17 +340,17 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): src_path = src # load destination index - print "* loading destination index" + if verbose: print "* loading destination index" dstidx = index_file(dstidx_path) dstidx.load() # create source index - print "* building source index" + if verbose: print "* building source index" srcidx = index_file(srcidx_path) srcidx.populate(src_path) srcidx.save() - print "* sync" + if verbose: print "* sync" # compare them update_files = [] @@ -360,7 +360,7 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # files missing in destination, or data changed #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - print 'data\t', f, dst + if verbose: print 'data\t', f, dst quiet_unlink(dst) srcidx.db[f].copy_file(dst) update_files.append((f, dst)) @@ -368,14 +368,14 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # metadata changed #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - print 'mdata\t', f, dst + if verbose: print 'mdata\t', f, dst update_files.append((f, dst)) # metadata gets changed later because otherwise we could leave # directory times wrong due to files being added to a directory after # their creation; this way we're sure there will be no more file # creation afterwards - print '* mdata' + if verbose: print '* mdata' for f, dst in update_files: try: srcidx.db[f].update_mdata(dst) @@ -386,27 +386,27 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # back together pass - print '* unlink' + if verbose: print '* unlink' for f in dstidx.names: if f not in srcidx.names: # files in destination and not in source #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - print 'unlink\t', f, dst + if verbose: print 'unlink\t', f, dst force_unlink(dst, dstidx.db[f].type) def show_idx(idx_path): - print "* loading index" + if verbose: print "* loading index" idx = index_file(idx_path) idx.load() for f in idx.names: fi = idx.db[f] - print "%s %d %f %s %s" % (fi.type, fi.size, fi.mtime, + if verbose: print "%s %d %f %s %s" % (fi.type, fi.size, fi.mtime, str(fi.hash), fi.name) def build_idx(idx_path, path): - print "* building index" + if verbose: print "* building index" # see comments in make_sync() while path[-1] == '/' and path != '/': @@ -457,6 +457,12 @@ commands: parser = AbkOptionParser(usage=usage, description="A backup script - " "Alberto Bertogli (albertogli@telpin.com.ar)", version="%prog " + VERSION, prog='abk') + parser.add_option("-v", "--verbose", + action="store_true", dest="verbose", default=True, + help="print progress information [default]") + parser.add_option("-q", "--quiet", + action="store_false", dest="verbose", + help="don't print progress information (just errors)") parser.add_option("-c", "--copy-mode", default='gzip', metavar="MODE", help="select copy mode to use. Available modes: " "raw, gzip, bzip2 [default: gzip]") @@ -473,6 +479,7 @@ commands: # command line options (parser, opts, args) = parse_options() +verbose = opts.verbose # configuration if opts.copy_mode == 'raw':