5757from mslib .msui .constants import MSS_CONFIG_PATH
5858
5959
60+ def subprocess_startupinfo ():
61+ """
62+ config options to hide windows terminals on subprocess call
63+ """
64+ startupinfo = None
65+ if os .name == 'nt' :
66+ # thx to https://gist.github.com/nitely/3862493
67+ startupinfo = subprocess .STARTUPINFO ()
68+ startupinfo .dwFlags = subprocess .CREATE_NEW_CONSOLE | subprocess .STARTF_USESHOWWINDOW
69+ startupinfo .wShowWindow = subprocess .SW_HIDE
70+ return startupinfo
71+
72+
6073def parse_iso_datetime (string ):
6174 try :
6275 result = isodate .parse_datetime (string )
@@ -762,7 +775,8 @@ def __init__(self, parent=None):
762775
763776 # Check if mamba is installed
764777 try :
765- subprocess .run (["mamba" ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
778+ subprocess .run (["mamba" ], startupinfo = subprocess_startupinfo (),
779+ stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
766780 self .command = "mamba"
767781 except FileNotFoundError :
768782 pass
@@ -786,7 +800,9 @@ def _check_version(self):
786800 """
787801 # Don't notify on updates if mss is in a git repo, as you are most likely a developer
788802 try :
789- git = subprocess .run (["git" , "rev-parse" , "--is-inside-work-tree" ], stdout = subprocess .PIPE ,
803+ git = subprocess .run (["git" , "rev-parse" , "--is-inside-work-tree" ],
804+ startupinfo = subprocess_startupinfo (),
805+ stdout = subprocess .PIPE ,
790806 stderr = subprocess .STDOUT , encoding = "utf8" )
791807 if "true" in git .stdout :
792808 self .is_git_env = True
@@ -795,7 +811,8 @@ def _check_version(self):
795811
796812 # Return if conda is not installed
797813 try :
798- subprocess .run (["conda" ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
814+ subprocess .run (["conda" ], startupinfo = subprocess_startupinfo (),
815+ stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
799816 except FileNotFoundError :
800817 return
801818
@@ -858,7 +875,11 @@ def _execute_command(self, command):
858875 """
859876 Handles proper execution of conda subprocesses and logging
860877 """
861- process = subprocess .Popen (command .split (), stdout = subprocess .PIPE , stderr = subprocess .STDOUT , encoding = "utf8" )
878+ process = subprocess .Popen (command .split (),
879+ startupinfo = subprocess_startupinfo (),
880+ stdout = subprocess .PIPE ,
881+ stderr = subprocess .STDOUT ,
882+ encoding = "utf8" )
862883 self .on_log_update .emit (" " .join (process .args ) + "\n " )
863884
864885 text = ""
0 commit comments