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

Update duplicati_client.py #22

Closed Programmierfreund closed 3 years ago

Programmierfreund commented 3 years ago

Like described in issue #21 (https://github.com/Pectojin/duplicati-client/issues/21) there is an UTF-8-issue when you are calling r.json inside a docker cointainer.

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.

TheAmitMa commented asked to share my solution - here it is.

Pectojin commented 3 years ago

I think it should be possible to set the encoding in the requests wrapper instead. Fewer code changes and ensures that it's always used. https://github.com/Pectojin/duplicati-client/blob/master/requests_wrapper.py

I'll take a crack at it when I find some time.

Programmierfreund commented 3 years ago

Sounds good - thanks for your reply.

Pectojin commented 3 years ago

I've tried setting it on the result object in each method in the requests_wrapper. This should be functionally equivalent to your changes but only 5 times (one for each request method supported).

https://github.com/Pectojin/duplicati-client/commit/c1029e1f7b82312fd28c0cc4e179ddf411e86d8c

However, as I was trying to verify that this works I discovered that I can't actually replicate the issue in docker on my machine. So I don't know if it works.

I started a library/alpine:latest container, installed python3 + py3-pip, installed dependencies, ran the login command and it just works as expected.