Skip to content

Commit

Permalink
Don't open a terminal window on Windows (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak authored Jan 20, 2023
2 parents 600e5f3 + 0242722 commit a72804f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import sys
from pathlib import Path
import subprocess
from subprocess import (
Popen,
PIPE,
Expand All @@ -38,11 +39,16 @@ def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProce
raise Exception(f"Unknown tool {tool}. Use adb, fastboot or heimdall.")
if PLATFORM == "win32":
full_command = [str(bin_path.joinpath(Path(f"{tool}"))) + ".exe"] + command
# prevent Windows from opening terminal windows
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
else:
full_command = [str(bin_path.joinpath(Path(f"{tool}")))] + command
si = None
logger.info(f"Run command: {full_command}")
# run the command
with Popen(
full_command, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True
full_command, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True, startupinfo=si
) as p:
for line in p.stdout:
logger.info(line.strip())
Expand Down

0 comments on commit a72804f

Please sign in to comment.