Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Short Pyblish plugin path #2428

Merged
merged 2 commits into from
Dec 22, 2021
Merged

Short Pyblish plugin path #2428

merged 2 commits into from
Dec 22, 2021

Conversation

2-REC
Copy link
Contributor

@2-REC 2-REC commented Dec 21, 2021

Brief description

Bug fix when using a short path for Pyblish plugins.

Description

When filtering the Pyblish plugins, if the config data for the current host is not found, the host will be extracted from the plugin's path.
If the path is composed of less than 4 elements (including the file name), it will crash.
Even more, the crash also occurs when the config data is found, as the code extracting the host name from the path is executed regardless its need.

Additional info

The error occurs in the 'filter_pyblish_plugins' function, when trying to access the components of the path up to index -4.
Additionally, the code is executed even when not needed, as it is located before testing for the defined host.
The produced exception message:

# Traceback (most recent call last):
#   File "c:\Program Files (x86)\OpenPype\openpype\tools\pyblish_pype\control.py", line 180, in reset
#     self.load_plugins()
#   File "c:\Program Files (x86)\OpenPype\openpype\tools\pyblish_pype\control.py", line 192, in load_plugins
#     plugins = pyblish.api.discover()
#   File "c:\Program Files (x86)\OpenPype\dependencies\pyblish\plugin.py", line 1384, in discover
#     filter_(plugins)
#   File "c:\Program Files (x86)\OpenPype\openpype\lib\plugin_tools.py", line 187, in filter_pyblish_plugins
#     host_from_file = file.split(os.path.sep)[-4:-3][0]
# IndexError: list index out of range

Testing notes:

  1. Define a plugin path in the settings UI ('Additional Project Plugin Paths' in the project 'Global' settings) with a single directory. For example (in Windows) "C:\pype_plugins".
  2. In this directory, add a plugin file (to have the plugin filtered and the path parsed).
  3. Open a host via OpenPype launcher (e.g.: Maya) and start Pyblish.
  4. The exception should occur.

@antirotor antirotor self-requested a review December 22, 2021 15:16
@antirotor antirotor added backend type: bug Something isn't working labels Dec 22, 2021
Copy link
Member

@antirotor antirotor left a comment

Choose a reason for hiding this comment

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

it works, thank you!

@antirotor antirotor merged commit 46e3681 into ynput:develop Dec 22, 2021
@2-REC 2-REC deleted the bugfix/plugins_shortpath branch December 24, 2021 04:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants