Skip to content

Commit

Permalink
add progress on list()
Browse files Browse the repository at this point in the history
  • Loading branch information
ghewgill committed Sep 25, 2008
1 parent b60d4ac commit 1967ff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion s3lib
Submodule s3lib updated 1 files
+3 −1 s3lib.py
10 changes: 7 additions & 3 deletions shaback.py
Expand Up @@ -182,6 +182,10 @@ def walktree(base, callback):
else:
print "Skipping", path

def progress(**args):
sys.stdout.write("%d\r" % args['count'])
sys.stdout.flush()

def backup(path):
shabackpath = os.path.join(os.environ['HOME'], ".shaback")
if not os.access(shabackpath, os.F_OK):
Expand Down Expand Up @@ -358,7 +362,7 @@ def reffiles(allowunencryptable):

def fsck():
print "Reading blobs"
blobdir = s3.list(Config.Bucket, "?prefix=blob/")
blobdir = s3.list(Config.Bucket, "?prefix=blob/", callback = progress)
hashlen = hashlib.sha1().digest_size * 2
blobs = frozenset([x['Key'][5:5+hashlen] for x in blobdir['Contents']])
print "%d blobs found" % len(blobs)
Expand Down Expand Up @@ -392,7 +396,7 @@ def fsck():

def gc():
print "Reading blobs"
blobdir = s3.list(Config.Bucket, "?prefix=blob/")
blobdir = s3.list(Config.Bucket, "?prefix=blob/", callback = progress)
hashlen = hashlib.sha1().digest_size * 2
blobs = dict([(x['Key'][5:5+hashlen], x['Key']) for x in blobdir['Contents']])
print "%d blobs found" % len(blobs)
Expand Down Expand Up @@ -421,7 +425,7 @@ def gc():
def refresh():
shabackpath = os.path.join(os.environ['HOME'], ".shaback")
print "Reading blobs"
blobdir = s3.list(Config.Bucket, "?prefix=blob/")
blobdir = s3.list(Config.Bucket, "?prefix=blob/", callback = progress)
hashlen = hashlib.sha1().digest_size * 2
blobs = dict([(x['Key'][5:5+hashlen], x['Key'][5+hashlen:]) for x in blobdir['Contents']])
print "%d blobs found" % len(blobs)
Expand Down

0 comments on commit 1967ff8

Please sign in to comment.