Beispiel #1
0
def main():
    # prepare all environments
    _prepare_publish_environments()

    # Registers pype's Global pyblish plugins
    pype.install()

    for path in PUBLISH_PATHS:
        path = os.path.normpath(path)

        if not os.path.exists(path):
            continue

        log.info(f"Registering path: {path}")
        pyblish.api.register_plugin_path(path)

    pyblish.api.register_host(publish_host)

    # Register project specific plugins
    project_name = os.environ["AVALON_PROJECT"]
    project_plugins_paths = os.getenv("PYPE_PROJECT_PLUGINS", "")
    for path in project_plugins_paths.split(os.pathsep):
        plugin_path = os.path.join(path, project_name, "plugins")
        if os.path.exists(plugin_path):
            pyblish.api.register_plugin_path(plugin_path)

    return publish.show()
Beispiel #2
0
def cli_publish(data, gui=True):
    io.install()

    pyblish.api.deregister_all_plugins()
    # Registers Global pyblish plugins
    pype.install()
    # Registers Standalone pyblish plugins
    for path in PUBLISH_PATHS:
        pyblish.api.register_plugin_path(path)

    project_plugins_paths = os.environ.get("PYPE_PROJECT_PLUGINS")
    project_name = os.environ["AVALON_PROJECT"]
    if project_plugins_paths and project_name:
        for path in project_plugins_paths.split(os.pathsep):
            if not path:
                continue
            plugin_path = os.path.join(path, project_name, "plugins")
            if os.path.exists(plugin_path):
                pyblish.api.register_plugin_path(plugin_path)
                api.register_plugin_path(api.Loader, plugin_path)
                api.register_plugin_path(api.Creator, plugin_path)

    # Create hash name folder in temp
    chars = "".join([random.choice(string.ascii_letters) for i in range(15)])
    staging_dir = tempfile.mkdtemp(chars)

    # create json for return data
    return_data_path = (staging_dir + os.path.basename(staging_dir) +
                        'return.json')
    # create also json and fill with data
    json_data_path = staging_dir + os.path.basename(staging_dir) + '.json'
    with open(json_data_path, 'w') as outfile:
        json.dump(data, outfile)

    args = ["-pp", os.pathsep.join(pyblish.api.registered_paths())]

    if gui:
        args += ["gui"]

    envcopy = os.environ.copy()
    envcopy["PYBLISH_HOSTS"] = "standalonepublisher"
    envcopy["SAPUBLISH_INPATH"] = json_data_path
    envcopy["SAPUBLISH_OUTPATH"] = return_data_path
    envcopy["PYBLISH_GUI"] = "pyblish_pype"

    returncode = execute([sys.executable, "-u", "-m", "pyblish"] + args,
                         env=envcopy)

    result = {}
    if os.path.exists(json_data_path):
        with open(json_data_path, "r") as f:
            result = json.load(f)

    io.uninstall()
    # TODO: check if was pyblish successful
    # if successful return True
    print('Check result here')
    return False
Beispiel #3
0
def main(env):
    import pype.hosts.resolve as bmdvr
    # Registers pype's Global pyblish plugins
    pype.install()

    # activate resolve from pype
    avalon.install(bmdvr)

    log.info(f"Avalon registred hosts: {avalon.registered_host()}")

    bmdvr.launch_pype_menu()
Beispiel #4
0
def main(env):
    from pype.hosts.fusion.api import menu
    import avalon.fusion
    # Registers pype's Global pyblish plugins
    pype.install()

    # activate resolve from pype
    avalon.api.install(avalon.fusion)

    log.info(f"Avalon registred hosts: {avalon.api.registered_host()}")

    menu.launch_pype_menu()
Beispiel #5
0
def main():
    # prepare all environments
    _prepare_publish_environments()

    # Registers pype's Global pyblish plugins
    pype.install()

    if os.path.exists(PUBLISH_PATH):
        log.info(f"Registering path: {PUBLISH_PATH}")
        pyblish.api.register_plugin_path(PUBLISH_PATH)

    pyblish.api.register_host(publish_host)

    return publish.show()
