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

Support unicode characters #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support unicode characters #44

wants to merge 1 commit into from

Conversation

nh13
Copy link

@nh13 nh13 commented May 27, 2020

The following two commands work just fine:

enasearch retrieve_run_report --accession PRJNA473989 --file results.txt
enasearch retrieve_run_report --accession PRJNA473989

But the following gives an exception

$ enasearch retrieve_run_report --accession PRJNA473989 > /dev/null
Traceback (most recent call last):
  File "/path/to/bin/enasearch", line 6, in <module>
    from enasearch.__main__ import main
  File "/path/to/lib/python2.7/site-packages/enasearch/__main__.py", line 6, in <module>
    cli.cli()
  File "/path/to/lib/python2.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/lib/python2.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/path/to/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/path/to/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/lib/python2.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/path/to/lib/python2.7/site-packages/enasearch/cli.py", line 20, in handle_exception
    raise click.ClickException(e)
  File "/path/to/lib/python2.7/site-packages/click/exceptions.py", line 23, in __init__
    ctor_msg = ctor_msg.encode("utf-8")
AttributeError: 'exceptions.UnicodeEncodeError' object has no attribute 'encode'

This is because the run report has a Unicode character

@@ -43,6 +43,7 @@ def print_complex_field_dict(d):

def print_display(results, display):
"""Print the results given the choosen display"""
results = results.encode("utf-8")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be better handled for python 2/3, and str/bytes/unicode

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.

1 participant