Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit 7c4db40

Browse files
Merge pull request #23 from kojoru/no_console_window_on_windows
Avoid showing console window on Windows platform
2 parents 8d860ce + d204ac0 commit 7c4db40

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

searchengines/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ def run(self, query, folders):
4141
print("Running: %s" % " ".join(arguments))
4242

4343
try:
44+
startupinfo = None
45+
if os.name == 'nt':
46+
startupinfo = subprocess.STARTUPINFO()
47+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
48+
4449
pipe = subprocess.Popen(arguments,
4550
stdout=subprocess.PIPE,
4651
stderr=subprocess.PIPE,
47-
cwd=folders[0]
52+
cwd=folders[0],
53+
startupinfo=startupinfo
4854
)
4955
except OSError: # Not FileNotFoundError for compatibility with Sublime Text 2
5056
raise RuntimeError("Could not find executable %s" % self.path_to_executable)
@@ -86,7 +92,9 @@ def _filter_lines_without_matches(self, line_parts):
8692

8793
def _resolve_windows_path_to_executable(self):
8894
try:
89-
self.path_to_executable = self._sanitize_output(subprocess.check_output("where %s" % self.path_to_executable))
95+
startupinfo = subprocess.STARTUPINFO()
96+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
97+
self.path_to_executable = self._sanitize_output(subprocess.check_output("where %s" % self.path_to_executable, startupinfo=startupinfo))
9098
except subprocess.CalledProcessError:
9199
# do nothing, executable not found
92100
pass

0 commit comments

Comments
 (0)