qwat / qwat-data-model

TEKSI Water module (project QWAT) - PostgreSQL / postgis Datamodel
https://www.teksi.ch
23 stars 24 forks source link

upgrade_db.sh or PUM should warn if python version is not python 3 #207

Closed haubourg closed 6 years ago

haubourg commented 6 years ago

Testing new upgrade_db version fails with python 2, which is generally the default one on most distributions pum. And PUM requires python 3.

Warning + tip could be

Postgres Update Manager requires python 3. Tip : use alias python = python3 to switch your python version.

By the way, should we keep PUM in 2.X Pip repository ?

m-kuhn commented 6 years ago

I wouldn't want a hint to modify the system configuration. It might break other things as side effect. Let's better try to get things right and this package out of the repository (and adjust the shebang?)

haubourg commented 6 years ago

in fact, I couldn't have pum work with python 3 without using a virtualenv. So Ok for not adding a hint, but we need to warn that in the docs.

m-kuhn commented 6 years ago

Can you open an issue what's wrong with pum if you are not using a virtualenv? I prefer to fix things rather than documenting workarounds wherever possible.

haubourg commented 6 years ago

well, that's more a ubuntu issue by now, I need not pip but pip3 package. But even with that pum install goes well, but I couldn't find the pum exec.

pip3 search pum returns

pum (0.5.4)                      - Postgres upgrade manager
  INSTALLED: 0.5.4 (latest)

then

 regis-> pip3 show -f pum
---
Metadata-Version: 2.0
Name: pum
Version: 0.5.4
Summary: Postgres upgrade manager
Home-page: https://github.com/opengisch/pum
Author: Mario Baranzini
Author-email: mario@opengis.chcd /
Installer: pip
License: UNKNOWN
Location: /home/regis/.local/lib/python3.5/site-packages
Requires: psycopg2, PyYAML
Classifiers:
  Topic :: Database
  License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
  Intended Audience :: System Administrators
  Intended Audience :: Information Technology
  Topic :: Software Development :: Version Control
  Development Status :: 5 - Production/Stable
Files:
  ../../../bin/pum
  pum-0.5.4.dist-info/DESCRIPTION.rst
  pum-0.5.4.dist-info/INSTALLER
  pum-0.5.4.dist-info/METADATA
  pum-0.5.4.dist-info/RECORD
  pum-0.5.4.dist-info/WHEEL
  pum-0.5.4.dist-info/metadata.json
  pum-0.5.4.dist-info/top_level.txt
  pum/__init__.py
  pum/__pycache__/__init__.cpython-35.pyc
  pum/core/__init__.py
  pum/core/__pycache__/__init__.cpython-35.pyc
  pum/core/__pycache__/checker.cpython-35.pyc
  pum/core/__pycache__/deltapy.cpython-35.pyc
  pum/core/__pycache__/dumper.cpython-35.pyc
  pum/core/__pycache__/upgrader.cpython-35.pyc
  pum/core/checker.py
  pum/core/deltapy.py
  pum/core/dumper.py
  pum/core/upgrader.py
  pum/utils/__init__.py
  pum/utils/__pycache__/__init__.cpython-35.pyc
  pum/utils/__pycache__/utils.cpython-35.pyc
  pum/utils/utils.py

But pum does not seem to be in my path anyway:

 pum --help
La commande « pum » est introuvable, vouliez-vous dire :
ponceta commented 6 years ago

I can run pum check but not any other pum function

(tutorial-env) pulmexa@ubuntu:~/qwat-data-model/update$ ./upgrade_db.sh 
CREATE EXTENSION
CREATE EXTENSION
...
Set baseline...OK
Test and upgrade...Dump...ERROR
b'pg_dump: [archiver (db)] connection to database "qwat_dev" failed: could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?\n'
Check...DIFFERENCES FOUND
tables:
- + ('qwat_sys', 'info')
- + ('qwat_sys', 'logged_relations')
- + ('qwat_sys', 'upgrades')
haubourg commented 6 years ago

you qwat_dev service seems wrong. Can you connect to it directly.?

ponceta commented 6 years ago

No but we can have a look on it on monday. It's probably simple.

m-kuhn commented 6 years ago

@haubourg, did you install --user

haubourg commented 6 years ago

@m-kuhn Uh? What do you mean?

m-kuhn commented 6 years ago

Did you install pum with pip3 install pum --user or sudo pip3 install pum?

haubourg commented 6 years ago

I did a simple pip3 install pum

m-kuhn commented 6 years ago

I guess that adds the --user transparently (it doesn't have write access to /bin without sudo). csn you try the sudo one?

haubourg commented 6 years ago

upgrade_db.sh and init_db.sh now warn / exit if pum is not correctly callable.

ponceta commented 6 years ago

I can confirm that. Top!