-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommand_exec_node.py
More file actions
45 lines (37 loc) · 1.09 KB
/
Copy pathcommand_exec_node.py
File metadata and controls
45 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import subprocess
class AnyType(str):
def __ne__(self, __value: object) -> bool:
return False
any_typ = AnyType("*")
class CommandExecNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"input": (any_typ,),
"command": ("STRING", {
"multiline": True,
"default": "echo Hello World"
}),
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("output",)
FUNCTION = "run_command"
CATEGORY = "Custom/Utility"
def run_command(self, input, command):
import subprocess
try:
result = subprocess.check_output(
command, shell=True, stderr=subprocess.STDOUT, universal_newlines=True
)
except subprocess.CalledProcessError as e:
result = f"[ERROR] Code {e.returncode}:\n{e.output}"
return (result,)
# Registro do node no ComfyUI
NODE_CLASS_MAPPINGS = {
"CommandExecNode": CommandExecNode
}
NODE_DISPLAY_NAME_MAPPINGS = {
"CommandExecNode": "Terminal"
}