NukeServerSocket v1.6


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Virgil Sisoe
A Nuke plugin to run code from external applications.
Requirements:
14.0, 13.2, 13.1, 12.2, 11.3 or later
Linux, Mac, Windows
13 Mar 2023
225

1. NukeServerSocket README

Main Build Pre Release Last commit

issues pull-request

Codacy Badge Codacy Badge DeepSource

license

x x


Changelog

v0.6.0 2023-03-12

  • Fixed Nuke 14 compatibility issues by removing WebSocket connection.
  • Switchable log panels.
  • Under the hood refactoring.

A Nuke plugin to run code from external applications.

1.1. Features

  • Receive Python or BlinkScript code from any client in your local network. (More on Extendibility)
  • Connect more than one client to the same Nuke instance.
  • Receive/Send nodes from another Nuke instance in your local network.
  • WebSocket-ready for browser-based text editors.

    Note: WebSocket connection does not work in Nuke 14.

1.2. Client applications

Client applications that use NukeServerSocket:

1.3. Installation

  1. Download the repository via the releases page or by cloning it from GitHub.
  2. Place the folder inside the ~/.nuke directory or into a custom one.
  3. Write import NukeServerSocket into your menu.py.

NOTES

  • If you use a custom plugin path, add the path in your init.py: nuke.pluginAddPath('custom/path')
  • The folder name must be named NukeServerSocket.
  • If you use Nuke Tools, use the command Nuke Tools: Add NukeServerSocket.

1.4. Usage

1.4.1. Execute code

Execute Code

  1. Open the NukeServerSocket panel inside Nuke, and with the mode on Receiver, start the server by clicking Connect.
  2. You can now send code from Visual Studio Code with Nuke Tools or any other method you prefer.

NOTES:

  • You can troubleshoot the connection by using the Test Receiver button.
  • If you receive a message: 'Server did not initiate. Error: The bound address is already in use', change the port to a random number between 49152 and 65535 and try again. It probably means that you have a connection listening on that port already.

1.4.2. Receive/Send nodes

Send Nodes

  • Receive nodes

    When receiving nodes, start the server with the mode on Receiver.

  • Sending nodes

    1. Switch the mode from Receiver to Sender and be sure that there is another NukeServerSocket instance listening for incoming network requests.
    2. Select the nodes you wish to send a click Send Selected Nodes.

NOTES:

  • When sending nodes to the same computer, only the Port value must match the two Nuke instances.
  • When sending nodes between different computers, both IP Address and Port must match the two Nuke instances.

1.5. Settings

You access the settings from the plugin toolbar.

  • Code Execution Engine: Change the engine that will executing the code.

    • Nuke Internal: Nuke executeInMainThread function. [Default]
    • Script Editor: Nuke Script Editor widget.

    Why use one over the other?

    • Nuke Internal is a more direct and fast approach, but it uses exec under the hood, which might cause some issues.
    • Nuke Script Editor its a safer approach overall but it does require slightly more work behind scene.
  • Connection Type: Change the internal connection protocol for the client-server (Not present in Nuke 14, which defaults to TCP).

    • TCP: The default type of connection. If unsure, use this. [Default]
    • WebSocket: This allows a two-way interactive communication session between the user's browser and the internal server. Use this when using a browser-based text editor.
  • Mirror To Script Editor: Allows mirroring the input/output code to the internal script editor.

    • Override Output Editor: Mirror output to the internal script editor.
    • Format Text: The script editor output window will receive a formatted version of the code result.
    • Clear Output: The script editor output window will clear the code after each execution.
    • Show File Path: The script editor output window will display the full path for the executed file.
    • Show Unicode: The script editor output window will display a Unicode character `` that indicates the start of the code execution result.
    • Override Input Editor: Mirror input to the internal script editor.
  • Timeout: Terminate the connection when the Server is inactive or did not establish a successful contact in the time specified.

    • Server: Set the Timeout when clicking the Connect button. The default value is 10 minutes.
    • Receiver: Set the Timeout for when clicking the Test Receiver button. The default value is 10 seconds.
    • Send Nodes: Set the Timeout when clicking Send Nodes button. The default value is 30 seconds.

1.6. Extendibility

At its core, the plugin is just a server socket that waits for an incoming request, performs the operations inside Nuke, and returns the result. Nothing ties it to any application per se.

This makes it very easy to implement a new client, without the need to modify the NukeServerSocket source code. The client needs only to send the data at the specified address inside NukeServerSocket.

You can find more information and examples on the wiki page.

1.7. Test plugin locally

You can run the plugin locally outside the Nuke application. This method is handy for testing code and implementing new features faster.

You can find more information and examples on the wiki page.

1.8. Known Issues

  • Nuke 14 does not ship with QWebSocket module so the WebSocket connection is not enabled.
  • Creating a modal window with the Nuke internal code execution engine will cause Nuke to freeze. A workaround is to switch to the Script Editor engine.
  • Settings window doesn't display the tooltip text.
  • Changing workspace with an active open connection makes Nuke load a new plugin instance with the default UI state. So it would look as if the previous connection has been closed, whereas in reality is still open and listening. To force close all of the listening connections, you can:
    • Restart the Nuke instance.
    • Wait for the connection timeout.

