anaconda-graveyard / nb_anacondacloud

Interact with Anaconda Cloud
BSD 2-Clause "Simplified" License
5 stars 9 forks source link

Doesn't work with Python 3 (Unicode) #2

Closed bollwyvl closed 8 years ago

bollwyvl commented 8 years ago

When running this against an environment created like:

conda create -n anaconda-cloud python=3.5

First, I was getting some JSON decode errors. These were fixed by using tornado.escape.json_decode instead of json.loads.

After fixing those, I see this when I click the upload button I get an error like the one below:

    Traceback (most recent call last):
      File "/home/weg/miniconda3/envs/anaconda-notebook/lib/python3.5/site-packages/tornado/web.py", line 1443, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/home/weg/miniconda3/envs/anaconda-notebook/lib/python3.5/site-packages/tornado/web.py", line 2800, in wrapper
        return method(self, *args, **kwargs)
      File "/home/weg/Documents/work/cio/nb_anacondacloud/nb_anacondacloud/nbextension/handlers.py", line 60, in post
        self.finish(json.dumps(uploader.upload()))
      File "/home/weg/Documents/work/cio/nb_anacondacloud/nb_anacondacloud/nbextension/uploader.py", line 48, in upload
        re.sub('\-ipynb$', '', self.name))
      File "/home/weg/miniconda3/envs/anaconda-notebook/lib/python3.5/site-packages/anaconda_client-1.1.1-py3.5.egg/binstar_client/__init__.py", line 412, in upload
        _hexmd5, b64md5, size = compute_hash(fd, size=size)
      File "/home/weg/miniconda3/envs/anaconda-notebook/lib/python3.5/site-packages/anaconda_client-1.1.1-py3.5.egg/binstar_client/utils/__init__.py", line 259, in compute_hash
        hash_obj.update(s)
    TypeError: Unicode-objects must be encoded before hashing

This looks pretty hard to fix, as it appears to be buried deep inside the client library (last line).