Maybe something to have by default even? There’s been talk about making something like this available before, but nothing ever came up to provide the interface for it. This could be it.
It would be awesome if you could share what you come up with, and maybe even pull request to add a default.
And @marcus already fixed the issue and with the new version in the repository all should be well doing a inspect.getfile() on the plug-in. As such creating an Action to show the plug-in in explorer should be roughly similar to
import pyblish.api
import subprocess
import os
import inspect
@pyblish.api.log
class ShowPluginInExplorerAction(pyblish.api.Action):
def process(self, plugin):
# Ensure it's not a registry loaded plug-in
module = plugin.__module__
if module == '__main__':
self.log.error("Action: Can't show file for in-memory plug-in")
return
path = inspect.getfile(plugin)
self.show_in_explorer(path)
def show_in_explorer(self, path):
path = os.path.abspath(str(path))
subprocess.Popen(r'explorer /select, "{0}"'.format(path))
Note that this is untested code!
Hope to have some more time on my hands soon to get this tested and added.
Was this also recommended as a way to perform Repair? What I like about the old implementation where one defines a repair() method on the plug-in is that it would show up as a “wrench” icon on the plug-in when it failed.
How does one implement that same behavior with Actions?
Currently I don’t think Actions are visually represented in the Overview (@marcus?). Would be an interesting feature to add the actions icons to the plugin when appropriate.
But you can’t see whether a plugin has actions associated, without right-clicking on it. If you added the icons of an action to the plugin visually, similar to how the wrench looks now, the user would know whether there are actions on a plugin without knowing in advanced or right-clicking.
I’d imagine that the user still needs to right-click to execute the action, but they can see in the overview that a certain action is present for a plugin.
I was specifically looking for a way to have an “icon” be added to the plug-in in the overview just like the Repair icon did before. So that one doesn’t need to right click?
Could the Actions have something like that?
#pseudocode
class MyAction(Action):
icon_in_overview = True
...