1.9. Compatibility

Nuke version: 11,12, 13, 14

Because Nuke 11 uses an early version of PySide2, future compatibility is not a guarantee.

While it should work the same on all platforms, I have tested the plugin only on:

  • Linux:
    • CentOS 8
  • macOS:
    • Mojave 10.14.06
    • Catalina 10.15.07
    • Monterey 12.6.3
  • Windows 10
MIT License Copyright (c) 2021 Virgil Sisoe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please login in order to download these files.

Comments   

 
0 # mani di 2021-08-01 09:45
Amazing stuff! Thank you!

note: you have a misspell a bit github link (colon missing)
 
 
0 # sankara rao potnuru 2022-01-23 19:51
Very useful, Thank you.
 
 
0 # Johan Alfort 2023-01-10 11:52
Hi, just wondering if this is getting Nuke 14 support as it seems to be broken. loads of errors in the terminal:

Traceback (most recent call last):
File "C:/Users/[Hidd en]/.nuke/menu. py", line 2, in
import NukeServerSocke t
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
File "C:\Users/[Hidden]/.nuke\NukeServerSocke t\__init__.py", line 2, in
from . import src
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
File "C:\Users/[Hidden]/.nuke\NukeServerSocke t\src\__init__.py", line 15, in
from . import main
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
File "C:\Users/[Hidden]/.nuke\NukeServerSocke t\src\main.py", line 16, in
from .connection import QServer, SendTestClient, SendNodesClient
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
File "C:\Users/[Hidden]/.nuke\NukeServerSocke t\src\connection\__init__.py", line 3, in
from .nss_server import QServer
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
File "C:\Users/[Hidden]/.nuke\NukeServerSocke t\src\connection\nss_server.py", line 8, in
from PySide2.QtWebSo ckets import QWebSocketServe r
File "C:\Program Files\Nuke14.0v 1\pythonextensi ons\site-packag es\shiboken2\fi les.dir\shiboke nsupport\__feat ure__.py", line 142, in _import
return original_import (name, *args, **kwargs)
ModuleNotFoundError: No module named 'PySide2.QtWebSo ckets'


Or is there a way to bypass this?
Thanks!
 
 
0 # Michael McReynolds 2023-03-07 20:33
Quoting Johan Alfort:

Or is there a way to bypass this?


It looks like it's trying to load the QtWebSockets module, which for some reason, doesn't exist in Nuke 14's PySide.

If you don't need a websocket, which I am guessing you don't if you aren't interacting through a browser based text editor (you are using either VSCode or Sublime), you can simply turn all those parts off.

It looks like websockets is just used in 3 files : nss_client, nss_server, nss_socket

Just go in there and comment out or delete the import at the top of all three files since QtWebSockets doesn't exist to import.

from PySide2.QtWebSo ckets import QWebSocket

and then you have to make sure to deal with QWebSocket everywhere it's mentioned.

Twice it's returned so just return None instead

return QWebSocket()

and

return QWebSocketServe r('NukeServerSo cket', QWebSocketServer.NonSecureMode)

to

return None

and set the possibility of it trying to use a websocket to False
in nss_socket.py

self.is_websock et = isinstance(self .socket, QWebSocket)

to this

self.is_websock et = False

Save up your files and you should be back in business. That is as long as you aren't using web based editing.
Cheers!
 
 
0 # Virgil Sisoe 2023-03-13 15:40
Quoting Michael McReynolds:
Quoting Johan Alfort:

Or is there a way to bypass this?


It looks like it's trying to load the QtWebSockets module, which for some reason, doesn't exist in Nuke 14's PySide.

If you don't need a websocket, which I am guessing you don't if you aren't interacting through a browser based text editor (you are using either VSCode or Sublime), you can simply turn all those parts off.

It looks like websockets is just used in 3 files : nss_client, nss_server, nss_socket

Just go in there and comment out or delete the import at the top of all three files since QtWebSockets doesn't exist to import.

from PySide2.QtWebSockets import QWebSocket

and then you have to make sure to deal with QWebSocket everywhere it's mentioned.

Twice it's returned so just return None instead

return QWebSocket()

and

return QWebSocketServer('NukeServerSocket', QWebSocketServer.NonSecureMode)

to

return None

and set the possibility of it trying to use a websocket to False
in nss_socket.py

self.is_websocket = isinstance(self.socket, QWebSocket)

to this

self.is_websocket = False

Save up your files and you should be back in business. That is as long as you aren't using web based editing.
Cheers!


Michael, thanks for taking out the time to help others. You are more than welcome to open a pull request next time you find a solution to a problem.
 
 
0 # Virgil Sisoe 2023-03-13 15:36
Those issues are now gone in the new update. If you have any other problem, please open an issue on the GitHub repository, as Nukepedia does not notify me about those posts.
 

You have no rights to post comments

We have 4178 guests and 110 members online