Skip to content

Conversation

allmightyspiff
Copy link
Member

slcli image list --public has a unicode character that causes an exception in Windows shells for some reason.

image id=1288413 is the problematic one. To reproduce on master

$ ./slcli image detail 1288413
An unexpected error has occured:
Traceback (most recent call last):
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\core.py", line 182, in main
    cli.main(**kwargs)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\image\detail.py", line 63, in cli
    env.fout(table)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\environment.py", line 56, in fout
    self.out(self.fmt(output), newline=newline)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\environment.py", line 43, in out
    click.echo(output, nl=newline)
  File "C:\Users\allmi\Source\py36\lib\site-packages\click\utils.py", line 260, in echo
    file.write(message)
  File "C:\Users\allmi\Source\py36\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u3010' in position 140: character maps to <undefined>

Feel free to report this error as it is likely a bug:
    https://github.com/softlayer/softlayer-python/issues
The following snippet should be able to reproduce the error
(py36)


$ ./slcli image list | grep 1288413
(py36)

When fixed should look like this:

$ ./slcli image detail 1288413
UnicodeEncodeError detected, printing as JSON.
{
    "id": 1288413,
    "global_identifier": "fd16452d-1a03-48b7-ae52-6b1d15632051",
    "name": "\u3010CEDEC\u3011Photon Handson image",
    "status": null,
    "active_transaction": null,
    "account": 363380,
    "visibility": "PUBLIC",
    "type": "SYSTEM",
    "flex": false,
    "note": "Photon\u30a4\u30e1\u30fc\u30b8",
    "created": "2016-08-19T01:01:52-07:00",
    "disk_space": 32203940352,
    "datacenters": "tok02,wdc01"
}

$ ./slcli image list | grep 1288413
        "id": 1288413,
(py36)

@allmightyspiff
Copy link
Member Author

Fixes #771

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 93.837% when pulling 1a59b8a on allmightyspiff:issues771 into f40fffa on softlayer:master.

@FernandoOjeda
Copy link
Contributor

It looks good, now is working well in git-bash with the new changes.

@allmightyspiff allmightyspiff merged commit f1d8f08 into softlayer:master Dec 4, 2019
@allmightyspiff allmightyspiff deleted the issues771 branch August 31, 2020 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants