Files
Isulion-ComfyUI_Isulion/Core_Nodes/shutdown_node.py
T
2026-07-29 20:10:42 +02:00

59 lines
1.6 KiB
Python

import os
import subprocess
class ShutdownNode:
"""
A node that will shutdown the computer.
Requires explicit confirmation to prevent accidental shutdowns.
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"any": ("*",),
"confirm": ("BOOLEAN", {
"default": False,
"label": "Confirm shutdown"
}),
"delay": ("INT", {
"default": 30,
"min": 0,
"display": "number"
})
}
}
RETURN_TYPES = ()
FUNCTION = "shutdown_computer"
CATEGORY = "utils"
OUTPUT_NODE = True
def shutdown_computer(self, any, confirm, delay):
if not confirm:
print("[ShutdownNode] Aborted: confirmation not checked.")
return ()
try:
if os.name == 'nt': # Windows
os.system(f'shutdown /s /f /t {delay}')
else: # Linux/Unix
minutes = max(1, round(delay / 60)) # Convert seconds to minutes, minimum 1 minute
os.system(f'shutdown -h +{minutes}')
print(f"Shutdown command initiated. Computer will shutdown in {delay} seconds.")
except Exception as e:
print(f"Error initiating shutdown: {str(e)}")
return ()
NODE_CLASS_MAPPINGS = {
"💤 IsulionShutdown": ShutdownNode
}
NODE_DISPLAY_NAME_MAPPINGS = {
"💤 IsulionShutdown": "💤 Isulion Shutdown"
}