system.util.runPython
Opened this issue · 1 comments
JosephTLockwood commented
Allows users to run complete Python scripts directly from Ignition.
This would allow users to install any Python library on a local computer and pass data.
from java.lang import ProcessBuilder, String
from java.io import File
# Function to run a Python script using the specified file path and arguments
def runPython(python_script_path, python_executable= r'C:\Python\Python311\python.exe', *args):
# Construct the command to execute the Python script
command = [python_executable, python_script_path] + list(args)
# Create a ProcessBuilder with the command
pb = ProcessBuilder(command)
# Start the process
process = pb.start()
# Read the output from the process
output = process.getInputStream().readAllBytes()
# Return the output
return output
I will work on this in my free time; however, I wanted to post it for documentation.
paul-griffith commented
This feels like a specialization of #11, but I'm not against it :)