Skip to content

Commit

Permalink
0.4.1 (#19)
Browse files Browse the repository at this point in the history
* new settings for execution engine

* decide which engine based on settings
  • Loading branch information
sisoe24 authored Feb 18, 2022
1 parent 3e37ec1 commit 021b780
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 96 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.4.1] - 2022-06-18

### Added

* New settings to switch che code execution engine.

## [0.4.0] - 2022-06-17

### Added
Expand All @@ -15,6 +21,10 @@

Under the hood improvements on code execution and some refactoring.

### Changed

* Changed default way to execute code to `executeInMainThread` function.

## [0.2.0] - 2021-10-29

Tests, code refactoring, connection timeouts, various fixes and optimizations.
Expand Down
180 changes: 115 additions & 65 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>

<head>
<title>README.md</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">

<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
Expand All @@ -16,19 +17,57 @@
: 'default'
});
</script>
<h1 id="1-nukeserversocket-readme">Changelog</h1>
<h2>v0.2.0 2021-10-29</h2>
<li>Connections timeouts.</li>
<li>Various fixes and optimizations.</li>
<h1 id="1-nukeserversocket-readme">Changelog</h1>
<h2>v0.4.1 2022-02-18</h2>
<li>Switch code execution engine settings.</li>

<h2>v0.1.0 2021-09-23</h2>
<li>Execute BlinkScript code.</li>
<li>Send/Receive Nodes from another instance.</li>
<li>New About widget.</li>
<li>API now accepts also simple strings when sending a request.</li>
<li>Under the hood optimizations.</li>
<h2>v0.4.0 2022-02-17</h2>
<li>Intercept exceptions inside Nuke's thread to extension output.</li>
<li>Configurable timeout settings.</li>
<li>Display timeout timers in UI.</li>

<h2>v0.3.0 2022-02-06</h2>
<li>Various fixes and optimizations for code execution.</li>

<h2>v0.2.0 2021-10-29</h2>
<li>Connections timeouts.</li>
<li>Various fixes and optimizations.</li>

<h2>v0.1.0 2021-09-23</h2>
<li>Execute BlinkScript code.</li>
<li>Send/Receive Nodes from another instance.</li>
<li>New About widget.</li>
<li>API now accepts also simple strings when sending a request.</li>
<li>Under the hood optimizations.</li>

