uskudnik / amazon-glacier-cmd-interface

Command line interface for Amazon Glacier
MIT License
374 stars 100 forks source link

Progress bar #40

Closed wvmarle closed 12 years ago

wvmarle commented 12 years ago

Posting here because I can't get git to commit it for a pull request. It sees the changes but no commit.

glacier.py:244 onwards.

    # if filename is given, use filename then look at stdio if theres something there
    total_size = 0
    if not stdin:
        try:
            reader = open(filename, 'rb')
            total_size = os.path.getsize(filename)
        except IOError:
            print "Couldn't access the file given."
            return False
    elif select.select([sys.stdin,],[],[],0.0)[0]:
        reader = sys.stdin
    else:
        print "Nothing to upload."
        return False

    #Read file in chunks so we don't fill whole memory
    for part in iter((lambda:reader.read(READ_PART_SIZE)), ''):
        writer.write(part)
        if total_size > 0:
            progress('\rWrote %s of %s bytes (%s%%).' %
                     (locale.format('%d', writer.uploaded_size, grouping=True),
                      locale.format('%d', total_size, grouping=True),
                      int(100 * writer.uploaded_size/total_size)))
        else:
            progress('\rWrote %s bytes.\n' % (locale.format('%d', writer.uploaded_size, grouping=True)))

    writer.close()
    if total_size > 0:
        progress('\rWrote %s of %s bytes (%s%%).' %
                 (locale.format('%d', writer.uploaded_size, grouping=True),
                  locale.format('%d', total_size, grouping=True),
                  int(100 * writer.uploaded_size/total_size)))
    else:
        progress('\rWrote %s bytes.\n' % (locale.format('%d', writer.uploaded_size, grouping=True)))
offlinehacker commented 12 years ago

That looks nice, will add it to code and test it, but granularity is not the best. GlacierWriter should yield progress.

offlinehacker commented 12 years ago

Please don't close this issue request, we need to add more granularity to progress bar

wvmarle commented 12 years ago

For granularity I think this is the best we can get. This is sent over http so I assume somewhere downstream it's going to httplib and that doesn't provide any progress afaik.

Anyway I now managed to push my changes into my own fork, but the "pull request" button remains a pale green, and just doesn't seem to work. No idea what I'm doing wrong now.

wvmarle commented 12 years ago

Forgot to add a title to the pull request...

uskudnik commented 12 years ago

Hehe, no biggie, I merged @offlinehacker pull request now. Thanks for your help!

@offlinehacker What else did you have in mind with more modularity? Do you still want to keep this one open or do we write a new one?

offlinehacker commented 12 years ago

I ment granularity, so progress bar would be more precise. Meybe we even don't need that. Support for upload interrupt on chunk basis is more important right now.

uskudnik commented 12 years ago

Agreed.

wvmarle commented 12 years ago

Progress bar finished. Can't do a commit now as with all my testing my branch is way too different from the main branch... too many little edits all over the place. It now looks like: Wrote 64.0 MB of 538.3 MB (11%). Rate 1.43 MB/s, average 1.41 MB/s, eta 23:30:58. Eta time calculated using the average rate so far.

offlinehacker commented 12 years ago

Nice, i will cherry pick changes and push them to my branch and then to uskudnik.

On Wed, Sep 26, 2012 at 5:27 PM, wvmarle notifications@github.com wrote:

Progress bar finished. Can't do a commit now as with all my testing my branch is way too different from the main branch... too many little edits all over the place. It now looks like: Wrote 64.0 MB of 538.3 MB (11%). Rate 1.43 MB/s, average 1.41 MB/s, eta 23:30:58.

— Reply to this email directly or view it on GitHubhttps://github.com/uskudnik/amazon-glacier-cmd-interface/issues/40#issuecomment-8893858.