JohnPaton / airbase

🌬 An easy downloader for the AirBase air quality data.
https://airbase.readthedocs.io
MIT License
8 stars 4 forks source link

No connection adapters were found #1

Closed b-kode closed 4 years ago

b-kode commented 4 years ago

Hi,

I very much like this tool to extract information from the Airbase database. Thanks for this. As a test, I was trying to select data from Belgium, for eg. O3 since 2018.

I tried both the download_to_file (my preference) and download_to_directory extensions.

Yet both fail at the point of 23/70. With the following error:

File "/home/demuzmp4/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3291, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in r.download_to_file(ofile) File "/home/demuzmp4/.local/lib/python3.6/site-packages/airbase/airbase.py", line 453, in download_to_file r = requests.get(url) File "/home/demuzmp4/.local/lib/python3.6/site-packages/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/home/demuzmp4/.local/lib/python3.6/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/home/demuzmp4/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "/home/demuzmp4/.local/lib/python3.6/site-packages/requests/sessions.py", line 640, in send adapter = self.get_adapter(url=request.url) File "/home/demuzmp4/.local/lib/python3.6/site-packages/requests/sessions.py", line 731, in get_adapter raise InvalidSchema("No connection adapters were found for '%s'" % url) requests.exceptions.InvalidSchema: No connection adapters were found for 'https://ereporting.blob.core.windows.net/downloadservice/BE_6001_42519_2018_timeseries.csv'

They do fail at the same URL, while this file can be downloaded via a browser.

To me it is not clear why this fails. I also tried with raise_for_status=False, but the problem persists.

Would it make sense that the download functions include a try error statement, allowing them to continue even though it fails to retrieve a file?

Or perhaps there is another way on how to address this?

Cheers, Matthias

JohnPaton commented 4 years ago

Hey, awesome that you're finding it useful!

Checking it out, I see that the link it's trying to download apparently starts with the characters '. This looks like some kind of encoding issue.

Some Googling brought me to this answer on StackOverflow: https://stackoverflow.com/a/44203507

I've tried setting the right encoding and it does seem to resolve the issue. I'll publish a new version in a minute that should fix it!

b-kode commented 4 years ago

Testing the new version now. Seems to work fine so far. Thanks for finding the encoding issue, I clearly overlooked the funny characters at the beginning of the url strings.

JohnPaton commented 4 years ago

Just published the new version on PyPI, should work if you pip install --upgrade airbase (the new version is 0.2.4). Glad it's working now, don't hesitate to give me a shout if you have any other issues!