I’m new to Pyblish, just starting to look under the hood this week. I have Pyblish up and running in Maya, which seems like it will be an awesome step towards my studio’s asset validation needs. But I’m also trying to see how I can apply Pyblish to work stand alone on the file system. Meaning I’d like to point Pyblish to a folder and validate it’s structure against a number of rules.
When it comes to the Context in Maya, that makes sense, it’s the opened scene ATM. But when it comes to validating a folder, I’d like to make my own context object, add a new instance (which represents the file path) perform my collection and validation (updating the instance) and then pass that context to the pyblish_qml UI.
The script below is what I’ve tried, and when I call show() to open the QML UI, it’s almost as if the context has been forgotten or updated without my custom Instance object (the folder path to validate).
Is there a proper way I should be doing this? Essentially I want to use the UI, but create instances for each folder path to check and make sure those instances are always in the UI even after opening\updating.
Thanks!
import os
import argparse
import pyblish.api
import pyblish.util
import pyblish_qml
def run_path_validation(path):
if not os.path.exists(path):
raise Exception("Could not find the supplied path: {} on the hard drive. Ensure it actually exists and is formatted properly.".format(args.path))
pyblish.api.register_plugin_path(r"D:\plugins")
context = pyblish.api.Context()
instance = context.create_instance(name="FilePath")
instance.data["path"] = path
pyblish.util.publish(context)
# Register and show the Pyblish GUI
pyblish.api.register_gui("pyblish_qml")
server = pyblish_qml.show()
server.wait()
parser = argparse.ArgumentParser()
parser.add_argument('-p', "--path", required=True)
if __name__ == "__main__":
args = parser.parse_args()
run_path_validation(args.path)