hydroshare / hs_restclient

Python client for the https://www.hydroshare.org REST API
BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

AttributeError: 'tuple' object has no attribute 'request' #123

Closed amabdallah closed 4 years ago

amabdallah commented 4 years ago

Hi @Castronova and @sblack-usu

When I run this very basic connection, I get the error below. My code used to work fine last year but not anymore. Any suggestions?

username = 'myusername'
password = 'mypass'

from hs_restclient import HydroShare, HydroShareAuthBasic
auth = HydroShareAuthBasic(username=username, password=password)
hs = HydroShare(auth=auth)
for resource in hs.resources():
    print(resource)

File "C:\Python38\lib\site-packages\hs_restclient\generators.py", line 12, in resultsListGenerator raise HydroShareHTTPException((url, 'GET', r.status_code, params)) File "C:\Python38\lib\site-packages\hs_restclient\exceptions.py", line 61, in init self.url = response.request.url AttributeError: 'tuple' object has no attribute 'request'

Castronova commented 4 years ago

@amabdallah Which version of the hs_restclient are you using? Can you run the following command:

python -c "import hs_restclient; print(hs_restclient.__version__)"
Castronova commented 4 years ago

@sblack-usu @amabdallah I was able to reproduce this error in version 1.3.6.

usr = 'username'
psk = 'password'

from hs_restclient import HydroShare, HydroShareAuthBasic
auth = HydroShareAuthBasic(username=usr, password=psk)
hs = HydroShare(auth=auth)

resources = hs.resources()

# try to print the first resource.
next(resources)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/castro/miniconda2/envs/hsrest/lib/python3.6/site-packages/hs_restclient/generators.py", line 12, in resultsListGenerator
    raise HydroShareHTTPException((url, 'GET', r.status_code, params))
  File "/Users/castro/miniconda2/envs/hsrest/lib/python3.6/site-packages/hs_restclient/exceptions.py", line 61, in __init__
    self.url = response.request.url
AttributeError: 'tuple' object has no attribute 'request'
sblack-usu commented 4 years ago

This has already been fixed in develop, it just needs a release. I can do the release today.

amabdallah commented 4 years ago

Thanks, @Castronova and @sblack-usu . Sorr I should've listed the version. Right, it was the latest one as posted here v1.3.6 https://hs-restclient.readthedocs.io/en/latest/

sblack-usu commented 4 years ago

Just released the 1.3.7 which will provide a proper exception image

amabdallah commented 4 years ago

@sblack-usu would you please propagate this release here? https://hs-restclient.readthedocs.io/en/latest/

I'm having issues installing the latest release v1.3.7 from GitHub. It is still pulling the 1.3.6