Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sisoe24/1.1.0 #33

Merged
merged 35 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b482fb0
Refactor local app controller layout
sisoe24 Aug 17, 2024
1680939
Closes #31
sisoe24 Aug 18, 2024
38b97ac
Closes #32
sisoe24 Aug 18, 2024
4661bb3
Update tests for received data
sisoe24 Aug 18, 2024
73e8349
Update readme
sisoe24 Aug 18, 2024
8263276
Add colors to log level
sisoe24 Aug 18, 2024
b3cb843
Refactor console write method to replace spaces with non-breaking spaces
sisoe24 Aug 18, 2024
848a532
Update console font based on platform
sisoe24 Aug 18, 2024
bf8c401
Remove unused import statement and skip "version.py" in isort configu…
sisoe24 Aug 18, 2024
4bd452d
Refactor build script and add release functionality
sisoe24 Aug 18, 2024
1a1f0a8
Refactor build script to use new release_manager module
sisoe24 Aug 18, 2024
f604388
Move module to scripts folder
sisoe24 Aug 18, 2024
a1c7f4e
Fix path typo
sisoe24 Aug 18, 2024
0b52b5d
trigger GitHub actions
sisoe24 Aug 18, 2024
55aa7f7
trigger GitHub actions
sisoe24 Aug 18, 2024
bbfe499
trigger GitHub actions
sisoe24 Aug 18, 2024
22b678a
trigger GitHub actions
sisoe24 Aug 18, 2024
894bb61
Update changelog
sisoe24 Aug 18, 2024
3302ef6
trigger GitHub actions
sisoe24 Aug 18, 2024
a74d578
Update tox file
sisoe24 Aug 18, 2024
04ad9d4
Update tox file
sisoe24 Aug 18, 2024
b92c2ec
chore: Update pyside2 dependency to version 5.15.2.1
sisoe24 Aug 18, 2024
fc097de
Update tox file and GitHub Actions configuration
sisoe24 Aug 18, 2024
3e00c58
Update variable names in test files for consistency
sisoe24 Aug 18, 2024
b3e21f9
Debugging actions
sisoe24 Aug 18, 2024
586780b
chore: Add root path to sys.path in conftest.py
sisoe24 Aug 18, 2024
f8a42e2
Refactor conftest
sisoe24 Aug 18, 2024
c04549e
Update test files function name
sisoe24 Aug 20, 2024
07778f5
Update GitHub Actions configuration and tox file
sisoe24 Aug 20, 2024
1a1b1ff
trigger GitHub actions
sisoe24 Aug 20, 2024
eea124c
Merge branch 'main' into sisoe24/1.1.0
sisoe24 Aug 20, 2024
b78859f
Merge branch 'main' into sisoe24/1.1.0
sisoe24 Aug 21, 2024
089df42
Bump version to 1.1.0 in version.py and pyproject.toml
sisoe24 Aug 21, 2024
63cc611
Fix issue with logs font not using proper monospace font
sisoe24 Aug 21, 2024
8d8504c
trigger GitHub actions
sisoe24 Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [1.1.0] - 2024-08-18

### Added

* Added color to logs

### Fixed

