Skip to content

Commit

Permalink
allow internally piping the lines to command line from atbx
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Dec 23, 2023
1 parent d833b70 commit d597608
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/agstoolbox/core/utils/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations # for python 3.8

import os
from subprocess import Popen, TimeoutExpired
import sys
from subprocess import Popen, PIPE, TimeoutExpired

from agstoolbox.core.utils.file import get_file, get_dir
from agstoolbox.core.utils.pyinstaller_hacks import lock_dll_dir, unlock_dll_dir
Expand All @@ -20,10 +21,15 @@ def run_exe_params(exe_path: str, block: bool = False, params=None) -> int:
os.chdir(working_dir)
lock_dll_dir()
print('Popen: cwd=' + working_dir + ', ' + ' '.join(p_params))
proc = Popen(p_params, cwd=working_dir)
proc = Popen(p_params, cwd=working_dir, stdout=PIPE, stderr=PIPE, bufsize=1,
universal_newlines=True)
count = 0
if block:
while count < 1000:
for line in proc.stdout:
sys.stdout.write(line)
for line in proc.stderr:
sys.stdout.write(line)
try:
proc.wait(10)
except TimeoutExpired:
Expand Down

0 comments on commit d597608

Please sign in to comment.