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

Python3 support #40

Open
stephenpardy opened this issue Nov 23, 2016 · 3 comments
Open

Python3 support #40

stephenpardy opened this issue Nov 23, 2016 · 3 comments

Comments

@stephenpardy
Copy link

Does not currently support Python3. First noticed when tried to import client:

ImportError Traceback (most recent call last)
in ()
8 matplotlib.rcParams.update(matplotlib.rcParamsDefault)
9
---> 10 import uws.UWS.client as client
11
12 get_ipython().magic('matplotlib inline')

/usr/local/lib/python3.5/site-packages/uws/UWS/init.py in ()
1 # -- coding: utf-8 --
----> 2 import client
3 import connection
4 import models
5

ImportError: No module named 'client'

The error arises because Python3 needs relative imports to be explicitly defined.

@lupinix
Copy link

lupinix commented Nov 23, 2016

Yep, just checked that too. Imports and prints can be fixed quite easily using the 2to3 tool. But there are also differences in byte/string handling (see example below). These can be fixed by usage of six

`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/lupinix/uws-client/venv/lib64/python3.5/base64.py in _input_type_check(s)
517 try:
--> 518 m = memoryview(s)
519 except TypeError as err:

TypeError: memoryview: a bytes-like object is required, not 'str'

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
in ()
----> 1 cli = client.Client(url, username, password)

/home/lupinix/uws-client/uws/UWS/client.py in init(self, url, user, password, connection)
15 self.connection = connection
16 else:
---> 17 self.connection = UWSConnection.Connection(url, user, password)
18
19 def get_job_list(self, filters=None):

/home/lupinix/uws-client/uws/UWS/connection.py in init(self, url, user, password)
13
14 if user is not None and password is not None:
---> 15 self.auth_string = base64.encodestring('%s:%s' % (user, password))
16 self.auth_string = self.auth_string.replace('\n', '')
17 self.headers = {"Authorization": "Basic %s" % self.auth_string}

/home/lupinix/uws-client/venv/lib64/python3.5/base64.py in encodestring(s)
545 warnings.warn("encodestring() is a deprecated alias, use encodebytes()",
546 DeprecationWarning, 2)
--> 547 return encodebytes(s)
548
549

/home/lupinix/uws-client/venv/lib64/python3.5/base64.py in encodebytes(s)
533 """Encode a bytestring into a bytes object containing multiple lines
534 of base-64 data."""
--> 535 _input_type_check(s)
536 pieces = []
537 for i in range(0, len(s), MAXBINSIZE):

/home/lupinix/uws-client/venv/lib64/python3.5/base64.py in _input_type_check(s)
519 except TypeError as err:
520 msg = "expected bytes-like object, not %s" % s.class.name
--> 521 raise TypeError(msg) from err
522 if m.format not in ('c', 'b', 'B'):
523 msg = ("expected single byte elements, not %r from %s" %

TypeError: expected bytes-like object, not str`

@stephenpardy
Copy link
Author

I managed to kludge together a fix for the byte-string issue, and switch the imports and print statements, but then I got a 403 error when trying to submit a request:

UWSError: No permission to access this resource

I checked the credentials on the online version and confirmed that I could actually login.
Perhaps related to the byte-string issue, or something else?

@viogp
Copy link

viogp commented Feb 8, 2021

I see a pull request that with the description "Python3 support", could this be integrated?
Right now, with the python3 installation (python3 -m pip install uws-client) something is not working properly:

'''
File ".../python3.8/site-packages/uws/UWS/init.py", line 2, in
import client
ModuleNotFoundError: No module named 'client'

'''

The module client is there, though.

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

3 participants