We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Upon embarking on an existing datapackage, we run into a string/bytes error:
import flotilla study = flotilla.embark('REDACTED', flotilla_dir=flotilla_dir)
2016-08-08 11:13:09 Reading datapackage from /projects/ps-yeolab/obotvinnik/flotilla_projects/REDACTED/datapackage.json 2016-08-08 11:13:09 Parsing datapackage to create a Study object --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-42-33d8552efa65> in <module>() 1 import flotilla 2 ----> 3 study = flotilla.embark('REDACTED', flotilla_dir=flotilla_dir) /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/__init__.py in embark(study_name, load_species_data, flotilla_dir) 63 study_name))) 64 return Study.from_datapackage_file(filename, ---> 65 load_species_data=load_species_data) 66 except IOError: 67 return Study.from_datapackage_url(study_name, /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/study.py in from_datapackage_file(cls, datapackage_filename, load_species_data, species_datapackage_base_url) 484 datapackage, datapackage_dir=datapackage_dir, 485 load_species_data=load_species_data, --> 486 species_datapackage_base_url=species_datapackage_base_url) 487 488 @staticmethod /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/study.py in from_datapackage(cls, datapackage, datapackage_dir, load_species_data, species_datapackage_base_url) 587 if load_species_data and species is not None: 588 species_kws = cls.load_species_data(species, cls.readers, --> 589 species_datapackage_base_url) 590 591 try: /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/study.py in load_species_data(species, readers, species_datapackage_base_url) 631 species_datapackage_base_url, species) 632 species_datapackage = datapackage_url_to_dict( --> 633 species_data_url) 634 635 for resource in species_datapackage['resources']: /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/datapackage.py in datapackage_url_to_dict(datapackage_url) 25 26 def datapackage_url_to_dict(datapackage_url): ---> 27 filename = check_if_already_downloaded(datapackage_url) 28 29 with open(filename) as f: /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/site-packages/flotilla/datapackage.py in check_if_already_downloaded(url, datapackage_name, download_dir) 60 opener = build_opener() 61 opened_url = opener.open(req) ---> 62 datapackage = json.loads(opened_url.read()) 63 datapackage_name = datapackage['name'] 64 /home/obotvinnik/anaconda/envs/py3k/lib/python3.5/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 310 if not isinstance(s, str): 311 raise TypeError('the JSON object must be str, not {!r}'.format( --> 312 s.__class__.__name__)) 313 if s.startswith(u'\ufeff'): 314 raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)", TypeError: the JSON object must be str, not 'bytes'
Is the solution here to force opened_url.read() to a string type? This is using the urllib2 package within the standard libarary.
opened_url.read()
urllib2
The text was updated successfully, but these errors were encountered:
@olgabot The error could be fixed by using a decode() method. So the line would be: datapackage = json.loads(opened_url.read().decode('utf-8'))
decode()
datapackage = json.loads(opened_url.read().decode('utf-8'))
Sorry, something went wrong.
No branches or pull requests
Upon embarking on an existing datapackage, we run into a string/bytes error:
Is the solution here to force
opened_url.read()
to a string type? This is using theurllib2
package within the standard libarary.The text was updated successfully, but these errors were encountered: