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

urlgrabber.progress.TextMeter fails with "TypeError: '>' not supported between instances of 'NoneType' and 'int'" #24

Closed
jchax opened this issue Mar 30, 2020 · 3 comments · Fixed by #25

Comments

@jchax
Copy link

jchax commented Mar 30, 2020

Description of problem:

Trying to use urlgrabber with a text progress meter fails with "TypeError: '>' not supported between instances of 'NoneType' and 'int'"

Version-Release number of selected component (if applicable):
python3-urlgrabber-4.0.0-4.fc31

How reproducible: Always

Steps to Reproduce:
1.
Run this program:

#!/usr/bin/python3

from urlgrabber.grabber import URLGrabber
from urlgrabber.progress import TextMeter

g = URLGrabber(progress_obj=TextMeter())
g.urlgrab('https://download.fedoraproject.org/pub/fedora/linux/releases/31/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-31-1.9.iso')

(use a different URL if you prefer)

  1. Wait a short while

Actual results:

Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1940, in _progress_update
self.opts.progress_obj.update(downloaded)
File "/usr/lib/python3.7/site-packages/urlgrabber/progress.py", line 149, in update
self._do_update(amount_read, now)
File "/usr/lib/python3.7/site-packages/urlgrabber/progress.py", line 251, in _do_update
ave_dl = format_number(self.re.average_rate())
File "/usr/lib/python3.7/site-packages/urlgrabber/progress.py", line 785, in format_number
while number > thresh and depth < max_depth:
TypeError: '>' not supported between instances of 'NoneType' and 'int'
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1580, in _do_perform
self.curl_obj.perform()
pycurl.error: (42, 'Callback aborted')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./grabber.py", line 7, in
g.urlgrab('https://download.fedoraproject.org/pub/fedora/linux/releases/31/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-31-1.9.iso')
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1256, in urlgrab
return self._retry(opts, retryfunc, url, filename)
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1145, in _retry
r = func(opts, *args)
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1241, in retryfunc
fo = PyCurlFileObject(url, filename, opts)
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1343, in init
self._do_open()
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1692, in _do_open
self._do_grab()
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1826, in _do_grab
self._do_perform()
File "/usr/lib/python3.7/site-packages/urlgrabber/grabber.py", line 1615, in _do_perform
raise KeyboardInterrupt
KeyboardInterrupt

Expected results:

A nice progress bar and, after a while, an iso.

Additional info:

I got 160KiB downloaded before the error message and nothing else was displayed at all.

Although this is against Fedora31, I get the same error on Fedora 30 and using python2 instead of python3 everything works as expected both on Fedora31 and Fedora30.

@jchax
Copy link
Author

jchax commented Mar 30, 2020

Initialising ave_rate to zero instead of None in RateEstimator fixes that problem. Changing "blen" to "int(blen)" in _term_add_bar() fixes the next one to show up. Both of those are in /usr/lib/python3.7/site-packages/urlgrabber/progress.py

Hope that helps.

@jchax
Copy link
Author

jchax commented Mar 30, 2020

brejoc added a commit to brejoc/urlgrabber-1 that referenced this issue Apr 1, 2020
Type errors would prevent TextMeter from being used as a
progess_option.
This commit fixes this with a type cast and an initialization of
a variable as int.

Fixes rpm-software-management#24
Conan-Kudo pushed a commit that referenced this issue Apr 3, 2020
Type errors would prevent TextMeter from being used as a
progess_option.
This commit fixes this with a type cast and an initialization of
a variable as int.

Fixes #24
@nikosmoum
Copy link

It's fixed, but it would be good to get it in an rpm or pypi release

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

Successfully merging a pull request may close this issue.

2 participants