* [[#30](https://github.com/sisoe24/nukeserversocket/issues/30)]
* [#31](https://github.com/sisoe24/nukeserversocket/issues/31)
* [#32](https://github.com/sisoe24/nukeserversocket/issues/32)
* Logs font now use proper monospace font

## [1.0.0] - 2023-11-19

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@ For a full list of changes, see the [CHANGELOG](https://github.com/sisoe24/nukes
Client applications that use nukeserversocket:

- [Nuke Tools](https://marketplace.visualstudio.com/items?itemName=virgilsisoe.nuke-tools) - Visual Studio Code extension.
- [nuketools.nvim](https://github.com/sisoe24/nuketools.nvim) - Neovim plugin.
- [Nuke Tools ST](https://packagecontrol.io/packages/NukeToolsST) - Sublime Text package.
- [DCC WebSocket](https://marketplace.visualstudio.com/items?itemName=virgilsisoe.dcc-websocket) - Visual Studio Code Web extension (deprecated at the moment).

### 1.3.1. Create a custom client

You can create a custom client in any programming language that supports socket communication. The client sends the code to the server, which then executes it in Nuke and sends back the result. For more information, see the [wiki page](https://github.com/sisoe24/nukeserversocket/wiki/Client-Applications-for-NukeServerSocket)

```py
# ... your socket code
data = {
"text": "print([n.name() for n in nuke.allNodes()])",
"file" : "path/to/file.py",
"formatText": "0"
}
s.sendall(bytearray(json.dumps(data), 'utf-8'))
data = s.recv(1024)
s.close()

nodes = json.loads(data.decode('utf-8').replace("'", '"'))
for node in nodes:
print(node)
```

## 1.4. Installation

1. Download the repository via the [releases page](https://github.com/sisoe24/nukeserversocket/releases) or by cloning it from GitHub.
Expand Down
26 changes: 22 additions & 4 deletions nukeserversocket/console.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
from __future__ import annotations

import sys
import logging

from PySide2.QtCore import Slot
from PySide2.QtWidgets import (QCheckBox, QGroupBox, QHBoxLayout, QPushButton,
QVBoxLayout, QPlainTextEdit)

from .utils import cache
from .logger import get_logger

LOGGER = get_logger()

LOG_COLORS = {
'DEBUG': 'aqua',
'INFO': 'white',
'WARNING': 'orange',
'ERROR': 'red',
'CRITICAL': 'magenta',
}


class NssConsole(QGroupBox):
def __init__(self, parent=None):
super().__init__(parent, title='Logs')

self._console = QPlainTextEdit()
self._console.setStyleSheet('font-family: menlo;')

if sys.platform == 'darwin':
font = 'menlo'
elif sys.platform == 'win32':
font = 'consolas'
else:
font = 'monospace'

self._console.setStyleSheet(f'font-family: {font};')
self._console.setReadOnly(True)
self._console.setLineWrapMode(QPlainTextEdit.NoWrap)

Expand Down Expand Up @@ -50,8 +66,10 @@ def __init__(self, parent=None):
def _on_enable_debug(self, state: int) -> None:
LOGGER.console.setLevel(logging.DEBUG if state == 2 else logging.INFO)

def write(self, text: str) -> None:
self._console.insertPlainText(text)
def write(self, text: str, level_name: str = 'INFO') -> None:
color = LOG_COLORS.get(level_name, 'white')
text = text.replace(' ', ' ')
self._console.appendHtml(f'<font color="{color}">{text}</font>')
self._console.verticalScrollBar().setValue(
self._console.verticalScrollBar().maximum()
)
27 changes: 22 additions & 5 deletions nukeserversocket/controllers/local_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from __future__ import annotations

import sys
import traceback

from PySide2.QtWidgets import (QLabel, QTextEdit, QPushButton, QApplication,
from PySide2.QtWidgets import (QLabel, QWidget, QTextEdit, QHBoxLayout,
QPushButton, QSizePolicy, QApplication,
QPlainTextEdit)

from ..main import NukeServerSocket
Expand All @@ -19,8 +21,12 @@ class LocalController(EditorController):
def __init__(self):
super().__init__()
self._input_editor = QPlainTextEdit()
self._input_editor.setPlaceholderText('Enter your code here...')
self._input_editor.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)

self._output_editor = QTextEdit()
self._output_editor.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)
self._output_editor.setPlaceholderText('Output will be shown here...')
self._output_editor.setReadOnly(True)

@property
Expand All @@ -33,8 +39,13 @@ def output_editor(self) -> QTextEdit:

def execute(self) -> None:
with stdoutIO() as s:
exec(self.input_editor.toPlainText())
result = s.getvalue()
try:
exec(self.input_editor.toPlainText())
except Exception:
result = traceback.format_exc()
else:
result = s.getvalue()

self.output_editor.setPlainText(result)


Expand All @@ -46,10 +57,16 @@ def __init__(self):
run_button.clicked.connect(self.editor.execute)
run_button.setShortcut('Ctrl+R')

lower_layout = QHBoxLayout()
lower_layout.addWidget(self.editor.input_editor)
lower_layout.addWidget(self.editor.output_editor)

lower_widget = QWidget()
lower_widget.setLayout(lower_layout)

main_layout = self.view.layout()
main_layout.addWidget(QLabel('<h3>Local Editor</h3>'))
main_layout.addWidget(self.editor.output_editor)
main_layout.addWidget(self.editor.input_editor)
main_layout.addWidget(lower_widget)
main_layout.addWidget(run_button)


Expand Down
2 changes: 1 addition & 1 deletion nukeserversocket/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, console: NssConsole) -> None:
self._console = console

def emit(self, record: logging.LogRecord) -> None:
self._console.write(self.format(record) + '\n')
self._console.write(self.format(record) + '\n', record.levelname)


def _file_handler() -> TimedRotatingFileHandler:
Expand Down
14 changes: 10 additions & 4 deletions nukeserversocket/received_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def __post_init__(self):
self.data.setdefault('file', '')
self.data.setdefault('formatText', '1')
except Exception as e:
LOGGER.error(
f'Nukeserversocket: An exception occurred while decoding the data. {e}'
)
LOGGER.error(f'An exception occurred while decoding the data. {e}')
self.data = {'text': '', 'file': '', 'formatText': '1'}

LOGGER.debug('Received data: %s', self.data)
Expand All @@ -49,4 +47,12 @@ def __post_init__(self):
LOGGER.critical('Data does not contain a text field.')

self.file = self.data['file']
self.format_text = bool(int(self.data['formatText']))

try:
self.format_text = bool(int(self.data['formatText']))
except ValueError:
LOGGER.error(
'formatText must be either "0" or "1". Got "%s". Fallback to "1".',
self.data['formatText']
)
self.format_text = True
4 changes: 1 addition & 3 deletions nukeserversocket/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from __future__ import annotations

__version__ = '1.0.0'
__version__ = '1.1.0'
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[tool.poetry]
name = "nukeserversocket"
version = "1.0.0"
version = "1.1.0"
description = "A Nuke plugin that will allow code execution from the local network via TCP/WebSocket connections and more."
authors = ["virgilsisoe <[email protected]>"]

[tool.poetry.scripts]
nukeserversocket = "nukeserversocket.controllers.local_app:main"
build = "release_manager:build"
build = "scripts.release_manager:main"

[tool.isort]
skip = ["__init__.py"]
skip = ["__init__.py" , "version.py"]
length_sort = true
add_imports = "from __future__ import annotations"

Expand Down Expand Up @@ -38,9 +38,9 @@ addopts = [

[tool.poetry.dependencies]
python = ">=3.7.7,<3.11"
pyside2 = "5.15.2.1"

[tool.poetry.group.dev.dependencies]
pyside2 = "5.15.2.1"
pytest = "^7.4.3"
tox = "4.8.0"
pytest-qt = "^4.2.0"
Expand Down
61 changes: 0 additions & 61 deletions release_manager.py

This file was deleted.

Loading