apache / accumulo-proxy

Apache Accumulo Proxy
https://accumulo.apache.org
Apache License 2.0
9 stars 19 forks source link

Update Proxy to work with Python 3 #13

Open mikewalch opened 4 years ago

mikewalch commented 4 years ago

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 commented 4 years ago

What failed?

mikewalch commented 4 years ago

@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 commented 4 years ago

Will it work if the following is changed:

-testtable = "pythontest"
+testtable = b'pythontest'
DomGarguilo commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.