From 3af0b44f7e21fccdf4837c4733c6fb1d0a9279a4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 16 Dec 2017 01:06:49 +0100 Subject: [PATCH] Upgrade weblate to 1.18, remove settings.py and upgrade to python3 because of django 2.0 --- check_process | 4 ++++ .../settings.2.18.py} | 20 +++++++++--------- conf/uwsgi.ini | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/install | 21 +++++++++++-------- scripts/restore | 4 ++-- scripts/upgrade | 6 +++--- 8 files changed, 35 insertions(+), 28 deletions(-) rename conf/{settings.py => settings_history/settings.2.18.py} (98%) diff --git a/check_process b/check_process index cdf0869..5337af0 100644 --- a/check_process +++ b/check_process @@ -20,6 +20,10 @@ setup_private=1 setup_public=1 upgrade=1 + # latest published github + upgrade=1 from_commit=5d0b16f4cd458cc5c93f8a3287aa9560738c08fb + # latest published in community.json + upgrade=1 from_commit=58c98267fa4c3ea5c1ff8fd4c63655a3230a2134 backup_restore=1 multi_instance=1 incorrect_path=1 diff --git a/conf/settings.py b/conf/settings_history/settings.2.18.py similarity index 98% rename from conf/settings.py rename to conf/settings_history/settings.2.18.py index aabf755..80f7de6 100644 --- a/conf/settings.py +++ b/conf/settings_history/settings.2.18.py @@ -165,6 +165,9 @@ SECRET_KEY = '__KEY__' # noqa TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(BASE_DIR, 'templates'), + ], 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', @@ -310,7 +313,8 @@ AUTH_PASSWORD_VALIDATORS = [ ] # Middleware -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -321,7 +325,7 @@ MIDDLEWARE_CLASSES = ( 'social_django.middleware.SocialAuthExceptionMiddleware', 'weblate.accounts.middleware.RequireLoginMiddleware', 'weblate.middleware.SecurityMiddleware', -) +] ROOT_URLCONF = 'weblate.urls' @@ -371,7 +375,10 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = \ HAVE_SYSLOG = False if platform.system() != 'Windows': try: - SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL2) + handler = SysLogHandler( + address='/dev/log', facility=SysLogHandler.LOG_LOCAL2 + ) + handler.close() HAVE_SYSLOG = True except IOError: HAVE_SYSLOG = False @@ -560,8 +567,6 @@ EMAIL_SEND_HTML = True # Subject of emails includes site title EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE) -EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend' - # Enable remote hooks ENABLE_HOOKS = True @@ -577,11 +582,6 @@ LAZY_COMMITS = True # Offload indexing 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 SIMPLIFY_LANGUAGES = True diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index fc61d73..d332168 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -1,10 +1,10 @@ [uwsgi] -plugins = python +plugins = python3 master = true protocol = uwsgi socket = /var/run/uwsgi/__APP__.socket 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 buffer-size = 8192 # Increase number of workers for heavily loaded sites diff --git a/manifest.json b/manifest.json index f8a0ea7..1b67591 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "description": { "en": "A translation platform using Git and Python" }, - "version": "2.17.1-1", + "version": "2.18-1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 9e96254..efc6dd9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ #!/bin/bash -current_version="2.17.1" +current_version="2.18" ynh_check_global_uwsgi_config () { uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" diff --git a/scripts/install b/scripts/install index 7f6ac41..50f8094 100755 --- a/scripts/install +++ b/scripts/install @@ -77,8 +77,8 @@ ynh_app_setting_set "$app" github_token "$github_token" #================================================= ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ - postgresql libpq-dev uwsgi uwsgi-plugin-python memcached + libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached #================================================= # CREATE A PostgreSQL DATABASE @@ -182,13 +182,15 @@ ynh_add_uwsgi_service #================================================= # PIP INSTALLATION #================================================= -virtualenv "${final_path}/venv" +virtualenv --python=python3 "${final_path}/venv" #run source in a 'sub shell' ( - set +eu + set +o nounset 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 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: "${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) key=$(ynh_string_random) memc_port=$(ynh_find_port 8080) -settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" -cp ../conf/settings.py "$settings" +settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" +cp "../conf/settings_history/settings.$current_version.py" "$settings" weblate_fill_settings "$settings" 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 #========================================== ( - set +eu + set +o nounset source "${final_path}/venv/bin/activate" + set -o nounset export DJANGO_SETTINGS_MODULE="weblate.settings" # the user needs to be weblate for postgresql 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 -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 diff --git a/scripts/restore b/scripts/restore index 772aea5..ca4b584 100755 --- a/scripts/restore +++ b/scripts/restore @@ -75,8 +75,8 @@ chown -R "$app": "$final_path" #================================================= ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ - postgresql libpq-dev uwsgi uwsgi-plugin-python memcached + libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached #================================================= # RESTORE THE PostgreSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 67a7d1b..bb91a2c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -157,7 +157,7 @@ then diff --unified "$old_settings" "$settings" > "$settings_diff" # generate new defaults settings - cp ../conf/settings.py "$settings" + cp "../conf/settings_history/settings.$current_version.py" "$settings" weblate_fill_settings "$settings" # send diff to the server administrator @@ -196,7 +196,7 @@ then else echo "Settings.py was not modified, using the new default file for $current_version." # generate new defaults settings - cp ../conf/settings.py "$settings" + cp "../conf/settings_history/settings.$current_version.py" "$settings" weblate_fill_settings "$settings" fi @@ -216,7 +216,7 @@ fi ) # 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