Beispiel #6
0
    def publish(paths):
        """Start headless publishing.

        Publish use json from passed paths argument.

        Args:
            paths (list): Paths to jsons.

        Raises:
            RuntimeError: When there is no pathto process.
        """
        if not any(paths):
            raise RuntimeError("No publish paths specified")

        from pype import install, uninstall
        from pype.api import Logger

        # Register target and host
        import pyblish.api
        import pyblish.util

        env = get_app_environments_for_context(os.environ["AVALON_PROJECT"],
                                               os.environ["AVALON_ASSET"],
                                               os.environ["AVALON_TASK"],
                                               os.environ["AVALON_APP_NAME"])
        os.environ.update(env)

        log = Logger.get_logger()

        install()

        pyblish.api.register_target("filesequence")
        pyblish.api.register_host("shell")

        os.environ["PYPE_PUBLISH_DATA"] = os.pathsep.join(paths)

        log.info("Running publish ...")

        # Error exit as soon as any error occurs.
        error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}"

        for result in pyblish.util.publish_iter():
            if result["error"]:
                log.error(error_format.format(**result))
                uninstall()
                sys.exit(1)

        log.info("Publish finished.")
        uninstall()
Beispiel #7
0
def test_avalon_plugin_presets(monkeypatch, printer):

    pype.install()
    api.register_host(Test())
    api.register_plugin(api.Creator, MyTestCreator)
    plugins = api.discover(api.Creator)
    printer("Test if we got our test plugin")
    assert MyTestCreator in plugins
    for p in plugins:
        if p.__name__ == "MyTestCreator":
            printer("Test if we have overriden existing property")
            assert p.my_test_property == "B"
            printer("Test if we have overriden superclass property")
            assert p.active is False
            printer("Test if we have added new property")
            assert p.new_property == "new"
Beispiel #8
0
def main(env):
    # Registers pype's Global pyblish plugins
    pype.install()

    # Register Host (and it's pyblish plugins)
    host_name = env["AVALON_APP"]
    # TODO not sure if use "pype." or "avalon." for host import
    host_import_str = f"pype.{host_name}"

    try:
        host_module = importlib.import_module(host_import_str)
    except ModuleNotFoundError:
        log.error((f"Host \"{host_name}\" can't be imported."
                   f" Import string \"{host_import_str}\" failed."))
        return False

    avalon.api.install(host_module)

    # Register additional paths
    addition_paths_str = env.get("PUBLISH_PATHS") or ""
    addition_paths = addition_paths_str.split(os.pathsep)
    for path in addition_paths:
        path = os.path.normpath(path)
        if not os.path.exists(path):
            continue

        pyblish.api.register_plugin_path(path)

    # Register project specific plugins
    project_name = os.environ["AVALON_PROJECT"]
    project_plugins_paths = env.get("PYPE_PROJECT_PLUGINS") or ""
    for path in project_plugins_paths.split(os.pathsep):
        plugin_path = os.path.join(path, project_name, "plugins")
        if os.path.exists(plugin_path):
            pyblish.api.register_plugin_path(plugin_path)

    return publish.show()
Beispiel #9
0
 def __init__(self):
     super(ThisTestGUI, self).__init__()
     # Registers pype's Global pyblish plugins
     pype.install()
     # activate resolve from pype
     avalon.install(bmdvr)
Beispiel #10
0
 def tray_start(self):
     # Registers Global pyblish plugins
     pype.install()
     # Registers Standalone pyblish plugins
     for path in self.PUBLISH_PATHS:
         pyblish.api.register_plugin_path(path)
def main(env):
    import pype.hosts.resolve as bmdvr
    # Registers pype's Global pyblish plugins
    pype.install()
    bmdvr.setup(env)