<h1 id="1-nukeserversocket-readme">1. NukeServerSocket README</h1>
<p><a href="https://github.com/sisoe24/NukeServerSocket/releases"><img
src="https://img.shields.io/github/v/release/sisoe24/NukeServerSocket?label=stable" alt="Main Build"></a>
<a href="https://github.com/sisoe24/NukeServerSocket/releases"><img
src="https://img.shields.io/github/v/release/sisoe24/NukeServerSocket?label=pre-release&amp;include_prereleases"
alt="Pre Release"></a>
<img src="https://img.shields.io/github/last-commit/sisoe24/NukeServerSocket" alt="Last commit">
</p>
<p><a href="https://github.com/sisoe24/NukeServerSocket/issues"><img
src="https://img.shields.io/github/issues/sisoe24/NukeServerSocket" alt="issues"></a>
<a href="https://github.com/sisoe24/NukeServerSocket/pulls"><img
src="https://img.shields.io/github/issues-pr/sisoe24/NukeServerSocket" alt="pull-request"></a>
</p>
<p><a
href="https://www.codacy.com/gh/sisoe24/NukeServerSocket/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=sisoe24/NukeServerSocket&amp;utm_campaign=Badge_Grade"><img
src="https://app.codacy.com/project/badge/Grade/5b59bd7f80c646a8b2b16ad4b8cba599" alt="Codacy Badge"></a>
<a
href="https://www.codacy.com/gh/sisoe24/NukeServerSocket/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=sisoe24/NukeServerSocket&amp;utm_campaign=Badge_Coverage"><img
src="https://app.codacy.com/project/badge/Coverage/5b59bd7f80c646a8b2b16ad4b8cba599" alt="Codacy Badge"></a>
<a href="https://deepsource.io/gh/sisoe24/NukeServerSocket/?ref=repository-badge"><img
src="https://deepsource.io/gh/sisoe24/NukeServerSocket.svg/?label=active+issues&amp;show_trend=true&amp;token=D3BtO5z54YqAh2Fn2pTf9JKB"
alt="DeepSource"></a>
</p>
<p><a href="https://github.com/sisoe24/NukeServerSocket/blob/main/LICENSE"><img
src="https://img.shields.io/github/license/sisoe24/NukeServerSocket" alt="license"></a></p>
<p><img src="https://img.shields.io/badge/Python-2.7.18_|_3.7.7-success" alt="x">
<img src="https://img.shields.io/badge/Nuke-11_|_12_|13-yellow" alt="x">
</p>
<p>A Nuke plugin that will allow code execution from the local network and more.</p>
<ul>
<li><a href="#1-nukeserversocket-readme">1. NukeServerSocket README</a>
Expand All @@ -48,16 +87,16 @@ <h1 id="1-nukeserversocket-readme">1. NukeServerSocket README</h1>
</ul>
</li>
<li><a href="#15-settings">1.5. Settings</a></li>
<li><a href="#16-extendibility">1.6. Extendibility</a>
<li><a href="#16-extendibility">1.6. Extendibility</a></li>
<li><a href="#17-test-plugin-locally">1.7. Test plugin locally</a></li>
<li><a href="#18-known-issues">1.8. Known Issues</a></li>
<li><a href="#19-compatibility">1.9. Compatibility</a></li>
<li><a href="#110-overview">1.10. Overview</a>
<ul>
<li><a href="#161-code-sample">1.6.1. Code Sample</a></li>
<li><a href="#162-port--host-address">1.6.2. Port &amp; Host address</a></li>
<li><a href="#1101-execute-code">1.10.1. Execute Code</a></li>
<li><a href="#1102-send-nodes">1.10.2. Send Nodes</a></li>
</ul>
</li>
<li><a href="#17-known-issues">1.7. Known Issues</a></li>
<li><a href="#18-compatibility">1.8. Compatibility</a></li>
<li><a href="#19-test-plugin-locally">1.9. Test plugin locally</a></li>
<li><a href="#110-overview">1.10. Overview</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -87,79 +126,89 @@ <h2 id="13-installation">1.3. Installation</h2>
</blockquote>
<h2 id="14-usage">1.4. Usage</h2>
<h3 id="141-receive-incoming-request">1.4.1. Receive incoming request</h3>
<p><a href="#1101-execute-code">Demo</a></p>
<p>Open the <em>NukeServerSocket</em> panel and with the mode on <strong>Receiver</strong>, start the server by
clicking <strong>Connect</strong>.</p>
<blockquote>
<p>If you receive a message: &quot;<em>Server did not initiate. Error: The bound address is already in
use</em>&quot;, just change the <strong>Port</strong> to a random number between <code>49152</code> and
<code>65535</code> and try again. It means that probably you have a connection listening on that port already.
Also when connected, you could test the receiver with the <strong>Test Receiver</strong> button, otherwise you are
done.
</p>
Also when connected, you could test the receiver with the <strong>Test Receiver</strong> button.</p>
</blockquote>
<p>When connected, NukeServerSocket will listen for incoming request on the IP Address and Port shown in the plugin.
</p>
<p>Now you can send code from Visual Studio Code with <a
href="https://marketplace.visualstudio.com/items?itemName=virgilsisoe.nuke-tools">Nuke Tools</a> or any other
method you prefer.</p>
<h3 id="142-receivesend-nodes">1.4.2. Receive/Send nodes</h3>
<p><a href="#1102-send-nodes">Demo</a></p>
<h4 id="1421-send">1.4.2.1. Send</h4>
<p>When sending nodes, switch the mode from <strong>Receiver</strong> to <strong>Sender</strong> and be sure that
there is another NukeServerSocket instance listening for incoming network request (<a
href="#141-receive-incoming-request">Receive incoming request</a>). Select the nodes you want to send a click
<strong>Send Selected Nodes</strong>.
</p>
<strong>Send Selected Nodes</strong>.</p>
<blockquote>
<p>By default, the IP Address on the sender points to the local IP address, so if you want to send nodes between the
same computer you should only specify the Port. When sending nodes to another computer you will also need to
specify the IP Address of the NukeServerSocket computer you want the nodes to be sended.</p>
<p>By default, the IP Address on the sender points to the local IP address, so, if you want to send nodes between
the same computer, you should only specify the Port. When sending nodes to another computer, you will also need to
specify the IP Address of the computer you want to send the nodes.</p>
</blockquote>
<h4 id="1422-receive">1.4.2.2. Receive</h4>
<p>When receiving nodes just follow the steps for <a href="#141-receive-incoming-request">Receive incoming request</a>
for the receiving instance and the <a href="#1421-send">Send</a> steps for the sending instances.</p>
for the receiving instance and the <a href="#1421-send">Send</a> steps for the sending instance.</p>
<h2 id="15-settings">1.5. Settings</h2>
<p>The plugin offers some minor settings like output text to internal script editor, format text and so on.</p>
<h2 id="16-extendibility">1.6. Extendibility</h2>
<p>At its core, the plugin is just a server socket that awaits for an incoming request, performs the operations inside
Nuke and returns the result. Nothing ties it to any application per se.</p>
<p>The only requirement is that the code received should be inside a string.</p>
<p>From the client point of view, the code can be sended either inside a <em>stringified</em> associative array or
inside a simple string, with the latter being valid only when sending Python code.</p>
<p>The associative array should have the following keys: <code>text</code> and an optional <code>file</code>.</p>
<p>The settings can be accessed from the plugin toolbar</p>
<ul>
<li><code>text</code>: Must contain the code to be executed as a string.</li>
<li><code>file</code>: Could contain the file path of the script that is being executed.</li>
<li>
<p><strong>Mirror To Script Editor</strong>: Allows to mirror the input/output code to the internal script editor.
</p>
<ul>
<li><strong>Override Output Editor</strong>: Mirror output to the internal script editor.</li>
<li><strong>Format Text</strong>: The script editor output window will received a formatted version of the code
result.</li>
<li><strong>Clear Output</strong>: The script editor output window will clear the code after each execution.
</li>
<li><strong>Show File Path</strong>: The script editor output window will display the full file path of the file
being executed.</li>
<li><strong>Show Unicode</strong>: The script editor output window will display a unicode character `` that
indicates the start of the code execution result.</li>
<li><strong>Override Input Editor</strong>: Mirror input to the internal script editor.</li>
</ul>
</li>
<li>
<p><strong>Timeout</strong>: Terminate the connection when the server is inactive or it wasn't able to establish a
successful connection, in the time specified.</p>
<ul>
<li><strong>Server</strong>: Set the timeout when clicking the <strong>Connect</strong> button. Defaults to
<code>10</code> minutes.</li>
<li><strong>Receiver</strong>: Set the timeout for when clicking the <strong>Test Receiver</strong> button.
Defaults to <code>10</code> seconds.</li>
<li><strong>Send Nodes</strong>: Set the timeout when clicking <strong>Send Nodes</strong> button. Defaults to
<code>30</code> seconds.</li>
</ul>
</li>
</ul>
<p>Although the associative array is optional when executing Python code, it is a requirement when executing
BlinkScript. The key <strong>file</strong> must contain a valid file extension: <code>.cpp</code> or
<code>.blink</code> in order for the plugin to know where to delegate the job.
</p>
<blockquote>
<p>When sending a stringified array, the plugin will try to deserialize it with <code>json.loads()</code>.</p>
</blockquote>
<h3 id="161-code-sample">1.6.1. Code Sample</h3>
<p>Please see <a href="https://github.com/sisoe24/NukeServerSocket#161-code-sample">Github Readme #Code Samples</a>
section for more information.</p>
<h3 id="162-port--host-address">1.6.2. Port &amp; Host address</h3>
<p>NukeServerSocket by default will listen on any host address.</p>
<p>When connecting locally (same computer) you can just specify the local host address (eg.<code>127.0.0.1</code>) in
your socket client code. When connecting from a different computer you also specify the exact IP Address (eg
<code>192.168.1.10</code>).
</p>
<p>The port value is written to <em>.nuke/NukeServerSocket.ini</em> inside the <code>server/port</code> field. Each
time the user changes it, it gets update automatically. If used locally, this can be used from your extension to
pick at which port to connect.</p>
<p>This is pretty much all you need to start your own extension for your favorite text editor or any other method you
prefer.</p>
<p>If you still have some problems, please feel free to reach out for any questions.</p>
<h2 id="17-known-issues">1.7. Known Issues</h2>
<h2 id="16-extendibility">1.6. Extendibility</h2>
<p>At its core, the plugin is just a server socket that awaits for an incoming request,
performs the operations inside Nuke and returns the result. Nothing ties it to any
application per se.</p>
<p>This makes it very easy to implement a new client, without the need to modify NukeServerSocket source code. The
client needs only to send the data at the specified address inside NukeServerSocket.</p>
<p>More information and examples on the <a
href="https://github.com/sisoe24/NukeServerSocket/wiki/Create-custom-client">wiki page</a>.</p>
<h2 id="17-test-plugin-locally">1.7. Test plugin locally</h2>
<p>The plugin can be launched locally outside the Nuke application. This is useful for testing code and implementing
new features more rapidly.</p>
<p>More information on the <a href="https://github.com/sisoe24/NukeServerSocket/wiki/Test-Plugin-locally">wiki
page</a>.</p>
<h2 id="18-known-issues">1.8. Known Issues</h2>
<ul>
<li>Settings window doesn't display the tooltip text.</li>
<li>When changing workspace with an active open connection, Nuke will load a new plugin instance with the default UI
state. This would look as if the previous connection has been closed, where in reality is still open and
listening. The only way to force close all of the connections is to restart Nuke.</li>
listening. One way to force close all of the connections is to restart Nuke, or you can wait for the connection
timeout.</li>
</ul>
<h2 id="18-compatibility">1.8. Compatibility</h2>
<h2 id="19-compatibility">1.9. Compatibility</h2>
<p>Nuke version: 11,12, 13.</p>
<blockquote>
<p>Because Nuke 11 uses an early version of PySide2, future compatibility is not a guarantee.</p>
Expand All @@ -180,12 +229,13 @@ <h2 id="18-compatibility">1.8. Compatibility</h2>
<li>Windows 10</li>
</ul>
<h2 id="110-overview">1.10. Overview</h2>
<h3 id="1101-execute-code">1.10.1. Execute Code</h3>
<img title="Execute Code" src="https://github.com/sisoe24/NukeServerSocket/blob/main/images/execute_code.gif?raw=true"
width="100%" />
<img title="Main Window" src="https://github.com/sisoe24/NukeServerSocket/blob/main/images/main_window.png?raw=true"
width="80%" />
<img title="Settings" src="https://github.com/sisoe24/NukeServerSocket/blob/main/images/settings.png?raw=trueg"
width="30%" />
<h3 id="1102-send-nodes">1.10.2. Send Nodes</h3>
<img title="Send Nodes" src="https://github.com/sisoe24/NukeServerSocket/blob/main/images/send_nodes.gif?raw=true"
width="100%" />

