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

fixes error in Python 3.6 related to joining bytes and strings #4

Merged
merged 2 commits into from
Jul 19, 2018

Conversation

bretthandrews
Copy link
Contributor

I tried to plot query results

from marvin.tools.query import Query
myfilter = 'nsa.z < 0.1'
q = Query(searchfilter=myfilter, returnparams=['cube.ra', 'cube.dec'])
r = q.run()
r.plot('cube.ra', 'cube.dec', show_plot=False)

which threw this error:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-c3b3ca85694f> in <module>()
      3 q = Query(searchfilter=myfilter)
      4 r = q.run()
----> 5 r.plot('nsa.z', 'nsa.z', show_plot=False)

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/tools/results.py in plot(self, x_name, y_name, **kwargs)
   1553         # computes a list of plateifus in each bin
   1554         if return_plateifus and with_hist:
-> 1555             plateifus = self.getListOf('plateifu', return_all=True)
   1556             hdata = output[2] if return_figure else output
   1557             if 'xhist' in hdata:

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/tools/results.py in getListOf(self, name, to_json, to_ndarray, return_all)
    975             params = {'searchfilter': self.searchfilter, 'format_type': 'list',
    976                       'return_all': True, 'params': self.returnparams}
--> 977             output = self._interaction(url, params, calltype='getList')
    978         else:
    979             # only deal with current page

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/tools/results.py in _interaction(self, url, params, calltype, create_set, **kwargs)
    911         # send the request
    912         try:
--> 913             ii = Interaction(route=url, params=params, stream=True)
    914         except MarvinError as e:
    915             raise MarvinError('API Query {0} call failed: {1}'.format(calltype, e))

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/extern/marvin_brain/python/brain/api/api.py in __init__(self, route, params, request_type, auth, timeout, headers, stream)
     49         # sends the request
     50         if self.url:
---> 51             self._sendRequest(request_type)
     52         else:
     53             raise BrainError('No route and/or url specified {0}'.format(self.url))

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/extern/marvin_brain/python/brain/api/api.py in _sendRequest(self, request_type)
    216         else:
    217             # Check the response if it's good
--> 218             self._checkResponse(self._response)
    219
    220     def getData(self, astype=None):

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/extern/marvin_brain/python/brain/api/api.py in _checkResponse(self, response)
    168
    169             self.status_code = response.status_code
--> 170             self.results = self._get_content(response)
    171             self.response_time = response.elapsed
    172             if not self.results:

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/extern/marvin_brain/python/brain/api/api.py in _get_content(self, response)
    121         content_type = response.headers['Content-Type']
    122         if 'json' in content_type:
--> 123             data = self._get_json_data(response)
    124         elif 'octet-stream' in content_type:
    125             data = self._get_binary_data(response)

~/projects/sdss/sas/mangawork/manga/marvin/python/marvin/extern/marvin_brain/python/brain/api/api.py in _get_json_data(self, response, chunksize)
     99
    100         if self.stream:
--> 101             resstring = ''.join([chunk for chunk in response.iter_content(chunk_size=chunksize)])
    102             json_data = json.loads(resstring.decode())
    103         else:

TypeError: sequence item 0: expected str instance, bytes found

@bretthandrews bretthandrews requested a review from havok2063 March 7, 2018 22:15
@bretthandrews bretthandrews merged commit b8d9f4b into master Jul 19, 2018
@bretthandrews bretthandrews deleted the bytes branch July 19, 2018 15:37
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

Successfully merging this pull request may close these issues.

2 participants