lavie / runlike

Given an existing docker container, prints the command line necessary to run a copy of it.
Other
1.99k stars 118 forks source link

UnicodeDecodeError #90

Closed ap88 closed 1 year ago

ap88 commented 2 years ago

I have a container running from the ownyourbits/nextcloudpi-armhf image. Trying to export with the command runlike nextcloud crashes with the following output:

Traceback (most recent call last):
  File "/usr/local/bin/runlike", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/runlike/runlike.py", line 28, in main
    cli()
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/runlike/runlike.py", line 23, in cli
    ins.inspect()
  File "/usr/local/lib/python2.7/dist-packages/runlike/inspector.py", line 32, in inspect
    self.facts = loads(output.decode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9939: ordinal not in range(128)
Walle123 commented 2 years ago

The error comes from the maintainers name. I fixed it myself by changing output.decode() to output.decode('utf8','strict') in line 32 of inspector.py and additionally you have to change ins.format.cli() to ins.format.cli().encode(encoding='utf8') in line 24 of runlike.py

The filepath can be read in the error message

lavie commented 2 years ago

@Walle123 thank you. Would you like to submit a patch?

Walle123 commented 2 years ago

@lavie I am pretty new to github and do not know how to do that

lavie commented 2 years ago

I'd be happy to help.

e.g. if you know you have to change inspector.py you can click the edit button and get an editor: https://github.com/lavie/runlike/edit/master/runlike/inspector.py

Then you commit the changes and submit a PR (pull request).

Walle123 commented 2 years ago

I think i did it right. Thank you for your help

lavie commented 2 years ago

Appreciated.

The builds did fail, but it's not your fault. There's a known issue with dockerhub.

I'll fix it soon. Not today though, unfortunately. Very short on time.