You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any chance you are able to incorporate Python execution into the mix on the plugin? I ask because I have a large library of python code that usually I install to the machines manually, but would love to be able to use your plugin to execute the python code directly via input or upload of the python script file.
Any chance you could do this for me?
Thanks,
SomeGuru
Some random code like stuff I was thinking on, but couldn't implement. I also wrote for Ubuntu, but need it universal for all OSes like Windows, Apple, Linux (distros RHEL, Debian, etc).
import os
import subprocess
def executePythonScript(mesh, params):
# Check if Python is installed on the agent system
pythonCheck = subprocess.run(["python", "--version"], stdout=subprocess.PIPE)
if pythonCheck.returncode != 0:
# Python is not installed on the agent system, so we will install it
print("Python is not installed on the agent system. Installing...")
subprocess.run(["apt-get", "install", "-y", "python3"])
# Check if the required Python dependencies are present
# Replace "dependency1" and "dependency2" with the actual dependencies needed
dependencyCheck = subprocess.run(["pip3", "show", "dependency1"], stdout=subprocess.PIPE)
if dependencyCheck.returncode != 0:
# Dependency1 is not installed, so we will install it
print("Dependency1 is not installed. Installing...")
subprocess.run(["pip3", "install", "dependency1"])
dependencyCheck = subprocess.run(["pip3", "show", "dependency2"], stdout=subprocess.PIPE)
if dependencyCheck.returncode != 0:
# Dependency2 is not installed, so we will install it
print("Dependency2 is not installed. Installing...")
subprocess.run(["pip3", "install", "dependency2"])
# Check if a Python file or text input was provided
if "pythonFile" in params:
# A Python file was provided, so we will execute it
print("Executing Python file...")
subprocess.run(["python3", params["pythonFile"]])
else:
# No Python file was provided, so we will accept text input in a console window
print("Enter Python code to be executed:")
code = input()
print("Executing Python code...")
subprocess.run(["python3", "-c", code])
To use this plugin, the user can call the "executePythonScript" RPC method and pass in the parameters "pythonFile" (optional) and "text" (optional). If "pythonFile" is provided, the plugin will execute the specified Python file. If "text" is provided, the plugin will execute the provided Python code. If neither is provided, the plugin will accept text input in a console window.
The text was updated successfully, but these errors were encountered:
Hi Ryan,
Any chance you are able to incorporate Python execution into the mix on the plugin? I ask because I have a large library of python code that usually I install to the machines manually, but would love to be able to use your plugin to execute the python code directly via input or upload of the python script file.
Any chance you could do this for me?
Thanks,
SomeGuru
Some random code like stuff I was thinking on, but couldn't implement. I also wrote for Ubuntu, but need it universal for all OSes like Windows, Apple, Linux (distros RHEL, Debian, etc).
with a registration of the plugin via:
To use this plugin, the user can call the "executePythonScript" RPC method and pass in the parameters "pythonFile" (optional) and "text" (optional). If "pythonFile" is provided, the plugin will execute the specified Python file. If "text" is provided, the plugin will execute the provided Python code. If neither is provided, the plugin will accept text input in a console window.
The text was updated successfully, but these errors were encountered: