-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Describe the bug
Due to the changed method of script installation in NAV 5.9, the navsyncdb, navpgdump and navtopology commands now run twice on every invocation. This isn't normally a big problem, but it can result in strange output and errors during an invocation, for example if using the command to create the initial NAV database (as the second run will typically fail because the database was already created and populated by the first run).
The principal problem is because nav/bin/navsyncdb.py and the other mentioned scripts are implemented to import main() from somewhere else, but do not implement a if __name__ == '__main__' guard to avoid running main() as a side effect of an import operation, like so:
nav/python/nav/bin/navsyncdb.py
Lines 2 to 4 in ef1bca6
| from nav.pgsync import main | |
| main() |
To Reproduce
Steps to reproduce the behavior (WARNING: This is a destructive command, never run it in a production environment):
- Run
navsyncdbfrom the command line. - See double output:
$ navsyncdb
No outstanding schema changes.
No outstanding schema changes.Expected behavior
navsyncdb, navpgdump and navtopology should only run once per invocation.
Environment (please complete the following information):
- NAV version installed: 5.9.1