linode-cli icon indicating copy to clipboard operation
linode-cli copied to clipboard

`linode-cli obj --help` throws UnicodeEncodeError

Open jtara1 opened this issue 3 years ago • 2 comments

using: windows 10 python 3.6.0 git bash

$ linode-cli --version
linode-cli 4.0.0
Built off spec version 4.85.0
$ linode-cli obj --help
Traceback (most recent call last):
  File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python36\Scripts\linode-cli.exe\__main__.py", line 7, in <module>
  File "c:\python36\lib\site-packages\linodecli\__init__.py", line 404, in main
    plugins.invoke(parsed.command, plugin_args, context)
  File "c:\python36\lib\site-packages\linodecli\plugins\__init__.py", line 33, in invoke
    plugin.call(args, context)
  File "c:\python36\lib\site-packages\linodecli\plugins\obj.py", line 669, in call
    print(tab.table)
  File "c:\python36\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-79: character maps to <undefined>
usage: linode-cli obj [--cluster CLUSTER] [COMMAND]

positional arguments:
  COMMAND            The command to execute in object storage

optional arguments:
  --cluster CLUSTER  The cluster to use for the operation

Available commands:

jtara1 avatar Mar 07 '21 23:03 jtara1

Thanks for the report!

I'm afraid I can't reproduce this with just python 3.6 - I ran the following in a python:3.6 docker:

root@fd8473f2ce98:/# linode-cli obj --help
usage: linode-cli obj [--cluster CLUSTER] [COMMAND]

positional arguments:
  COMMAND            The command to execute in object storage

optional arguments:
  --cluster CLUSTER  The cluster to use for the operation

Available commands:
┌───────────┬──────────────────────────────────────────────────────────────────┐
│ del       │ Removes a file from a bucket                                     │
│ du        │ Shows space used by all buckets in this cluster, and total space │
│ get       │ Retrieves an uploaded object and writes it to a file             │
│ la        │ Lists all objects in all buckets                                 │
│ ls        │ Lists buckets or objects                                         │
│ mb        │ Creates a new bucket                                             │
│ put       │ Uploads an object to object storage                              │
│ rb        │ Deletes a bucket                                                 │
│ rm        │ Removes a file from a bucket                                     │
│ setacl    │ Modify Access Control List for a Bucket or Objects               │
│ signurl   │ Generates a URL to an object                                     │
│ ws-create │ Turns a bucket into a static website                             │
│ ws-delete │ Disables static site for a bucket                                │
│ ws-info   │ Returns info about a configured static site                      │
└───────────┴──────────────────────────────────────────────────────────────────┘

That's the expected output.

I suspect your system is having trouble encoding the table border characters, which lines up with the stack trace and the output that was printed. Can you confirm this by running linode-cli --help, which should use the same table border characters (and produce the same error if that is the problem)?

Dorthu avatar Mar 08 '21 12:03 Dorthu

Hey there @jtara1!

Is this issue still occurring for you?

LBGarber avatar Sep 06 '22 16:09 LBGarber

This issue seems related to #161.

I haven't been able to reproduce this issue on my end but if you're still running into this issue, you may be able to resolve it using the PYTHONIOENCODING environment variable.

If this issue is still occurring, feel free to @ me and I will re-open this issue. For the time being, I'll keep this issue closed.

lgarber-akamai avatar Dec 07 '22 19:12 lgarber-akamai