1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

VADE RETRO PYTHON3! Welcome Weblate 2.20!

This commit is contained in:
Jean-Baptiste Holcroft 2018-04-08 10:27:26 +02:00
parent 20281a7830
commit 0c26641287
7 changed files with 32 additions and 48 deletions

View file

@ -11,7 +11,6 @@
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
github_account="myaccount" github_account="myaccount"
github_token="myoauthtoken" github_token="myoauthtoken"
password="pass"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -593,6 +593,8 @@ EMAIL_SEND_HTML = True
# Subject of emails includes site title # Subject of emails includes site title
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE) EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
# Enable remote hooks # Enable remote hooks
ENABLE_HOOKS = True ENABLE_HOOKS = True

View file

@ -1,12 +1,12 @@
[uwsgi] [uwsgi]
plugins = python3 plugins = python
master = true master = true
protocol = uwsgi protocol = uwsgi
socket = /var/run/uwsgi/__APP__.socket socket = /var/run/uwsgi/__APP__.socket
virtualenv = __FINALPATH__/venv virtualenv = __FINALPATH__/venv
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info # http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
mount = __PATH__=__FINALPATH__/venv/lib/python3.4/site-packages/weblate/wsgi.py mount = __PATH__=__FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py
manage-script-name = true manage-script-name = true
# Needed for OAuth/OpenID # Needed for OAuth/OpenID

View file

@ -82,6 +82,8 @@ ynh_remove_uwsgi_service () {
yunohost service remove "uwsgi-app@$app.socket" yunohost service remove "uwsgi-app@$app.socket"
ynh_secure_remove "$finaluwsgiini" ynh_secure_remove "$finaluwsgiini"
ynh_secure_remove "/var/run/uwsgi/$app.socket"
ynh_secure_remove "/var/log/uwsgi/app/$app"
fi fi
} }

View file

@ -77,8 +77,8 @@ ynh_app_setting_set "$app" github_token "$github_token"
#================================================= #=================================================
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \
postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached postgresql libpq-dev uwsgi uwsgi-plugin-python memcached
#================================================= #=================================================
# CREATE A PostgreSQL DATABASE # CREATE A PostgreSQL DATABASE
@ -177,7 +177,7 @@ ynh_add_uwsgi_service
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
#================================================= #=================================================
virtualenv --python=python3 "${final_path}/venv" virtualenv "${final_path}/venv"
#run source in a 'sub shell' #run source in a 'sub shell'
( (
set +o nounset set +o nounset
@ -187,7 +187,7 @@ virtualenv --python=python3 "${final_path}/venv"
# prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers"
pip install --upgrade setuptools pip install --upgrade setuptools
pip install Weblate=="$current_version" pip install Weblate=="$current_version"
pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached phply pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached phply
# specific to YunoHost package: # specific to YunoHost package:
pip install django_sendmail_backend pip install django_sendmail_backend
) )
@ -201,7 +201,7 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
admin_mail=$(ynh_user_get_info "$admin" mail) admin_mail=$(ynh_user_get_info "$admin" mail)
key=$(ynh_string_random) key=$(ynh_string_random)
memc_port=$(ynh_find_port 8080) memc_port=$(ynh_find_port 8080)
settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
cp "../conf/settings_history/settings.$current_version.py" "$settings" cp "../conf/settings_history/settings.$current_version.py" "$settings"
weblate_fill_settings "$settings" weblate_fill_settings "$settings"
@ -238,7 +238,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
#================================================= #=================================================
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -247,7 +247,10 @@ ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/se
#================================================= #=================================================
# Set permissions to app files # Set permissions to app files
chown -R "$app": "$final_path" chown -R "$app": "$final_path/data"
mkdir -p "$final_path/avatar-cache"
chown -R "$app": "$final_path/avatar-cache"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -75,8 +75,8 @@ chown -R "$app": "$final_path"
#================================================= #=================================================
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \
postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached postgresql libpq-dev uwsgi uwsgi-plugin-python memcached
#================================================= #=================================================
# RESTORE THE PostgreSQL DATABASE # RESTORE THE PostgreSQL DATABASE

View file

@ -62,15 +62,7 @@ if [ -z "$db_name" ]; then # If db_name doesn't exist, create it
ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set "$app" db_name "$db_name"
fi fi
# (<2.18) handle python3 migration (because of django 2.0)
if [[ -e "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" ]]
then
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
migrate_py2to3=true
else
settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py"
migrate_py2to3=false
fi
# (<2.17) save memc_port if it doesn't exist # (<2.17) save memc_port if it doesn't exist
if [[ -z "$memc_port" ]] if [[ -z "$memc_port" ]]
@ -143,8 +135,8 @@ chsh --shell /bin/bash "$app"
#================================================= #=================================================
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \
postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached postgresql libpq-dev uwsgi uwsgi-plugin-python memcached
#================================================= #=================================================
# SPECIFIC SETUP uwsgi # SPECIFIC SETUP uwsgi
@ -159,22 +151,6 @@ ynh_add_uwsgi_service
# save old settings file # save old settings file
cp "$settings" "$final_path/settings.$previous_version.old.py" cp "$settings" "$final_path/settings.$previous_version.old.py"
# (<2.18) handle python3 migration
if [[ "$migrate_py2to3" = true ]]
then
ynh_secure_remove "$final_path/venv"
virtualenv --python=python3 "${final_path}/venv"
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
pip install --upgrade pip
pip install Weblate=="$current_version"
settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py"
cp "$final_path/settings.$previous_version.old.py" "$settings"
ynh_store_file_checksum "$settings"
fi
old_settings="./settings.$previous_version.old.py" old_settings="./settings.$previous_version.old.py"
settings_diff="$final_path/settings.${previous_version}_${current_version}.diff" settings_diff="$final_path/settings.${previous_version}_${current_version}.diff"
@ -186,9 +162,7 @@ settings_diff="$final_path/settings.${previous_version}_${current_version}.diff"
# prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers"
pip install --upgrade setuptools pip install --upgrade setuptools
pip install Weblate=="$current_version" pip install Weblate=="$current_version"
# prevent error "ImportError: No module named 'social'" pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached phply
pip install -r "$final_path/venv/lib/python3.4/site-packages/weblate/requirements.txt"
pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached phply
# specific to YunoHost package: # specific to YunoHost package:
pip install django_sendmail_backend pip install django_sendmail_backend
) )
@ -261,19 +235,23 @@ fi
weblate loadpo --all --lang lt weblate loadpo --all --lang lt
weblate loadpo --all --lang lv weblate loadpo --all --lang lv
fi fi
if [[ "$migrate_py2to3" = true ]]
then
weblate rebuild_index --clean --all
fi
) )
# Recalculate and store the config file checksum into the app settings # Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions for curl installation
chown -R root:root "$final_path"
chown -R "$app": "$final_path/data"
mkdir -p "$final_path/avatar-cache"
chown -R "$app": "$final_path/avatar-cache"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT