1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00

Migrate interpreter to Python3

This commit is contained in:
Josué Tille 2018-11-07 19:30:34 +01:00
parent 321773d6ae
commit 050c2fe8e9
6 changed files with 22 additions and 16 deletions

View file

@ -2,6 +2,9 @@ location __PATH__ {
include uwsgi_params;
uwsgi_pass unix:///run/uwsgi/app/pgadmin/socket;
uwsgi_read_timeout 180;
uwsgi_send_timeout 180;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -12,7 +12,7 @@ chmod-socket = 666
# Plugin to use and interpretor config
single-interpreter = true
master = true
plugin = python
plugin = python3
# Manage the subpath
manage-script-name = true
@ -21,7 +21,7 @@ mount = __PATH__=pgAdmin4.py
# Virtualenv and python path
virtualenv = __FINALPATH__
pythonpath = __FINALPATH__
chdir = __FINALPATH__/lib/python2.7/site-packages/pgadmin4
chdir = __FINALPATH__/lib/python__PYTHON_VERSION__/site-packages/pgadmin4
# The variable holding flask application
callable = app

View file

@ -10,7 +10,7 @@
"url": "https://www.pgadmin.org",
"license": "PostgreSQL",
"maintainer": {
"name": "Josué",
"name": "Josué Tille",
"email": "josue@tille.ch"
},
"requirements": {

View file

@ -5,6 +5,7 @@
app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app
pgadmin_user="pgadmin"
python_version="3.5"
[[ -e "../settings/manifest.json" ]] || [[ -e "../manifest.json" ]] && \
APP_VERSION=$(ynh_app_upstream_version)
@ -16,7 +17,7 @@ app_sub_version=$(echo $APP_VERSION | cut -d'-' -f2)
#=================================================
install_dependance() {
ynh_install_app_dependencies python-pip build-essential python-dev python-virtualenv postgresql uwsgi uwsgi-plugin-python expect
ynh_install_app_dependencies python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect
}
psql_create_admin() {
@ -42,14 +43,14 @@ install_source() {
fi
else
# Install virtualenv if it don't exist
test -e $final_path/bin || virtualenv -p python2.7 $final_path
test -e $final_path/bin/python3 || python3 -m venv $final_path
# Install pgadmin in virtualenv
PS1=""
cp ../conf/virtualenv_activate $final_path/bin/activate
source $final_path/bin/activate
pip install --upgrade pip
pip install --upgrade https://ftp.postgresql.org/pub/pgadmin/pgadmin$app_main_version/v$app_sub_version/pip/pgadmin${APP_VERSION}-py2.py3-none-any.whl
pip3 install --upgrade pip
pip3 install --upgrade https://ftp.postgresql.org/pub/pgadmin/pgadmin$app_main_version/v$app_sub_version/pip/pgadmin${APP_VERSION}-py2.py3-none-any.whl
deactivate
fi
}
@ -63,9 +64,9 @@ set_permission() {
}
config_pgadmin() {
cp ../conf/config_local.py $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
ynh_replace_string __USER__ $pgadmin_user $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
ynh_replace_string __DOMAIN__ $domain $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
cp ../conf/config_local.py $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
ynh_replace_string __USER__ $pgadmin_user $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
ynh_replace_string __DOMAIN__ $domain $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py
}
config_uwsgi() {
@ -73,5 +74,6 @@ config_uwsgi() {
ynh_replace_string __USER__ $pgadmin_user /etc/uwsgi/apps-enabled/pgadmin.ini
ynh_replace_string __FINALPATH__ $final_path /etc/uwsgi/apps-enabled/pgadmin.ini
ynh_replace_string __PATH__ $path_url /etc/uwsgi/apps-enabled/pgadmin.ini
ynh_replace_string __PYTHON_VERSION__ $python_version /etc/uwsgi/apps-enabled/pgadmin.ini
}

View file

@ -5,7 +5,7 @@ import sqlite3
import sys
# Import crypto from pgadmin project
crypto = imp.load_source('crypt', '/opt/yunohost/pgadmin/lib/python2.7/site-packages/pgadmin4/pgadmin/utils/crypto.py')
crypto = imp.load_source('crypt', '/opt/yunohost/pgadmin/lib/python__PYTHON_VERSION__/site-packages/pgadmin4/pgadmin/utils/crypto.py')
# Get arguments
username = sys.argv[1]

View file

@ -82,14 +82,15 @@ chmod +x ../conf/setup.exp
PS1=""
source $final_path/bin/activate
ynh_replace_special_string "__ADMIN_PASSWORD__" "$admin_pwd" "../conf/setup.exp"
../conf/setup.exp "$final_path/bin/python2.7" "$final_path/lib/python2.7/site-packages/pgadmin4/setup.py" "$email"
../conf/setup.exp "$final_path/bin/python3" "$final_path/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email"
# POPULATE THE DATABASE
ynh_psql_test_if_first_run
su --command="psql -c\"CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION\"" postgres
# Add Server In PGadmin database
$final_path/bin/python2.7 config_database.py "$db_user" "$db_pwd"
ynh_replace_string "__PYTHON_VERSION__" "$python_version" config_database.py
$final_path/bin/python3 config_database.py "$db_user" "$db_pwd"
deactivate
#=================================================