jwass / geojsonio.py

Open GeoJSON data on geojson.io
BSD 2-Clause "Simplified" License
121 stars 25 forks source link

KeyError: 'owner' / IncompleteResponse: None #9

Open m-deck opened 6 years ago

m-deck commented 6 years ago

Hi,

Following this tutorial: https://www.twilio.com/blog/2017/08/geospatial-analysis-python-geojson-geopandas.html

When I get to the geojsonio.display() line, I get the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/temp-venv/lib/python3.6/site-packages/github3/models.py in __init__(self, json, session)
     47         try:
---> 48             self._update_attributes(json)
     49         except KeyError as kerr:

~/temp-venv/lib/python3.6/site-packages/github3/gists/gist.py in _update_attributes(self, gist)
    324     def _update_attributes(self, gist):
--> 325         super(Gist, self)._update_attributes(gist)
    326         self.commits_url = gist['commits_url']

~/temp-venv/lib/python3.6/site-packages/github3/gists/gist.py in _update_attributes(self, gist)
     50         self.id = gist['id']
---> 51         self.owner = users.ShortUser(gist['owner'], self)
     52         self.public = gist['public']

KeyError: 'owner'

During handling of the above exception, another exception occurred:

IncompleteResponse                        Traceback (most recent call last)
<ipython-input-12-9a29351e3f24> in <module>()
----> 1 geojsonio.display(precincts)

~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in display(contents, domain, force_gist)
     34 
     35     """
---> 36     url = make_url(contents, domain, force_gist)
     37     webbrowser.open(url)
     38     return url

~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in make_url(contents, domain, force_gist, size_for_gist)
     91         url = data_url(contents, domain)
     92     else:
---> 93         gist = _make_gist(contents)
     94         url = gist_url(gist.id, domain)
     95 

~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in _make_gist(contents, description, filename)
    170     ghapi = github3.GitHub()
    171     files = {filename: {'content': contents}}
--> 172     gist = ghapi.create_gist(description, files)
    173 
    174     return gist

~/temp-venv/lib/python3.6/site-packages/github3/github.py in create_gist(self, description, files, public)
    303         url = self._build_url('gists')
    304         json = self._json(self._post(url, data=new_gist), 201)
--> 305         return self._instance_or_null(gists.Gist, json)
    306 
    307     @requires_auth

~/temp-venv/lib/python3.6/site-packages/github3/models.py in _instance_or_null(self, instance_class, json)
    144             return None
    145 
--> 146         return instance_class(json, self)
    147 
    148     def _json(self, response, expected_status_code, include_cache_info=True):

~/temp-venv/lib/python3.6/site-packages/github3/models.py in __init__(self, json, session)
     48             self._update_attributes(json)
     49         except KeyError as kerr:
---> 50             raise exceptions.IncompleteResponse(json, kerr)
     51 
     52     def _update_attributes(self, json):

IncompleteResponse: None The library was expecting more data in the response (KeyError('owner',)). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.
jwass commented 6 years ago

It looks like this is a bug in the latest github3.py 1.0.1 release. I updated the requirements file to pin to 0.7.0 which should fix this.

jwass commented 6 years ago

@m-deck I filed the issue with github3 here: https://github.com/sigmavirus24/github3.py/issues/795. If it gets fixed, that should fix things here. Or in the meantime, you can roll back the version of github3 that you're using.