[elbe-devel] [PATCH] soapclient: fix cdrom upload

Bastian Germann bage at linutronix.de
Thu Jul 16 09:52:41 CEST 2020


Am 16.07.20 um 08:54 schrieb Torben Hohn:
> The cdrom file is opened in text mode. That results in utf-8 errors.
> 
> ------------------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/old/linutronix/elbe/elbe", line 62, in <module>
> cmdmod.run_command(sys.argv[2:])
> File "/home/old/linutronix/elbe/elbepack/commands/control.py", line 189, in run_command
> action.execute(control, opt, args[1:])
> File "/home/old/linutronix/elbe/elbepack/soapclient.py", line 651, in execute
> bindata = fp.read(size)
> File "/usr/lib/python3.8/codecs.py", line 322, in decode
> (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 32849: invalid continuation byte
> elbe control set_cdrom Failed
> Giving up
> ------------------------------------------------------------------------------
> 
> Open file in binary mode. In Python2 this does not change anything. But
> in python3 this will result in read() returning bytes. And it will not
> try to treat the file data as utf-8.
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>  elbepack/soapclient.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> index f7bddf266..a465b615b 100644
> --- a/elbepack/soapclient.py
> +++ b/elbepack/soapclient.py
> @@ -645,7 +645,7 @@ class SetCdromAction(ClientAction):
>          builddir = args[0]
>          filename = args[1]
>  
> -        fp = open(filename, "r")
> +        fp = open(filename, "rb")
>          client.service.start_cdrom(builddir)
>          while True:
>              bindata = fp.read(size)
> 


More information about the elbe-devel mailing list