Prevent CMD windows being shown when starting git in a subprocess. · gitpython-developers/GitPython@0d93908 (original) (raw)

Original file line number Diff line number Diff line change
@@ -609,6 +609,12 @@ def execute(self, command,
609 609 # end handle
610 610
611 611 try:
612 +if sys.platform == 'win32':
613 +CREATE_NO_WINDOW = 0x08000000
614 +creationflags = CREATE_NO_WINDOW
615 +else:
616 +creationflags = None
617 +
612 618 proc = Popen(command,
613 619 env=env,
614 620 cwd=cwd,
@@ -619,6 +625,7 @@ def execute(self, command,
619 625 shell=self.USE_SHELL,
620 626 close_fds=(os.name == 'posix'), # unsupported on windows
621 627 universal_newlines=universal_newlines,
628 +creationflags=creationflags,
622 629 **subprocess_kwargs
623 630 )
624 631 except cmd_not_found_exception as err:
@@ -629,7 +636,13 @@ def execute(self, command,
629 636
630 637 def _kill_process(pid):
631 638 """ Callback method to kill a process. """
632 -p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
639 +if sys.platform == 'win32':
640 +CREATE_NO_WINDOW = 0x08000000
641 +creationflags = CREATE_NO_WINDOW
642 +else:
643 +creationflags = None
644 +
645 +p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags)
633 646 child_pids = []
634 647 for line in p.stdout:
635 648 if len(line.split()) > 0: