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

Update Proxy to work with Python 3 #13

Open
mikewalch opened this issue Dec 17, 2019 · 7 comments
Open

Update Proxy to work with Python 3 #13

mikewalch opened this issue Dec 17, 2019 · 7 comments

Comments

@mikewalch
Copy link
Member

I tried to create a Proxy client in Python 3 but it did not work. This is probably due to the thrift bindings need to be regenerated to work with Python 3.

@ctubbsii
Copy link
Member

What failed?

@mikewalch
Copy link
Member Author

@ctubbsii , Below is the traceback:

Traceback (most recent call last):
  File "example.py", line 43, in <module>
    client.updateAndFlush(login, testtable, row1)
  File "/accumulo-proxy/src/main/python/accumulo/AccumuloProxy.py", line 3763, in updateAndFlush
    self.send_updateAndFlush(login, tableName, cells)
  File "/accumulo-proxy/src/main/python/accumulo/AccumuloProxy.py", line 3772, in send_updateAndFlush
    args.write(self._oprot)
  File "/accumulo-proxy/src/main/python/accumulo/AccumuloProxy.py", line 20327, in write
    oprot.writeBinary(kiter403)
  File "/.virtualenvs/accumulo-python-client-yg6HPmFr/lib/python3.7/site-packages/thrift/protocol/TCompactProtocol.py", line 42, in nested
    return func(self, *args, **kwargs)
  File "/.virtualenvs/accumulo-python-client-yg6HPmFr/lib/python3.7/site-packages/thrift/protocol/TCompactProtocol.py", line 283, in __writeBinary
    self.trans.write(s)
  File "/.virtualenvs/accumulo-python-client-yg6HPmFr/lib/python3.7/site-packages/thrift/transport/TTransport.py", line 292, in write
    self.__wbuf.write(buf)
TypeError: a bytes-like object is required, not 'str'

@ctubbsii
Copy link
Member

Will it work if the following is changed:

-testtable = "pythontest"
+testtable = b'pythontest'

@DomGarguilo
Copy link
Member

Will it work if the following is changed:

-testtable = "pythontest"
+testtable = b'pythontest'

After making this change its complaining because its not a string

Traceback (most recent call last):
  File "/home/dgarguilo/Documents/python-accumulo-client/basic_client.py", line 39, in <module>
    if not client.tableExists(login, testtable):
  File "/home/dgarguilo/.local/share/virtualenvs/python-accumulo-client-M0ijMr3p/lib/python3.10/site-packages/accumulo/AccumuloProxy.py", line 2462, in tableExists
    self.send_tableExists(login, tableName)
  File "/home/dgarguilo/.local/share/virtualenvs/python-accumulo-client-M0ijMr3p/lib/python3.10/site-packages/accumulo/AccumuloProxy.py", line 2470, in send_tableExists
    args.write(self._oprot)
  File "/home/dgarguilo/.local/share/virtualenvs/python-accumulo-client-M0ijMr3p/lib/python3.10/site-packages/accumulo/AccumuloProxy.py", line 14577, in write
    oprot.writeString(self.tableName.encode('utf-8') if sys.version_info[0] == 2 else self.tableName)
  File "/home/dgarguilo/.local/share/virtualenvs/python-accumulo-client-M0ijMr3p/lib/python3.10/site-packages/thrift/protocol/TProtocol.py", line 122, in writeString
    self.writeBinary(str_to_binary(str_val))
  File "/home/dgarguilo/.local/share/virtualenvs/python-accumulo-client-M0ijMr3p/lib/python3.10/site-packages/thrift/compat.py", line 43, in str_to_binary
    return bytes(str_val, 'utf8')
TypeError: encoding without a string argument

@DomGarguilo
Copy link
Member

It seems like python3 is not supported by thrift so I don't think we would be able to get the proxy working with it.

@DomGarguilo
Copy link
Member

It seems like python3 is not supported by thrift so I don't think we would be able to get the proxy working with it.

This might be wrong actually, still looking into this.

@ctubbsii
Copy link
Member

I think thrift has spent some time getting python3 working... possibly a lot has changed since this issue was originally created. There may still be some quirks with it, though, as holdover from trying to support both python2 and python3.

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