'Python subprocess.Popen unable to parse argument
Trying to use Popen to launch multiple processes in separate shells, the process is an .exe file that takes arguments, when passing these arguments in a for loop since the variable changes and needs to be dynamically read every time the process runs, im facing issues as the program reports that it is not receiving the "COM" argument, but rather receiving "" string, however when printing the command the full thing shows properly as expected.
Using os.system works as expected but I need the CREATE_NEW_CONSOLE functionality. Side note, how can i keep the shell running after the subprocess is complete ?
ports = serial.tools.list_ports.comports()
print(len(ports), 'port(s) found')
for p in ports:
print(p.device)
flasho_arg = f"-port {p.device} -app {K8_application} -launcher {launcher} -psoc {PSOC} -esp {esp} -graphics {graphics}"
print(flasho_arg)
#process = subprocess.Popen(["flasho.exe", flasho_arg], creationflags=subprocess.CREATE_NEW_CONSOLE)
os.system(f"flasho.exe {flasho_arg}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|