mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Deadline in Pype 3 - Hound & Cleanup
Events and plugins should be in 'vendor' dir only for now
This commit is contained in:
parent
1dcddc9b4e
commit
598266bb6d
4 changed files with 21 additions and 273 deletions
42
vendor/deadline/custom/events/Pype/Pype.py
vendored
42
vendor/deadline/custom/events/Pype/Pype.py
vendored
|
|
@ -1,6 +1,4 @@
|
|||
import os
|
||||
import sys
|
||||
import logging
|
||||
import json
|
||||
import subprocess
|
||||
import platform
|
||||
|
|
@ -11,7 +9,6 @@ import time
|
|||
import Deadline.Events
|
||||
import Deadline.Scripting
|
||||
|
||||
from System import Environment
|
||||
|
||||
def GetDeadlineEventListener():
|
||||
return PypeEventListener()
|
||||
|
|
@ -71,7 +68,6 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
|
||||
self.ALREADY_INJECTED = False
|
||||
|
||||
|
||||
def Cleanup(self):
|
||||
del self.OnJobSubmittedCallback
|
||||
del self.OnJobStartedCallback
|
||||
|
|
@ -101,7 +97,7 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
del self.OnThermalShutdownCallback
|
||||
del self.OnMachineRestartCallback
|
||||
|
||||
def inject_pype_environment(self, job, additonalData={}):
|
||||
def inject_pype_environment(self, job, additonalData=None):
|
||||
|
||||
if self.ALREADY_INJECTED:
|
||||
self.LogInfo("Environment injected previously")
|
||||
|
|
@ -117,16 +113,19 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
|
||||
self.LogInfo("inject_pype_environment start")
|
||||
try:
|
||||
pype_command = "pype_console"
|
||||
if platform.system().lower() == "linux":
|
||||
pype_command = "pype_console.sh"
|
||||
elif platform.system().lower() == "windows":
|
||||
if platform.system().lower() == "windows":
|
||||
pype_command = "pype_console.exe"
|
||||
|
||||
pype_root = self.GetConfigEntryWithDefault("PypeExecutable", "").strip()
|
||||
pype_root = self.GetConfigEntryWithDefault("PypeExecutable", "")
|
||||
|
||||
pype_app = os.path.join(pype_root , pype_command)
|
||||
pype_app = os.path.join(pype_root.strip(), pype_command)
|
||||
if not os.path.exists(pype_app):
|
||||
raise RuntimeError("App '{}' doesn't exist. Fix it in Tools > Configure Events > pype".format(pype_app))
|
||||
raise RuntimeError("App '{}' doesn't exist. " +
|
||||
"Fix it in Tools > Configure Events > " +
|
||||
"pype".format(pype_app))
|
||||
|
||||
# tempfile.TemporaryFile cannot be used because of locking
|
||||
export_url = os.path.join(tempfile.gettempdir(),
|
||||
|
|
@ -134,20 +133,21 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
'env.json') # add HHMMSS + delete later
|
||||
self.LogInfo("export_url {}".format(export_url))
|
||||
|
||||
additional_args = {}
|
||||
additional_args['project'] = job.GetJobEnvironmentKeyValue('AVALON_PROJECT')
|
||||
additional_args['asset'] = job.GetJobEnvironmentKeyValue('AVALON_ASSET')
|
||||
additional_args['task'] = job.GetJobEnvironmentKeyValue('AVALON_TASK')
|
||||
additional_args['app'] = job.GetJobEnvironmentKeyValue('AVALON_APP_NAME')
|
||||
self.LogInfo("args::{}".format(additional_args))
|
||||
add_args = {}
|
||||
add_args['project'] = \
|
||||
job.GetJobEnvironmentKeyValue('AVALON_PROJECT')
|
||||
add_args['asset'] = job.GetJobEnvironmentKeyValue('AVALON_ASSET')
|
||||
add_args['task'] = job.GetJobEnvironmentKeyValue('AVALON_TASK')
|
||||
add_args['app'] = job.GetJobEnvironmentKeyValue('AVALON_APP_NAME')
|
||||
self.LogInfo("args::{}".format(add_args))
|
||||
|
||||
args = [
|
||||
pype_app,
|
||||
'extractenvironments',
|
||||
export_url
|
||||
]
|
||||
if all(additional_args.values()):
|
||||
for key, value in additional_args.items():
|
||||
if all(add_args.values()):
|
||||
for key, value in add_args.items():
|
||||
args.append("--{}".format(key))
|
||||
args.append(value)
|
||||
|
||||
|
|
@ -163,13 +163,13 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
for key, value in contents.items():
|
||||
job.SetJobEnvironmentKeyValue(key, value)
|
||||
|
||||
Deadline.Scripting.RepositoryUtils.SaveJob(job) # IMPORTANT
|
||||
Deadline.Scripting.RepositoryUtils.SaveJob(job) # IMPORTANT
|
||||
self.ALREADY_INJECTED = True
|
||||
|
||||
os.remove(export_url)
|
||||
|
||||
self.LogInfo("inject_pype_environment end")
|
||||
except Exception as error:
|
||||
except Exception:
|
||||
import traceback
|
||||
self.LogInfo(traceback.format_exc())
|
||||
self.LogInfo("inject_pype_environment failed")
|
||||
|
|
@ -177,7 +177,7 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
raise
|
||||
|
||||
def updateFtrackStatus(self, job, statusName, createIfMissing=False):
|
||||
"Updates version status on ftrack"
|
||||
"""Updates version status on ftrack"""
|
||||
pass
|
||||
|
||||
def OnJobSubmitted(self, job):
|
||||
|
|
@ -220,7 +220,7 @@ class PypeEventListener(Deadline.Events.DeadlineEventListener):
|
|||
|
||||
def OnJobError(self, job, task, report):
|
||||
self.LogInfo("OnJobError LOGGING")
|
||||
data = {"task": task, "report": report}
|
||||
#data = {"task": task, "report": report}
|
||||
|
||||
def OnJobPurged(self, job):
|
||||
pass
|
||||
|
|
|
|||
29
vendor/deadline/custom/plugins/deadline_module.py
vendored
Normal file
29
vendor/deadline/custom/plugins/deadline_module.py
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
from pype.modules import (
|
||||
PypeModule, IPluginPaths)
|
||||
|
||||
|
||||
class DeadlineModule(PypeModule, IPluginPaths):
|
||||
name = "deadline"
|
||||
|
||||
def initialize(self, modules_settings):
|
||||
# This module is always enabled
|
||||
deadline_settings = modules_settings[self.name]
|
||||
self.enabled = deadline_settings["enabled"]
|
||||
self.deadline_url = deadline_settings["DEADLINE_REST_URL"]
|
||||
|
||||
def get_global_environments(self):
|
||||
"""Deadline global environments for pype implementation."""
|
||||
return {
|
||||
"DEADLINE_REST_URL": self.deadline_url
|
||||
}
|
||||
|
||||
def connect_with_modules(self, *_a, **_kw):
|
||||
return
|
||||
|
||||
def get_plugin_paths(self):
|
||||
"""Deadline plugin paths."""
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
return {
|
||||
"publish": [os.path.join(current_dir, "plugins", "publish")]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue