Skip to content

Commit

Permalink
Merge pull request #69 from ynput/bugfix/no_webservice_connection
Browse files Browse the repository at this point in the history
Fail better when no DL webservice connection
  • Loading branch information
kalisp authored Dec 3, 2024
2 parents 6fad831 + 69896e8 commit 510e153
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 36 deletions.
7 changes: 1 addition & 6 deletions client/ayon_deadline/lib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
import json
from dataclasses import dataclass, field, asdict
from functools import partial
Expand Down Expand Up @@ -173,11 +172,7 @@ def _get_deadline_info(
except requests.exceptions.ConnectionError as exc:
msg = 'Cannot connect to DL web service {}'.format(endpoint)
log.error(msg)
raise(
DeadlineWebserviceError,
DeadlineWebserviceError('{} - {}'.format(msg, exc)),
sys.exc_info()[2]
)
raise DeadlineWebserviceError(msg) from exc
if not response.ok:
log.warning(f"No {item_type} retrieved")
return []
Expand Down
75 changes: 45 additions & 30 deletions client/ayon_deadline/plugins/publish/global/collect_jobinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ayon_deadline.lib import (
FARM_FAMILIES,
AYONDeadlineJobInfo,
DeadlineWebserviceError,
)


Expand Down Expand Up @@ -116,36 +117,50 @@ def apply_settings(cls, project_settings):
addons_manager = AddonsManager(project_settings)
deadline_addon = addons_manager["deadline"]
deadline_server_name = settings["deadline_server"]
pools = deadline_addon.get_pools_by_server_name(deadline_server_name)
cls.pool_enum_values = [
{"value": pool, "label": pool}
for pool in pools
]

groups = deadline_addon.get_groups_by_server_name(deadline_server_name)
cls.group_enum_values = [
{"value": group, "label": group}
for group in groups
]

limit_groups = deadline_addon.get_limit_groups_by_server_name(
deadline_server_name
)
limit_group_items = [
{"value": limit_group, "label": limit_group}
for limit_group in limit_groups
]
if not limit_group_items:
limit_group_items.append({"value": None, "label": "< none >"})
cls.limit_group_enum_values = limit_group_items

machines = deadline_addon.get_machines_by_server_name(
deadline_server_name
)
cls.machines_enum_values = [
{"value": machine, "label": machine}
for machine in machines
]
pools = []
groups = []
limit_groups = []
machines = []
try:
pools = [
{"value": pool, "label": pool}
for pool in deadline_addon.get_pools_by_server_name(
deadline_server_name
)
]
groups = [
{"value": group, "label": group}
for group in deadline_addon.get_groups_by_server_name(
deadline_server_name
)
]
limit_groups = [
{"value": limit_group, "label": limit_group}
for limit_group in (
deadline_addon.get_limit_groups_by_server_name(
deadline_server_name
)
)
]
machines = [
{"value": machine, "label": machine}
for machine in deadline_addon.get_machines_by_server_name(
deadline_server_name
)
]
except DeadlineWebserviceError:
cls.log.warning(f"Unable to connect to {deadline_server_name}")

for items in [
pools, groups, limit_groups, machines
]:
if not items:
items.append({"value": None, "label": "< none >"})

cls.pool_enum_values = pools
cls.group_enum_values = groups
cls.limit_group_enum_values = limit_groups
cls.machines_enum_values = machines

@classmethod
def get_attr_defs_for_instance(cls, create_context, instance):
Expand Down

0 comments on commit 510e153

Please sign in to comment.