Fix UnicodeDecodeError with python scripts

This commit is contained in:
Josué Tille 2018-03-09 20:37:26 +01:00
parent 36d5426211
commit dc93a61bf9
10 changed files with 17 additions and 17 deletions

View file

@ -16,7 +16,7 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=cf99200a947e1b557d2d714ccb871a92922cd00d upgrade=1 from_commit=f9b9e934f6929bd564386f06c0352f0ef41b7619
upgrade=1 from_commit=0fdafb9aa7ea85ccabb066a9596da91ab9229905 upgrade=1 from_commit=0fdafb9aa7ea85ccabb066a9596da91ab9229905
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
@ -42,7 +42,7 @@
Level 10=0 Level 10=0
;;; Upgrade options ;;; Upgrade options
; commit=cf99200a947e1b557d2d714ccb871a92922cd00d ; commit=f9b9e934f6929bd564386f06c0352f0ef41b7619
name=The oldest installable version - branch Old_version_for_CI name=The oldest installable version - branch Old_version_for_CI
; commit=0fdafb9aa7ea85ccabb066a9596da91ab9229905 ; commit=0fdafb9aa7ea85ccabb066a9596da91ab9229905
name=Before move main dir to opt name=Before move main dir to opt

View file

@ -1,6 +1,6 @@
import json 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 = json.load(jsonFile)
if "skipped_urls" in data: if "skipped_urls" in data:
data["skipped_urls"].append("/seafhttp") data["skipped_urls"].append("/seafhttp")
@ -8,5 +8,5 @@ with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile:
data["skipped_urls"] = ["/seafhttp"] data["skipped_urls"] = ["/seafhttp"]
data["skipped_urls"].append("/seafdav") data["skipped_urls"].append("/seafdav")
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)) jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,8 +1,8 @@
import json 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 = json.load(jsonFile)
data["skipped_urls"].append("/seafdav") data["skipped_urls"].append("/seafdav")
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)) jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,9 +1,9 @@
import json 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 = json.load(jsonFile)
data["skipped_urls"].remove("/seafhttp") data["skipped_urls"].remove("/seafhttp")
data["skipped_urls"].remove("/seafdav") data["skipped_urls"].remove("/seafdav")
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)) jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -1,6 +1,6 @@
import json 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 = json.load(jsonFile)
data["unprotected_urls"].remove("/seafhttp") data["unprotected_urls"].remove("/seafhttp")
data["unprotected_urls"].remove("/seafdav") data["unprotected_urls"].remove("/seafdav")
@ -10,5 +10,5 @@ with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile:
data["skipped_urls"] = ["/seafhttp"] data["skipped_urls"] = ["/seafhttp"]
data["skipped_urls"].append("/seafdav") data["skipped_urls"].append("/seafdav")
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)) jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -20,7 +20,7 @@ fi
ynh_read_manifest () { ynh_read_manifest () {
manifest="$1" manifest="$1"
key="$2" 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 # Read the upstream version from the manifest

View file

@ -158,7 +158,7 @@ ynh_secure_remove "$final_path/first_launch.exp"
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent # Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent
cp ../conf/add_sso_conf.py $final_path cp ../conf/add_sso_conf.py $final_path
cp ../conf/remove_sso_conf.py $final_path cp ../conf/remove_sso_conf.py $final_path
python $final_path/add_sso_conf.py python3 $final_path/add_sso_conf.py
# unprotect media # unprotect media
ynh_app_setting_set seafile unprotected_uris "/media" ynh_app_setting_set seafile unprotected_uris "/media"

View file

@ -27,8 +27,8 @@ domain=$(ynh_app_setting_get $app domain)
systemctl stop seafile-server.service systemctl stop seafile-server.service
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent # remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
test -e /var/www/$app/remove_sso_conf.py && python /var/www/$app/remove_sso_conf.py test -e /var/www/$app/remove_sso_conf.py && python3 /var/www/$app/remove_sso_conf.py
test -e /opt/yunohost/$app/remove_sso_conf.py && python /opt/yunohost/$app/remove_sso_conf.py test -e /opt/yunohost/$app/remove_sso_conf.py && python3 /opt/yunohost/$app/remove_sso_conf.py
ynh_secure_remove /var/log/seafile ynh_secure_remove /var/log/seafile
ynh_secure_remove /var/www/$app ynh_secure_remove /var/www/$app
ynh_secure_remove /opt/yunohost/$app ynh_secure_remove /opt/yunohost/$app

View file

@ -53,7 +53,7 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
#================================================= #=================================================
# Restore sso persistent config # Restore sso persistent config
python $final_path/add_sso_conf.py python3 $final_path/add_sso_conf.py
# Add logrotate # Add logrotate
ynh_use_logrotate $final_path/logs ynh_use_logrotate $final_path/logs

View file

@ -76,7 +76,7 @@ case $installed_version in
../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
;& ;&
"6.0."* ) "6.0."* )
python ../conf/update_sso_conf.py || true python3 ../conf/update_sso_conf.py || true
install_dependance install_dependance
# Update seafile by script # Update seafile by script
@ -120,7 +120,7 @@ then
cp ../conf/add_sso_conf.py $final_path cp ../conf/add_sso_conf.py $final_path
cp ../conf/add_sso_conf_webdav.py $final_path cp ../conf/add_sso_conf_webdav.py $final_path
cp ../conf/remove_sso_conf.py $final_path cp ../conf/remove_sso_conf.py $final_path
python $final_path/add_sso_conf_webdav.py python3 $final_path/add_sso_conf_webdav.py
# Update seafile config # Update seafile config
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py