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

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' #20

Closed
nongiach opened this issue Jun 7, 2018 · 4 comments

Comments

@nongiach
Copy link

nongiach commented Jun 7, 2018

Hey, thx for this module.
When I download the very same zip file from github sometimes it crashes but most of the time it works.

    download(URL, master_zip, Config.DOWNLOAD_CACHE_DIR)
  File "/usr/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.5/dist-packages/arm_now/download.py", line 30, in download
    obj.start()
  File "/usr/local/lib/python3.5/dist-packages/pySmartDL/pySmartDL.py", line 266, in start
    self.filesize = int(urlObj.headers["Content-Length"])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

http://github.com/nongiach/arm_now

@cquark7
Copy link

cquark7 commented Jun 24, 2018

It happens because pySmartDL assumes that webserver will always send the "Content-Length" header in its response. Some servers don't do that. In order to fix this error lot of changes are required in source code of this library.

@nongiach
Copy link
Author

The server I use sends the "Content-Length", as matter of fact for the same server and same file, same link, same config, one time I get an error and another time everything is fine the file is downloaded. Could it be because of some internal caching or buffering done by pySmartDL?

iTaybb added a commit that referenced this issue Feb 18, 2019
@iTaybb
Copy link
Owner

iTaybb commented Feb 18, 2019

Fixed.

@iTaybb iTaybb closed this as completed Feb 18, 2019
@todaynowork
Copy link

Seem there is another place need to be fixed

2020-02-12 23:41:18,343 - __main__ - ERROR - int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Traceback (most recent call last):
  File "/Users/todaynowork/git/Images_Extract/report_images_extract_russia.py", line 258, in fecthReceipts
    obj = downloadImage(report_url, dest)
  File "/Users/todaynowork/git/Images_Extract/report_images_extract_russia.py", line 363, in downloadImage
    obj = SmartDL(file_uri, dest=dest, progress_bar=False)
  File "/Users/todaynowork/git/Images_Extract/.venv/lib/python3.8/site-packages/pySmartDL/pySmartDL.py", line 133, in __init__
    if not utils.is_HTTPRange_supported(self.url, timeout=self.timeout):
  File "/Users/todaynowork/git/Images_Extract/.venv/lib/python3.8/site-packages/pySmartDL/utils.py", line 107, in is_HTTPRange_supported
    filesize = int(urlObj.headers["Content-Length"])

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

4 participants