-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_line_python.py
More file actions
27 lines (22 loc) · 1.05 KB
/
cmd_line_python.py
File metadata and controls
27 lines (22 loc) · 1.05 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
# vecnode 18-12-2025
# Execute 'test_udp.py' from a Text DAT and get the result on UDP In DAT (hiding CMD window)
import subprocess
import os
def execute_pair_file():
python_executable = os.environ.get('MY_PYTHON', 'python') # Default to 'python'
toe_directory = project.folder
path_to_script = os.path.join(toe_directory, "test_udp.py")
command_list = [python_executable, path_to_script]
# Create a STARTUPINFO structure to specify that the subprocess window is not created
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
try:
result = subprocess.run(command_list, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=toe_directory, startupinfo=startupinfo)
print("Output from test_udp.py:")
print(result.stdout)
if result.stderr:
print("Errors:", result.stderr)
except subprocess.CalledProcessError as e:
print(f"Error calling test_udp.py: {e}")
print("Command executed:", command_list)
execute_pair_file()