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

Upgrade weblate to 1.18, remove settings.py and upgrade to python3 because of django 2.0

This commit is contained in:
Jean-Baptiste Holcroft 2017-12-16 01:06:49 +01:00
parent 5d0b16f4cd
commit 3af0b44f7e
8 changed files with 35 additions and 28 deletions

View file

@ -20,6 +20,10 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# latest published github
upgrade=1 from_commit=5d0b16f4cd458cc5c93f8a3287aa9560738c08fb
# latest published in community.json
upgrade=1 from_commit=58c98267fa4c3ea5c1ff8fd4c63655a3230a2134
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
incorrect_path=1 incorrect_path=1

View file

@ -165,6 +165,9 @@ SECRET_KEY = '__KEY__' # noqa
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
],
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
@ -310,7 +313,8 @@ AUTH_PASSWORD_VALIDATORS = [
] ]
# Middleware # Middleware
MIDDLEWARE_CLASSES = ( MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware', 'django.middleware.locale.LocaleMiddleware',
@ -321,7 +325,7 @@ MIDDLEWARE_CLASSES = (
'social_django.middleware.SocialAuthExceptionMiddleware', 'social_django.middleware.SocialAuthExceptionMiddleware',
'weblate.accounts.middleware.RequireLoginMiddleware', 'weblate.accounts.middleware.RequireLoginMiddleware',
'weblate.middleware.SecurityMiddleware', 'weblate.middleware.SecurityMiddleware',
) ]
ROOT_URLCONF = 'weblate.urls' ROOT_URLCONF = 'weblate.urls'
@ -371,7 +375,10 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = \
HAVE_SYSLOG = False HAVE_SYSLOG = False
if platform.system() != 'Windows': if platform.system() != 'Windows':
try: try:
SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL2) handler = SysLogHandler(
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
)
handler.close()
HAVE_SYSLOG = True HAVE_SYSLOG = True
except IOError: except IOError:
HAVE_SYSLOG = False HAVE_SYSLOG = False
@ -560,8 +567,6 @@ 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
@ -577,11 +582,6 @@ LAZY_COMMITS = True
# Offload indexing # Offload indexing
OFFLOAD_INDEXING = True OFFLOAD_INDEXING = True
# Translation locking
AUTO_LOCK = True
AUTO_LOCK_TIME = 60
LOCK_TIME = 15 * 60
# Use simple language codes for default language/country combinations # Use simple language codes for default language/country combinations
SIMPLIFY_LANGUAGES = True SIMPLIFY_LANGUAGES = True

View file

@ -1,10 +1,10 @@
[uwsgi] [uwsgi]
plugins = python plugins = python3
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
wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py wsgi-file = __FINALPATH__/venv/lib/python3.4/site-packages/weblate/wsgi.py
# Needed for OAuth/OpenID # Needed for OAuth/OpenID
buffer-size = 8192 buffer-size = 8192
# Increase number of workers for heavily loaded sites # Increase number of workers for heavily loaded sites

View file

@ -8,7 +8,7 @@
"description": { "description": {
"en": "A translation platform using Git and Python" "en": "A translation platform using Git and Python"
}, },
"version": "2.17.1-1", "version": "2.18-1",
"url": "https://weblate.org", "url": "https://weblate.org",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
current_version="2.17.1" current_version="2.18"
ynh_check_global_uwsgi_config () { ynh_check_global_uwsgi_config () {
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"

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 python-dev python-pip python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \
postgresql libpq-dev uwsgi uwsgi-plugin-python memcached postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached
#================================================= #=================================================
# CREATE A PostgreSQL DATABASE # CREATE A PostgreSQL DATABASE
@ -182,13 +182,15 @@ ynh_add_uwsgi_service
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
#================================================= #=================================================
virtualenv "${final_path}/venv" virtualenv --python=python3 "${final_path}/venv"
#run source in a 'sub shell' #run source in a 'sub shell'
( (
set +eu set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset
"${final_path}/venv/bin/pip" install --upgrade pip
"${final_path}/venv/bin/pip" install Weblate=="$current_version" "${final_path}/venv/bin/pip" install Weblate=="$current_version"
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached "${final_path}/venv/bin/pip" install python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached
# specific to YunoHost package: # specific to YunoHost package:
"${final_path}/venv/bin/pip" install django_sendmail_backend "${final_path}/venv/bin/pip" install django_sendmail_backend
) )
@ -202,8 +204,8 @@ 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/python2.7/site-packages/weblate/settings.py" settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py"
cp ../conf/settings.py "$settings" cp "../conf/settings_history/settings.$current_version.py" "$settings"
weblate_fill_settings "$settings" weblate_fill_settings "$settings"
ynh_app_setting_set "$app" memc_port "$memc_port" ynh_app_setting_set "$app" memc_port "$memc_port"
@ -213,8 +215,9 @@ ynh_app_setting_set "$app" memc_port "$memc_port"
# https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database
#========================================== #==========================================
( (
set +eu set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
# the user needs to be weblate for postgresql # the user needs to be weblate for postgresql
weblate migrate --noinput weblate migrate --noinput
@ -238,7 +241,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/python2.7/site-packages/weblate/settings.py" ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

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 python-dev python-pip python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
postgresql libpq-dev uwsgi uwsgi-plugin-python memcached postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached
#================================================= #=================================================
# RESTORE THE PostgreSQL DATABASE # RESTORE THE PostgreSQL DATABASE

View file

@ -157,7 +157,7 @@ then
diff --unified "$old_settings" "$settings" > "$settings_diff" diff --unified "$old_settings" "$settings" > "$settings_diff"
# generate new defaults settings # generate new defaults settings
cp ../conf/settings.py "$settings" cp "../conf/settings_history/settings.$current_version.py" "$settings"
weblate_fill_settings "$settings" weblate_fill_settings "$settings"
# send diff to the server administrator # send diff to the server administrator
@ -196,7 +196,7 @@ then
else else
echo "Settings.py was not modified, using the new default file for $current_version." echo "Settings.py was not modified, using the new default file for $current_version."
# generate new defaults settings # generate new defaults settings
cp ../conf/settings.py "$settings" cp "../conf/settings_history/settings.$current_version.py" "$settings"
weblate_fill_settings "$settings" weblate_fill_settings "$settings"
fi fi
@ -216,7 +216,7 @@ 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/python2.7/site-packages/weblate/settings.py" ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION