Skip to content
Snippets Groups Projects
Commit e3fd3300355f authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:pencil: make script work with python3 only

parent 0ae853f01f07
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
here=$(dirname $0) here=$(dirname $0)
project_home=$(cd $here && cd .. && echo $PWD) project_home=$(cd $here && cd .. && echo $PWD)
dbname=$(basename $project_home)_test dbname=$(basename $project_home)_test
if ! type python3 > /dev/null; then
python="python2"
else
python="python3"
fi
# this is the same value as conf/dev/odoo.conf # this is the same value as conf/dev/odoo.conf
if [[ -e "${project_home}/conf/dev/odoo.conf" ]]; if [[ -e "${project_home}/conf/dev/odoo.conf" ]];
then then
...@@ -21,6 +26,7 @@ ...@@ -21,6 +26,7 @@
# this is the same value as conf/dev/odoo.conf # this is the same value as conf/dev/odoo.conf
if [[ -e "${project_home}/conf/dev/odoo.conf" ]]; if [[ -e "${project_home}/conf/dev/odoo.conf" ]];
then then
dbowner=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/conf/dev/odoo.conf') ; print c.get('options', 'db_user')") dbowner=$($python -B -c "from six.moves import configparser ; c = configParser.ConfigParser() ; c.read('${project_home}/conf/dev/odoo.conf') ; print(c.get('options', 'db_user'))")
unaccent=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/conf/dev/odoo.conf') ; print(c.get('options', 'unaccent') if c.has_option('options', 'unaccent') else False)")
else else
dbowner=odoo dbowner=odoo
...@@ -25,3 +31,4 @@ ...@@ -25,3 +31,4 @@
else else
dbowner=odoo dbowner=odoo
unaccent=False
fi fi
...@@ -27,6 +34,6 @@ ...@@ -27,6 +34,6 @@
fi fi
modules_to_install=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print ','.join(c.get('odoo_scripts', 'module_list', '').split())") modules_to_install=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list').split()))")
fail_on_errors=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print c.get('odoo_scripts', 'fail_on_errors', 'True') if c.has_option('odoo_scripts', 'fail_on_errors') else True") fail_on_errors=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.get('odoo_scripts', 'fail_on_errors') if c.has_option('odoo_scripts', 'fail_on_errors') else True)")
# color stuff # color stuff
autoload colors autoload colors
...@@ -76,7 +83,6 @@ ...@@ -76,7 +83,6 @@
dropdb $PG_HOST $PG_USER --if-exists $dbname --no-password dropdb $PG_HOST $PG_USER --if-exists $dbname --no-password
echo "[${YELLOW}INFO${RESET}] Create database '$dbname' with owner $dbowner" echo "[${YELLOW}INFO${RESET}] Create database '$dbname' with owner $dbowner"
createdb $PG_HOST $PG_USER -O $dbowner $dbname --no-password || { echo ${RED}FATAL${RESET} - Cannot create test database ; exit 1; } createdb $PG_HOST $PG_USER -O $dbowner $dbname --no-password || { echo ${RED}FATAL${RESET} - Cannot create test database ; exit 1; }
unaccent=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/conf/dev/odoo.conf') ; print c.get('options', 'unaccent', False)")
if [[ "$unaccent" == "True" ]]; if [[ "$unaccent" == "True" ]];
then then
psql $PG_HOST $PG_USER $dbname -c "CREATE EXTENSION unaccent;" psql $PG_HOST $PG_USER $dbname -c "CREATE EXTENSION unaccent;"
......
...@@ -8,7 +8,12 @@ ...@@ -8,7 +8,12 @@
# Version 2.19 # Version 2.19
here=$(dirname $0) here=$(dirname $0)
project_home=$(cd $here && cd .. && echo $PWD) project_home=$(cd $here && cd .. && echo $PWD)
tested_modules=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print ','.join(c.get('odoo_scripts', 'module_list_tests', '').split())") if ! type python3 > /dev/null; then
python="python2"
else
python="python3"
fi
tested_modules=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(c.get('odoo_scripts', 'module_list_tests').split() if c.has_option('odoo_scripts', 'module_list_tests') else []))")
if [[ "$tested_modules" != "" ]]; if [[ "$tested_modules" != "" ]];
then then
update="-u $tested_modules" update="-u $tested_modules"
...@@ -28,7 +33,7 @@ ...@@ -28,7 +33,7 @@
db_user_param="--db_user $ODOO_SCRIPTS_DB_USER" db_user_param="--db_user $ODOO_SCRIPTS_DB_USER"
fi fi
ODOO_TYPE=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print c.get('odoo_scripts', 'odoo_type', 'odoo8')") ODOO_TYPE=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.get('odoo_scripts', 'odoo_type') if c.has_option('odoo_scripts', 'odoo_type') else 'odoo8')")
if [ "$ODOO_TYPE" = "odoo8" ]; if [ "$ODOO_TYPE" = "odoo8" ];
then then
loglevel="--log-level=info" loglevel="--log-level=info"
......
...@@ -8,5 +8,10 @@ ...@@ -8,5 +8,10 @@
# Version 2.19 # Version 2.19
here=$(dirname $0) here=$(dirname $0)
project_home=$(cd $here && cd .. && echo $PWD) project_home=$(cd $here && cd .. && echo $PWD)
python="/usr/bin/env python" if [ -x "$(command -v python3)" ];
then
python="python3"
else
python="python2"
fi
# odoo7, odoo8, odoo10, odoo11 or bzr # odoo7, odoo8, odoo10, odoo11 or bzr
...@@ -12,5 +17,5 @@ ...@@ -12,5 +17,5 @@
# odoo7, odoo8, odoo10, odoo11 or bzr # odoo7, odoo8, odoo10, odoo11 or bzr
ODOO_TYPE=$($python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print c.get('odoo_scripts', 'odoo_type', 'odoo8')") ODOO_TYPE=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.get('odoo_scripts', 'odoo_type') if c.has_option('odoo_scripts', 'odoo_type') else 'odoo8')")
echo "INFO - Starting odoo for development" echo "INFO - Starting odoo for development"
...@@ -118,7 +123,7 @@ ...@@ -118,7 +123,7 @@
else else
if [ "$ODOO_TYPE" = "bzr" ]; if [ "$ODOO_TYPE" = "bzr" ];
then then
addons_path="--addons-path=$($python -B -c "import ConfigParser ; import os ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['$HOME/src/openobject-server/openerp/addons','$HOME/src/openobject-addons','$HOME/src/openerp-web/addons']+['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))")" addons_path="--addons-path=$($python -B -c "from six.moves import configparser ; import os ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['$HOME/src/openobject-server/openerp/addons','$HOME/src/openobject-addons','$HOME/src/openerp-web/addons']+['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))")"
else else
if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ] || [ "$ODOO_TYPE" = "odoo10" ]; if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ] || [ "$ODOO_TYPE" = "odoo10" ];
then then
...@@ -122,5 +127,5 @@ ...@@ -122,5 +127,5 @@
else else
if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ] || [ "$ODOO_TYPE" = "odoo10" ]; if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ] || [ "$ODOO_TYPE" = "odoo10" ];
then then
pathes=$($python -B -c "import ConfigParser ; import os ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['$odoo_addons_path/addons']+['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))") pathes=$($python -B -c "from six.moves import configparser ; import os ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['$odoo_addons_path/addons']+['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))")
else else
...@@ -126,5 +131,5 @@ ...@@ -126,5 +131,5 @@
else else
pathes=$($python -B -c "import ConfigParser ; import os ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))") pathes=$($python -B -c "from six.moves import configparser ; import os ; c = configparser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(','.join(['${project_home}/'+line for line in set(os.path.dirname(path) for path in c.get('odoo_scripts', 'modules').split())]))")
fi fi
if [ -n "$pathes" ]; if [ -n "$pathes" ];
then then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment