You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
lunkwill42
changed the title
[BUG] navsyncdb command runs twice on every invocation
[BUG] Several NAV scripts run twice on every invocation
Mar 20, 2024
Describe the bug
Due to the changed method of script installation in NAV 5.9, the
navsyncdb
,navpgdump
andnavtopology
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 importmain()
from somewhere else, but do not implement aif __name__ == '__main__'
guard to avoid runningmain()
as a side effect of an import operation, like so:nav/python/nav/bin/navsyncdb.py
Lines 2 to 4 in ef1bca6
To Reproduce
Steps to reproduce the behavior (WARNING: This is a destructive command, never run it in a production environment):
navsyncdb
from the command line.Expected behavior
navsyncdb
,navpgdump
andnavtopology
should only run once per invocation.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: