Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update startup.py #69

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NukeLauncher(SoftwareLauncher):
"NukeAssist",
"NukeStudio",
"NukeX",
"Hiero",
]

# This dictionary defines a list of executable template strings for each
Expand Down Expand Up @@ -110,6 +111,39 @@ def scan_software(self):

return softwares

def _scan_software_entities(self):
filters = [
['sg_status_list', 'is', 'act'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

['engine', 'in', ['tk-nuke', 'tk-hiero', 'tk-nukestudio']],
{
'filter_operator': 'any',
'filters': [
['sg_mac_template', 'is_not', None],
['sg_linux_template', 'is_not', None],
['sg_windows_template', 'is_not', None],
]
}
]
os_template = {'win32': 'sg_windows_template',
'linux2': 'sg_linux_template',
'darwin': 'sg_mac_template'}
fields = ['sg_mac_template',
'sg_linux_template',
'sg_windows_template']
results = self.shotgun.find("Software", filters, fields)

templ_list = []
for result in results:
try:
templ_list.extend(result.get(
os_template[sys.platform]).split('\n'))
except AttributeError as e:
self.logger.error(
'AttributeError on template \'{}\': {}'.format(result.get('code'), e))
pass

return templ_list

def _find_software(self):
"""
Finds all Nuke software on disk.
Expand All @@ -129,13 +163,15 @@ def _find_software(self):
)

# Certain platforms have more than one location for installed software
for template in executable_templates:
match_templates = executable_templates
match_templates.extend(self._scan_software_entities())

for template in match_templates:
self.logger.debug("Processing template %s.", template)
# Extract all products from that executable.
for executable, tokens in self._glob_and_match(
template, self.COMPONENT_REGEX_LOOKUP
):
self.logger.debug("Processing %s with tokens %s", executable, tokens)
for executable, tokens in self._glob_and_match(template, self.COMPONENT_REGEX_LOOKUP):
self.logger.debug(
"Processing %s with tokens %s", executable, tokens)
for sw in self._extract_products_from_path(executable, tokens):
yield sw

Expand Down Expand Up @@ -268,7 +304,8 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
required_env["TANK_CONTEXT"] = sgtk.Context.serialize(self.context)
required_env["TANK_ENGINE"] = self.engine_name

self.logger.debug("Launch environment: %s", pprint.pformat(required_env))
self.logger.debug("Launch environment: %s",
pprint.pformat(required_env))
self.logger.debug("Launch arguments: %s", required_args)

return LaunchInformation(exec_path, required_args, required_env)
Expand Down Expand Up @@ -317,7 +354,8 @@ def _get_plugin_startup_env(self, plugin_names, app_path, app_args, file_to_open
plugin_path = os.path.join(self.disk_location, "plugins", plugin_name)

if os.path.exists(plugin_path):
self.logger.debug("Plugin '%s' found at '%s'", plugin_name, plugin_path)
self.logger.debug("Plugin '%s' found at '%s'",
plugin_name, plugin_path)
startup_paths.append(plugin_path)
else:
self.logger.warning(
Expand Down