From c8c336bdd30ae9c88a201bc98064f0c6c791b1d2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 19 Feb 2019 09:49:43 +0100 Subject: [PATCH 01/67] Aport action is checking before launch if already aport is running --- pype/plugins/launcher/actions/Aport.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pype/plugins/launcher/actions/Aport.py b/pype/plugins/launcher/actions/Aport.py index 16906f6ce7..5810e0ce99 100644 --- a/pype/plugins/launcher/actions/Aport.py +++ b/pype/plugins/launcher/actions/Aport.py @@ -1,7 +1,5 @@ import os -import sys -from avalon import io -from pprint import pprint +import psutil import acre from avalon import api, lib @@ -25,6 +23,16 @@ class Aport(api.Action): return True return False + def is_running(self, filename): + procs = [p for p in psutil.process_iter() if ( + 'python.exe' in p.name() and + filename in p.cmdline() + )] + + if len(procs) > 0: + return True + return False + def process(self, session, **kwargs): """Implement the behavior for when the action is triggered @@ -35,10 +43,17 @@ class Aport(api.Action): Popen instance of newly spawned process """ + av_core_path = os.environ.get('AVALON_CORE', None) + path_items = [ + av_core_path, 'setup', 'aport', 'pythonpath', 'init.py' + ] + aport_path = os.path.sep.join(path_items) + if self.is_running(aport_path): + log.info("Aport server is already running") + return with pype.modified_environ(**session): # Get executable by name - print(self.name) app = lib.get_application(self.name) executable = lib.which(app["executable"]) From cf62926da6e8d9d092c932aafbae5cad2f5ede59 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 19 Feb 2019 09:58:32 +0100 Subject: [PATCH 02/67] action triggers launch of preactions if app has set them and allows check if app is already running --- pype/ftrack/lib/ftrack_app_handler.py | 79 +++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/pype/ftrack/lib/ftrack_app_handler.py b/pype/ftrack/lib/ftrack_app_handler.py index 9aed3d74da..7ceb5d635f 100644 --- a/pype/ftrack/lib/ftrack_app_handler.py +++ b/pype/ftrack/lib/ftrack_app_handler.py @@ -3,8 +3,10 @@ import os import sys import platform +import psutil from avalon import lib as avalonlib import acre +import ftrack_api from pype import api as pype from pype import lib as pypelib from .avalon_sync import get_config_data @@ -20,13 +22,17 @@ class AppAction(BaseHandler): - a unique identifier for app. - a verbose descriptive text for you action - icon in ftrack + +