mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
Aport action is checking before launch if already aport is running
This commit is contained in:
parent
7bd1f6df6a
commit
c8c336bdd3
1 changed files with 19 additions and 4 deletions
|
|
@ -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"])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue