PyHive
                                
                                
                                
                                    PyHive copied to clipboard
                            
                            
                            
                        Add http transport for NONE authentication
Partially closes https://github.com/dropbox/PyHive/issues/69, at least for NONE auth.
Codecov Report
Merging #230 into master will decrease coverage by
0.94%. The diff coverage is31.81%.
@@           Coverage Diff            @@
##           master   #230      +/-   ##
========================================
- Coverage   93.94%    93%   -0.95%     
========================================
  Files          14     14              
  Lines        1487   1500      +13     
  Branches      159    164       +5     
========================================
- Hits         1397   1395       -2     
- Misses         64     75      +11     
- Partials       26     30       +4
| Impacted Files | Coverage Ξ | |
|---|---|---|
| pyhive/hive.py | 82.39% <31.81%> (-5.01%) | 
:arrow_down: | 
Continue to review full report at Codecov.
Legend - Click here to learn more
Ξ = absolute <relative> (impact),ΓΈ = not affected,? = missing dataPowered by Codecov. Last update d19cb0c...81a375b. Read the comment docs.
Hi! We've been attempting to utilize PyHive at our company, but were having issues so I checked out the branch on this PR to get http transport mode working, since there appear to be some issues with binary lingering in other interfaces we utilize (other matter entirely).
There seems to be an issue with string encoding when used with Python 3.6:
Traceback (most recent call last):
  File "test_s3_interface.py", line 39, in <module>
    test_hive_interface()
  File "test_s3_interface.py", line 33, in test_hive_interface
    http_path='cliservice'
  File "/Users/josephdebartola/.local/share/virtualenvs/hive-partitions-j2DAtHmC/lib/python3.6/site-packages/pyhive/hive.py", line 96, in connect
    return Connection(*args, **kwargs)
  File "/Users/josephdebartola/.local/share/virtualenvs/hive-partitions-j2DAtHmC/lib/python3.6/site-packages/pyhive/hive.py", line 206, in __init__
    credentials = base64.b64encode(username + ":" + password)
  File "/Users/josephdebartola/.local/share/virtualenvs/hive-partitions-j2DAtHmC/lib/python3.6/base64.py", line 58, in b64encode
    encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'
I got this working in 3.6 on my end by patching lines 206-207 in hive.py:
credentials = base64.b64encode((username + ":" + password).encode('utf-8'))
self._transport.setCustomHeaders({"Authorization": "Basic " + credentials.decode('utf-8')})
Thanks for all the hard work on PyHive! I am excited to use the package and am excited for the incoming improvements.
EDIT: I attempted to use this on 2.7 to see whether my change broke compatibility there, but I ended up coming up against the issue with builtins mentioned in this ticket
Thank you for pointing that out @josephpd3
 
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.