From 72412ad863f56729f075753cd78734c9c72336d5 Mon Sep 17 00:00:00 2001 From: antirotor Date: Tue, 8 Jan 2019 13:47:54 +0100 Subject: [PATCH] better deadline handling --- .../maya/create/create_renderglobals.py | 28 ++++++++++--------- .../publish/validate_deadline_connection.py | 11 ++------ 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/pype/plugins/maya/create/create_renderglobals.py b/pype/plugins/maya/create/create_renderglobals.py index 61fd76f6ef..b9e4f99ad5 100644 --- a/pype/plugins/maya/create/create_renderglobals.py +++ b/pype/plugins/maya/create/create_renderglobals.py @@ -20,18 +20,22 @@ class CreateRenderGlobals(avalon.maya.Creator): self.data["id"] = "avalon.renderglobals" # get pools - try: - deadline_url = os.environ["DEADLINE_REST_URL"] - except KeyError: - self.log.error("Deadline REST API url not found.") + pools = [] + data = OrderedDict(**self.data) - argument = "{}/api/pools?NamesOnly=true".format(deadline_url) - response = requests.get(argument) - if not response.ok: - self.log.warning("No pools retrieved") - pools = [] + deadline_url = os.environ.get('DEADLINE_REST_URL', None) + if deadline_url is None: + self.log.warning("Deadline REST API url not found.") else: - pools = response.json() + argument = "{}/api/pools?NamesOnly=true".format(deadline_url) + response = requests.get(argument) + if not response.ok: + self.log.warning("No pools retrieved") + else: + pools = response.json() + data["primaryPool"] = pools + # We add a string "-" to allow the user to not set any secondary pools + data["secondaryPool"] = ["-"] + pools # We don't need subset or asset attributes self.data.pop("subset", None) @@ -49,9 +53,7 @@ class CreateRenderGlobals(avalon.maya.Creator): data["whitelist"] = False data["machineList"] = "" data["useMayaBatch"] = True - data["primaryPool"] = pools - # We add a string "-" to allow the user to not set any secondary pools - data["secondaryPool"] = ["-"] + pools + self.data = data self.options = {"useSelection": False} # Force no content diff --git a/pype/plugins/maya/publish/validate_deadline_connection.py b/pype/plugins/maya/publish/validate_deadline_connection.py index d0f6e9e54d..e4b0eebb60 100644 --- a/pype/plugins/maya/publish/validate_deadline_connection.py +++ b/pype/plugins/maya/publish/validate_deadline_connection.py @@ -15,15 +15,10 @@ class ValidateDeadlineConnection(pyblish.api.ContextPlugin): def process(self, instance): - # AVALON_DEADLINE = api.Session.get("AVALON_DEADLINE", - # "http://localhost:8082") - # - # assert AVALON_DEADLINE is not None, "Requires AVALON_DEADLINE" - - try: - deadline_url = os.environ["DEADLINE_REST_URL"] - except KeyError: + deadline_url = os.environ.get('DEADLINE_REST_URL', None) + if deadline_url is None: self.log.error("Deadline REST API url not found.") + raise ValueError("Deadline REST API url not found.") # Check response response = requests.get(deadline_url)