flyingcircusio / batou

batou is a universal, fractal deployment utility using Python.
https://batou.readthedocs.org
Other
47 stars 11 forks source link

appenv ascii decoding breaks output #350

Closed zagy closed 1 year ago

zagy commented 1 year ago

When cmd puts out non ascii chars the output is not rendered but an error

…/./.appenv/updatelock/bin/python -m pip install -r requirements.txt returned with exit code 1
Traceback (most recent call last):
  File "…./appenv", line 38, in cmd
    return subprocess.check_output([c], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['…/./.appenv/updatelock/bin/python -m pip install -r requirements.txt']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "…./appenv", line 562, in <module>
    main()
  File "…./appenv", line 554, in main
    appenv.meta()
  File "…./appenv", line 302, in meta
    args.func(args, remaining)
  File "…./appenv", line 468, in update_lockfile
    cmd(
  File "…./appenv", line 41, in cmd
    print(e.output.decode("ascii"))
          ^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1679: ordinal not in range(128)

https://github.com/flyingcircusio/batou/blob/6526a55d2a581857754f8e76faf22737100d12ea/appenv.py#L40-L42