Check for PyAMS command line script in application startup
authorThierry Florac <tflorac@ulthar.net>
Sun, 18 Feb 2018 12:50:18 +0100
changeset 50 c66a8bf09662
parent 49 f65a0b93fea7
child 51 2eea97d70f10
Check for PyAMS command line script in application startup
src/pyams_scheduler/include.py
--- a/src/pyams_scheduler/include.py	Thu Feb 08 08:54:58 2018 +0100
+++ b/src/pyams_scheduler/include.py	Sun Feb 18 12:50:18 2018 +0100
@@ -18,6 +18,7 @@
 import logging
 logger = logging.getLogger('PyAMS (scheduler')
 
+import os.path
 import sys
 
 # import interfaces
@@ -54,8 +55,9 @@
 def handle_new_application(event):
     """Start scheduler process when application is created"""
 
-    # Check for upgrade mode
-    if sys.argv[0].endswith('pyams_upgrade'):
+    # Check for PyAMS command line script
+    cmdline = os.path.split(sys.argv[0])[-1]
+    if cmdline.startswith('pyams_'):
         return
 
     registry = get_global_registry()
@@ -68,10 +70,10 @@
         # get application
         application_name = settings.get(PYAMS_APPLICATION_SETTINGS_KEY, PYAMS_APPLICATION_DEFAULT_NAME)
         application = root.get(application_name)
-        process = None
         if application is not None:
             sm = application.getSiteManager()
             set_local_registry(sm)
+            process = None
             try:
                 scheduler_util = sm.get(SCHEDULER_NAME)
                 try: