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

CLI crashes when redirecting output #739

Closed
verdverm opened this issue Jul 7, 2016 · 2 comments
Closed

CLI crashes when redirecting output #739

verdverm opened this issue Jul 7, 2016 · 2 comments
Milestone

Comments

@verdverm
Copy link

verdverm commented Jul 7, 2016

Expected Behavior

output of CLI is piped to next command or file

Actual Behavior

CLI crashes

Environment Information

Operating System: OSX
softlayer-python version (slcli --version): 5.1.0


(cli) tony@Tonys-MBP ~VIRTUAL_ENV $ slcli image list > list2.txt ruby-2.0.0p645 tony@Tonys-MBP ~VIRTUAL_ENV $ less list2.txt [ruby-2.0.0p645]
An unexpected error has occured:
Traceback (most recent call last):
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/core.py", line 163, in main
cli.main(*_kwargs)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, *_ctx.params)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(_args, *_kwargs)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, _args[1:], *_kwargs)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(_args, *_kwargs)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/image/list.py", line 58, in cli
env.fout(table)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/environment.py", line 56, in fout
self.out(self.fmt(output), newline=newline)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/environment.py", line 51, in fmt
return formatting.format_output(output, fmt=self.format)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/formatting.py", line 39, in format_output
return str(format_no_tty(data))
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 240, in str
return self.unicode().encode(self.encoding)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 243, in unicode
return self.get_string()
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 987, in get_string
formatted_rows = self._format_rows(rows, options)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 942, in _format_rows
return [self._format_row(row, options) for row in rows]
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 939, in _format_row
return [self._format_value(field, value) for (field, value) in zip(self._field_names, row)]
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 890, in _format_value
return self._unicode(value)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/prettytable.py", line 179, in _unicode
value = str(value)
File "/Users/tony/alchemy/sl_exp/cli/lib/python2.7/site-packages/SoftLayer/CLI/formatting.py", line 326, in str
return str(self.original)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Feel free to report this error as it is likely a bug:
https://github.com/softlayer/softlayer-python/issues

@verdverm
Copy link
Author

verdverm commented Jul 7, 2016

Seems to be illegal characters have made it into the image name list

...      �201 ...
...      ��201 ...

@sudorandom
Copy link
Contributor

Ah, those must be on private images since I'm not able to reproduce on my side. I'll see if I can make a text case for this.

sudorandom added a commit that referenced this issue Jul 14, 2016
* Better handles unicode in slcli for raw output

Closes #739.

* Added a test case that will return 'invalid' instead of failing outright

Also fixes a couple new style issues

* Make the unicode test just for python 2
@sudorandom sudorandom modified the milestone: v5.2.0 Aug 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants