Pectojin / duplicati-client

A command line client for controlling the Duplicati Server
GNU Lesser General Public License v2.1
75 stars 20 forks source link

UTF-8 Error in Docker Container based on Alpine Linux #21

Closed Programmierfreund closed 3 years ago

Programmierfreund commented 3 years ago

I want to add duplicati-client as new layer on top of the official "nodered/node-red" image in docker hub. I know that there is no locale support of the underlying Alpine Linux. So I added musl-locales-master to my Dockerfile - hoping that this helps also for UTF-8. Unfortunately duplicati-client is still not working in this environment (see below). Does anyone has experience in running duplicati-client on Alpine?

Best regards

PS: On Ubuntu duplicati-client is working fine


$ duc login http://duplicati:8200 --password=my password
Traceback (most recent call last):
File "/usr/bin/duc", line 1372, in
main(vars(args))
File "/usr/bin/duc", line 97, in main
data = auth.login(data, url, password, verify, interactive,
File "/usr/local/lib/duplicati-client/auth.py", line 126, in login
salt = r.json()["Salt"]
File "/usr/lib/python3.8/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text,
kwargs)
File "/usr/lib/python3.8/json/init.py", line 337, in loads
raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

Programmierfreund commented 3 years ago

I found a valid solution based on this article: https://www.howtosolutions.net/2019/04/python-fixing-unexpected-utf-8-bom-error-when-loading-json-data/ - easiest way ist described in step 4.

Before each r.json call I have to add r.encoding='utf-8-sig' in die program code. Maybe Pectojin can add this in the master code? Otherwise I can add a pull request.

TheAmitMa commented 3 years ago

I have the same problem. Even on ubuntu container. @Programmierfreund, Could you please share the fixed version?

Programmierfreund commented 3 years ago

I have the same problem. Even on ubuntu container. @Programmierfreund, Could you please share the fixed version?

I have now added two pull requests (unfortnately instead of one). You can see like I have adjusted duplicaty_client.py and auth.py.