</body>

</html>
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ When receiving nodes just follow the steps for [Receive incoming request](#141-r

The settings can be accessed from the plugin toolbar

- **Code Execution Engine**: Change the engine that is executing the code.
- **Nuke Internal**: Nuke `executeInMainThread` function.
- **Script Editor**: Nuke Script Editor widget.

- **Mirror To Script Editor**: Allows to mirror 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 received a formatted version of the code result.
Expand Down Expand Up @@ -119,6 +123,7 @@ More information on the [wiki page](https://github.com/sisoe24/NukeServerSocket/

## 1.8. Known Issues

- 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.
- When changing workspace with an active open connection, Nuke will load a new plugin instance with the default UI state. This would look as if the previous connection has been closed, where in reality is still open and listening. One way to force close all of the connections is to restart Nuke, or you can wait for the connection timeout.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nukeserversocket"
version = "0.4.0"
version = "0.4.1"
description = ""
authors = ["virgilsisoe <virgilsisoe@gmail.com>"]
packages = [
Expand Down
32 changes: 20 additions & 12 deletions src/controllers/nuke_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,26 @@ def execute(self):
If for some reason execution fails, method will fallback on the script
editor execution mechanism.
"""
try:
self._output = nuke.executeInMainThreadWithResult(
self._exec, self._input)
except Exception: # skipcq: PYL-W0703
err = "executeInMainThread Error. Fallback on ScriptEditor for now."
self.execution_error.emit(err)
LOGGER.error(err)

self.script_editor.set_input(self._input)
self.script_editor.execute()
self._output = self.script_editor.output()
self.script_editor.restore_state()
if AppSettings().get_bool('engine/nuke_internal', True):
try:
self._output = nuke.executeInMainThreadWithResult(
self._exec, self._input)
LOGGER.debug('execute internal')
except Exception: # skipcq: PYL-W0703
err = "executeInMainThread Error. Fallback on ScriptEditor for now."
self.execution_error.emit(err)
LOGGER.error(err)
self._execute_script_editor()
else:
self._execute_script_editor()

def _execute_script_editor(self):
"""Execute code from the internal script editor widget."""
LOGGER.debug('execute script editor')
self.script_editor.set_input(self._input)
self.script_editor.execute()
self._output = self.script_editor.output()
self.script_editor.restore_state()

def output(self): # type: () -> str
"""Get output from the nuke command."""
Expand Down
Loading

0 comments on commit 021b780

Please sign in to comment.