Skip to content

Commit

Permalink
Merge pull request niosus#78 from rchl/hide-console
Browse files Browse the repository at this point in the history
Suppress console window on running a process
  • Loading branch information
niosus authored Aug 31, 2016
2 parents 27fcaef + 4f1cc28 commit 572521c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions clang/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,22 @@ def find_libclang_dir(clang_binary):
log.info(" we are on '%s'", platform.system())
file = "libclang{}".format(suffix)
log.info(" searching for: '%s'", file)
startupinfo = None
# let's find the library
if platform.system() == "Darwin":
# [HACK]: wtf??? why does it not find libclang.dylib?
get_library_path_cmd = [clang_binary, "-print-file-name="]
elif platform.system() == "Windows":
# [HACK]: wtf??? why does it not find libclang.dylib?
get_library_path_cmd = [clang_binary, "-print-prog-name="]
# Don't let console window pop-up briefly.
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
else:
get_library_path_cmd = [clang_binary, "-print-file-name={}".format(file)]
output = subprocess.check_output(
get_library_path_cmd).decode('utf8').strip()
get_library_path_cmd,
startupinfo=startupinfo).decode('utf8').strip()
log.info(" libclang search output = '%s'", output)
if output:
libclang_dir = ClangUtils.dir_from_output(output)
Expand Down
9 changes: 8 additions & 1 deletion plugin/completion/base_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,16 @@ def run_command(command, shell=True):
str: raw command output
"""
try:
startupinfo = None
if platform.system() == "Windows":
# Don't let console window pop-up briefly.
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
output = subprocess.check_output(command,
stderr=subprocess.STDOUT,
shell=shell)
shell=shell,
startupinfo=startupinfo)
output_text = ''.join(map(chr, output))
except subprocess.CalledProcessError as e:
output_text = e.output.decode("utf-8")
Expand Down

0 comments on commit 572521c

Please sign in to comment.