Check for PyAMS command line script in application startup
authorThierry Florac <tflorac@ulthar.net>
Sun, 18 Feb 2018 12:47:42 +0100
changeset 75 73e3b79a71b1
parent 74 be2e9a915714
child 76 6fd737a311f0
Check for PyAMS command line script in application startup
src/pyams_media/include.py
--- a/src/pyams_media/include.py	Sun Feb 18 12:47:28 2018 +0100
+++ b/src/pyams_media/include.py	Sun Feb 18 12:47:42 2018 +0100
@@ -18,6 +18,7 @@
 import logging
 logger = logging.getLogger('PyAMS (media)')
 
+import os.path
 import sys
 
 # import interfaces
@@ -53,8 +54,9 @@
 def handle_new_application(event):
     """Start converter process when application created"""
 
-    # check for upgrade mode
-    if sys.argv[0].endswith('pyams_upgrade'):
+    # check for PyAMS command line script
+    cmsline = os.path.split(sys.argv[0])[-1]
+    if cmsline.startswith('pyams_'):
         return
 
     registry = get_global_registry()
@@ -67,10 +69,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:
                 conversion_util = sm.get(CONVERTER_NAME)
                 if conversion_util is not None: