From 309e2619a123bd04e03fbbb0db794babeeac29a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sat, 24 Feb 2018 23:38:31 +0100 Subject: [PATCH] Fix UnicodeDecodeError with python scripts --- conf/add_sso_conf.py | 4 ++-- conf/remove_sso_conf.py | 4 ++-- scripts/experimental_helper.sh | 2 +- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf/add_sso_conf.py b/conf/add_sso_conf.py index 49a23e7..4595548 100644 --- a/conf/add_sso_conf.py +++ b/conf/add_sso_conf.py @@ -1,11 +1,11 @@ import json -with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: +with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile: data = json.load(jsonFile) if "skipped_urls" in data: data["skipped_urls"].append("/_matrix") else: data["skipped_urls"] = ["/_matrix"] -with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: +with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile: jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/conf/remove_sso_conf.py b/conf/remove_sso_conf.py index effdcca..46c5a86 100644 --- a/conf/remove_sso_conf.py +++ b/conf/remove_sso_conf.py @@ -1,8 +1,8 @@ import json -with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: +with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile: data = json.load(jsonFile) data["skipped_urls"].remove("/_matrix") -with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: +with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile: jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index c53defa..3c09ff3 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -6,7 +6,7 @@ ynh_read_manifest () { manifest="$1" key="$2" - python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])" + python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])" } # Read the upstream version from the manifest diff --git a/scripts/install b/scripts/install index e55de83..aa5d57a 100644 --- a/scripts/install +++ b/scripts/install @@ -269,7 +269,7 @@ ynh_use_logrotate /var/log/matrix-$app # The script "add_sso_conf.py" will just add en entry for the path "/_matrix" in the sso conf.json.persistent file in the cathegory "skipped_urls". cp ../conf/add_sso_conf.py $final_path cp ../conf/remove_sso_conf.py $final_path -python $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/synapse_ynh/issues/32" +python3 $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/synapse_ynh/issues/32" #================================================= # SECURE FILES AND DIRECTORIES diff --git a/scripts/remove b/scripts/remove index 9261541..e3cbf9a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -64,7 +64,7 @@ closeport $turnserver_alt_tls_port #================================================= # Remove the skipped url -python $final_path/remove_sso_conf.py +python3 $final_path/remove_sso_conf.py #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 1c79f96..353da65 100644 --- a/scripts/restore +++ b/scripts/restore @@ -88,7 +88,7 @@ yunohost firewall allow Both $turnserver_alt_tls_port > /dev/null 2>&1 # Open access to server without a button the home # The script "add_sso_conf.py" will just add en entry for the path "/_matrix" in the sso conf.json.persistent file in the cathegory "skipped_urls". -python $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/synapse_ynh/issues/32" +python3 $final_path/add_sso_conf.py || ynh_die "Your file /etc/ssowat/conf.json.persistent don't respect the json synaxe. Please fix the synaxe to install this app. For more information see here : https://github.com/YunoHost-Apps/synapse_ynh/issues/32" #================================================= # RESTORE THE POSTGRESQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 9d552ce..abf33c7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -240,7 +240,7 @@ then cp ../conf/add_sso_conf.py $final_path cp ../conf/remove_sso_conf.py $final_path - python $final_path/add_sso_conf.py || echo "Error while sso config, please add '/_matrix' in /etc/ssowat/conf.json.persistent" + python3 $final_path/add_sso_conf.py || echo "Error while sso config, please add '/_matrix' in /etc/ssowat/conf.json.persistent" #================================================= # CREATE DEDICATED USER