Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETA causes crash in #71

Closed
tivaro opened this issue Jun 18, 2016 · 2 comments
Closed

ETA causes crash in #71

tivaro opened this issue Jun 18, 2016 · 2 comments

Comments

@tivaro
Copy link

tivaro commented Jun 18, 2016

The following code works with progressbar2==3.6.2,
however, when progressbar2==3.8.0 it breaks.

The download stops working after the first iteration. (the script just hangs)

I played with the code for hours, I thought it might have something to do with the uneven update sizes, but it doesn't. Interestingly AbsoluteETA does not cause a crash, but displays elapsed time instead of ETA.

I am using python 2.7.6 on Ubuntu 14.04

def default_pbar(max_value=None, prefix='     '):
    widgets = [
        prefix,
        progressbar.Bar('=', '[', ']'),
        #' ', Bar(marker=progressbar.RotatingMarker()),
        ' ', progressbar.Counter(), '/', `max_value`,
        ' ', '(', progressbar.Percentage(), ')',
        ' ', progressbar.FileTransferSpeed(),
        ' ', progressbar.ETA(),
        ' ',
    ]
    return progressbar.ProgressBar(widgets=widgets, max_value=max_value, redirect_stdout=True)

def retrieveFile(web_location, local_location):
    #progressbar update function
    def dlProgress(count, blockSize, totalSize):
        if pbar.max_value != totalSize:
            pbar.max_value = totalSize
        pbar.update(min(count*blockSize, totalSize))

    dl_size = int(urllib.urlopen(web_location).info().getheaders("Content-Length")[0])
    pbar =default_pbar(dl_size)
    pbar.start()
    urllib.urlretrieve(web_location, local_location, reporthook=dlProgress)
    pbar.finish()

retrieveFile('ftp://ftp.ncbi.nlm.nih.gov/pub/pmc/articles.A-B.tar.gz', 'articles.A-B.tar.gz')
@wolph
Copy link
Owner

wolph commented Jun 18, 2016

That's really unfortunate, I'll see if I can find the cause of the problem

@wolph
Copy link
Owner

wolph commented Jun 23, 2016

I found the problem, it simply wasn't updating often enough. It works as expected again. I'll create a new release within a few hours :)

@wolph wolph closed this as completed Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants