コード例 #1
0
def launch(application):
    """Starts the web server that will be hosted in the Photoshop extension.
    """
    from avalon import api, photoshop

    api.install(photoshop)

    # Launch Photoshop and the html server.
    process = subprocess.Popen(application, stdout=subprocess.PIPE)
    server = html_server.app.start_server(5000)

    # Wait for application launch to show Workfiles.
    if os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", False):
        # Wait for Photoshop launch.
        if photoshop.app():
            workfiles.show(save=False)

    # Wait for Photoshop launch.
    if photoshop.app():
        api.emit("application.launched")

    self.callback_queue = queue.Queue()
    while True:
        main_thread_listen()

    # Wait on Photoshop to close before closing the html server.
    process.wait()
    server.shutdown()
コード例 #2
0
def launch(*subprocess_args):
    """Starts the websocket server that will be hosted
       in the Photoshop extension.
    """
    from avalon import api, photoshop

    api.install(photoshop)
    sys.excepthook = safe_excepthook
    # Launch Photoshop and the websocket server.
    process = subprocess.Popen(subprocess_args, stdout=subprocess.PIPE)

    websocket_server = WebServerTool()
    # Add Websocket route
    websocket_server.add_route("*", "/ws/", WebSocketAsync)
    # Add after effects route to websocket handler
    route_name = 'Photoshop'
    print("Adding {} route".format(route_name))
    WebSocketAsync.add_route(
        route_name,
        PhotoshopRoute  # keep same name as in extension
    )
    websocket_server.start_server()

    while True:
        if process.poll() is not None:
            print("Photoshop process is not alive. Exiting")
            websocket_server.stop()
            sys.exit(1)
        try:
            _stub = photoshop.stub()
            if _stub:
                break
        except Exception:
            time.sleep(0.5)

    # Wait for application launch to show Workfiles.
    if os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", True):
        if os.getenv("WORKFILES_SAVE_AS"):
            workfiles.show(save=False)
        else:
            workfiles.show()

    # Photoshop could be closed immediately, withou workfile selection
    try:
        if photoshop.stub():
            api.emit("application.launched")

        self.callback_queue = queue.Queue()
        while True:
            main_thread_listen(process, websocket_server)

    except ConnectionNotEstablishedYet:
        pass
    finally:
        # Wait on Photoshop to close before closing the websocket server
        process.wait()
        websocket_server.stop()
コード例 #3
0
ファイル: lib.py プロジェクト: kalisp/avalon-core
def launch(application_path):
    """Setup for Storyboard Pro launch."""
    from avalon import api, storyboardpro, toonboom

    api.install(storyboardpro)

    toonboom.launch(
        application_path,
        os.path.join(os.path.dirname(__file__), "temp.zip")
    )
コード例 #4
0
def main(env):
    import openpype.hosts.resolve as bmdvr
    # Registers openpype's Global pyblish plugins
    openpype.install()

    # activate resolve from openpype
    avalon.install(bmdvr)

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

    bmdvr.launch_pype_menu()
コード例 #5
0
def main(launch_args):
    # Be sure server won't crash at any moment but just print traceback
    sys.excepthook = safe_excepthook

    # Create QtApplication for tools
    # - QApplicaiton is also main thread/event loop of the server
    qt_app = QtWidgets.QApplication([])

    # Execute pipeline installation
    api.install(tvpaint)

    # Create Communicator object and trigger launch
    # - this must be done before anything is processed
    communicator = CommunicationWrapper.create_communicator(qt_app)
    communicator.launch(launch_args)

    def process_in_main_thread():
        """Execution of `MainThreadItem`."""
        item = communicator.main_thread_listen()
        if item:
            item.execute()

    timer = QtCore.QTimer()
    timer.setInterval(100)
    timer.timeout.connect(process_in_main_thread)
    timer.start()

    # Register terminal signal handler
    def signal_handler(*_args):
        print("You pressed Ctrl+C. Process ended.")
        communicator.stop()

    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)

    qt_app.setQuitOnLastWindowClosed(False)
    qt_app.setStyleSheet(style.load_stylesheet())

    # Load avalon icon
    icon_path = get_icon_path()
    if icon_path:
        icon = QtGui.QIcon(icon_path)
        qt_app.setWindowIcon(icon)

    # Set application name to be able show application icon in task bar
    if platform.system().lower() == "windows":
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
            u"WebsocketServer")

    # Run Qt application event processing
    sys.exit(qt_app.exec_())
コード例 #6
0
def publish(paths, gui=False):
    """Publish rendered image sequences based on the job data

    Args:
        paths (list): a list of paths where to publish from
        gui (bool, Optional): Choose to show Pyblish GUI, default is False

    Returns:
        None

    """

    assert isinstance(paths, (list, tuple)), "Must be list of paths"
    log.info(paths)
    assert any(paths), "No paths found in the list"
    # Set the paths to publish for the collector if any provided
    if paths:
        os.environ["FILESEQUENCE"] = os.pathsep.join(paths)

    # Install Avalon with shell as current host
    from avalon import api, shell
    api.install(shell)

    # Register target and host
    import pyblish.api
    pyblish.api.register_target("filesequence")
    pyblish.api.register_host("shell")

    # Publish items
    if gui:
        import pyblish_qml
        pyblish_qml.show(modal=True)
    else:

        import pyblish.util
        context = pyblish.util.publish()

        if not context:
            log.warning("Nothing collected.")
            sys.exit(1)

        # Collect errors, {plugin name: error}
        error_results = [r for r in context.data["results"] if r["error"]]

        if error_results:
            log.error(" Errors occurred ...")
            for result in error_results:
                log.error(error_format.format(**result))
            sys.exit(2)
コード例 #7
0
    def launch(self, launch_args):
        """Prepare all required data and launch host.

        First is prepared websocket server as communication point for host,
        when server is ready to use host is launched as subprocess.
        """
        log.info("Installing TVPaint implementation")
        api.install(tvpaint)

        if platform.system().lower() == "windows":
            self._prepare_windows_plugin(launch_args)

        # Launch TVPaint and the websocket server.
        log.info("Launching TVPaint")
        self.websocket_server = WebSocketServer()
        self.websocket_rpc = TVPaintRpc(self, loop=self.websocket_server.loop)

        os.environ["WEBSOCKET_URL"] = "ws://localhost:{}".format(
            self.websocket_server.port)
        self.websocket_server.add_route("*", "/",
                                        self.websocket_rpc.handle_request)
        log.info("Added request handler for url: {}".format(
            os.environ["WEBSOCKET_URL"]))

        self.websocket_server.start()
        # Make sure RPC is using same loop as websocket server
        while not self.websocket_server.server_is_running:
            time.sleep(0.1)

        # Start TVPaint when server is running
        self._launch_tv_paint(launch_args)

        log.info("Waiting for client connection")
        while True:
            if self.process.poll() is not None:
                log.debug("Host process is not alive. Exiting")
                self.websocket_server.stop()
                self.qt_app.quit()
                return

            if self.websocket_rpc.client_connected():
                log.info("Client has connected")
                break
            time.sleep(0.5)

        self.on_client_connect()

        api.emit("application.launched")
コード例 #8
0
def launch(application):
    """Starts the web server that will be hosted in the Photoshop extension.
    """
    from avalon import api, photoshop

    api.install(photoshop)
    sys.excepthook = safe_excepthook

    # Launch Photoshop and the html server.
    process = subprocess.Popen(application, stdout=subprocess.PIPE)
    server = html_server.app.start_server(5000)

    while True:
        if process.poll() is not None:
            print("Photoshop process is not alive. Exiting")
            server.shutdown()
            sys.exit(1)
        try:
            _app = photoshop.app()
            if _app:
                break
        except Exception:
            time.sleep(0.1)

    # Wait for application launch to show Workfiles.
    if os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", False):
        # Wait for Photoshop launch.
        if photoshop.app():
            workfiles.show(save=False)

    # Wait for Photoshop launch.
    if photoshop.app():
        api.emit("application.launched")

    self.callback_queue = queue.Queue()
    while True:
        main_thread_listen()

    # Wait on Photoshop to close before closing the html server.
    process.wait()
    server.shutdown()
コード例 #9
0
ファイル: lib.py プロジェクト: jrsndl/avalon-core
def launch(*subprocess_args):
    """Starts the websocket server that will be hosted
       in the Photoshop extension.
    """
    from avalon import api, photoshop

    api.install(photoshop)
    sys.excepthook = safe_excepthook
    # Launch Photoshop and the websocket server.
    ConsoleTrayApp.process = subprocess.Popen(
        subprocess_args,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL
    )

    websocket_server = WebServerTool()
    route_name = 'Photoshop'
    if websocket_server.port_occupied(websocket_server.host_name,
                                      websocket_server.port):
        log.info("Server already running, sending actual context and exit")
        asyncio.run(websocket_server.send_context_change(route_name))
        sys.exit(1)

    # Add Websocket route
    websocket_server.add_route("*", "/ws/", WebSocketAsync)
    # Add after effects route to websocket handler

    print("Adding {} route".format(route_name))
    WebSocketAsync.add_route(
        route_name, PhotoshopRoute  # keep same name as in extension
    )
    websocket_server.start_server()

    ConsoleTrayApp.websocket_server = websocket_server

    if os.environ.get("AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH", True):
        save = False
        if os.getenv("WORKFILES_SAVE_AS"):
            save = True

        ConsoleTrayApp.execute_in_main_thread(lambda: workfiles.show(save))
コード例 #10
0
ファイル: lib.py プロジェクト: ldunham1/pype
def reload_pipeline():
    """Attempt to reload pipeline at run-time.

    CAUTION: This is primarily for development and debugging purposes.

    """

    import importlib
    import pype.hosts.premiere

    api.uninstall()

    for module in ("avalon.io", "avalon.lib", "avalon.pipeline", "avalon.api",
                   "avalon.tools", "{}".format(AVALON_CONFIG),
                   "{}.premiere".format(AVALON_CONFIG),
                   "{}.premiere.lib".format(AVALON_CONFIG)):
        log.info("Reloading module: {}...".format(module))
        try:
            module = importlib.import_module(module)
            importlib.reload(module)
        except Exception as e:
            log.warning("Cannot reload module: {}".format(e))

    api.install(pype.hosts.premiere)
コード例 #11
0
    update_frame_range(current_comp, representations)

    current_comp.Save(comp_path)

    return comp_path


if __name__ == '__main__':

    import argparse

    parser = argparse.ArgumentParser(description="Switch to a shot within an"
                                     "existing comp file")

    parser.add_argument("--file_path",
                        type=str,
                        default=True,
                        help="File path of the comp to use")

    parser.add_argument("--asset_name",
                        type=str,
                        default=True,
                        help="Name of the asset (shot) to switch")

    args, unknown = parser.parse_args()

    api.install(avalon.fusion)
    switch(args.asset_name, args.file_path)

    sys.exit(0)
コード例 #12
0
ファイル: 123.py プロジェクト: 3dzayn/pype
def main():
    print("Installing OpenPype ...")
    api.install(houdini)
コード例 #13
0
ファイル: avalon_setup.py プロジェクト: kalisp/avalon-core
def register():
    """Register Avalon with Blender."""
    print("Registering Avalon...")
    api.install(blender)
コード例 #14
0
def main():
    print("Installing Avalon ...")
    api.install(houdini)
コード例 #15
0
import unreal

avalon_detected = True
try:
    from avalon import api
    from avalon import unreal as avalon_unreal
except ImportError as exc:
    avalon_detected = False
    unreal.log_error("Avalon: cannot load avalon [ {} ]".format(exc))

if avalon_detected:
    api.install(avalon_unreal)


@unreal.uclass()
class AvalonIntegration(unreal.AvalonPythonBridge):

    @unreal.ufunction(override=True)
    def RunInPython_Create(self):
        unreal.log_warning("Avalon: showing creator window")
        if avalon_detected:
            avalon_unreal.show_creator()

    @unreal.ufunction(override=True)
    def RunInPython_Load(self):
        unreal.log_warning("Avalon: showing loader window")
        if avalon_detected:
            avalon_unreal.show_loader()

    @unreal.ufunction(override=True)
    def RunInPython_Publish(self):
コード例 #16
0
 def __init__(self):
     super(ThisTestGUI, self).__init__()
     # Registers openpype's Global pyblish plugins
     openpype.install()
     # activate resolve from openpype
     avalon.install(bmdvr)
コード例 #17
0
ファイル: userSetup.py プロジェクト: kalisp/avalon-core
from avalon import api, maya
api.install(maya)
コード例 #18
0
ファイル: app.py プロジェクト: aardschok/filepublisher
    def install(self):
        """Ensure the plugins have been registered together with a host name"""

        import avalon.shell
        api.install(avalon.shell)
        pyblish.api.register_host("shell")