From a7f403b1e82d4ada20d0e747032c7382e2a6bf63 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 13 Jun 2016 15:36:51 +0100 Subject: fix flake8 found problems --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 9a141297..b4f987ef 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -614,7 +614,7 @@ class Git(LazyMixin): cwd=cwd, bufsize=-1, stdin=istream, - stderr=PIPE, + stderr=PIPE, stdout=PIPE if with_stdout else open(os.devnull, 'wb'), shell=self.USE_SHELL, close_fds=(os.name == 'posix'), # unsupported on windows -- cgit v1.2.1 From 0d9390866f9ce42870d3116094cd49e0019a970a Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Fri, 29 Jul 2016 14:04:27 +0100 Subject: Prevent CMD windows being shown when starting git in a subprocess. This fixes a UI problem with using GitPython from a GUI python probgram. Each repo that is opened creates a git cat-file processs and that provess will create a console window with out this change. --- git/cmd.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index d8469565..a7f4285a 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -609,6 +609,12 @@ class Git(LazyMixin): # end handle try: + if sys.platform == 'win32': + CREATE_NO_WINDOW = 0x08000000 + creationflags = CREATE_NO_WINDOW + else: + creationflags = None + proc = Popen(command, env=env, cwd=cwd, @@ -619,6 +625,7 @@ class Git(LazyMixin): shell=self.USE_SHELL, close_fds=(os.name == 'posix'), # unsupported on windows universal_newlines=universal_newlines, + creationflags=creationflags, **subprocess_kwargs ) except cmd_not_found_exception as err: @@ -629,7 +636,13 @@ class Git(LazyMixin): def _kill_process(pid): """ Callback method to kill a process. """ - p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE) + if sys.platform == 'win32': + CREATE_NO_WINDOW = 0x08000000 + creationflags = CREATE_NO_WINDOW + else: + creationflags = None + + p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags) child_pids = [] for line in p.stdout: if len(line.split()) > 0: -- cgit v1.2.1 From d79951fba0994654104128b1f83990387d44ac22 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 1 Aug 2016 10:39:55 +0100 Subject: Must pass creationflags as a keywork --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index a7f4285a..5c4cd5e9 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -642,7 +642,7 @@ class Git(LazyMixin): else: creationflags = None - p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags) + p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags) child_pids = [] for line in p.stdout: if len(line.split()) > 0: -- cgit v1.2.1 From 572ebd6e92cca39100183db7bbeb6b724dde0211 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 1 Aug 2016 11:09:20 +0100 Subject: creationflags must be set to 0 on non-windows platforms --- git/cmd.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 5c4cd5e9..00a73e33 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -43,6 +43,9 @@ from git.compat import ( safe_decode, ) +# value of Windows process creation flag taken from MSDN +CREATE_NO_WINDOW = 0x08000000 + execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream', 'with_stdout', 'kill_after_timeout', @@ -610,10 +613,9 @@ class Git(LazyMixin): try: if sys.platform == 'win32': - CREATE_NO_WINDOW = 0x08000000 creationflags = CREATE_NO_WINDOW else: - creationflags = None + creationflags = 0 proc = Popen(command, env=env, @@ -637,10 +639,9 @@ class Git(LazyMixin): def _kill_process(pid): """ Callback method to kill a process. """ if sys.platform == 'win32': - CREATE_NO_WINDOW = 0x08000000 creationflags = CREATE_NO_WINDOW else: - creationflags = None + creationflags = 0 p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags) child_pids = [] -- cgit v1.2.1 From df958981ad63edae6fceb69650c1fb9890c2b14f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 2 Aug 2016 05:46:45 +0200 Subject: refactor(cmd): streamline usage of creationflags --- git/cmd.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 00a73e33..62eef9e4 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -43,9 +43,6 @@ from git.compat import ( safe_decode, ) -# value of Windows process creation flag taken from MSDN -CREATE_NO_WINDOW = 0x08000000 - execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream', 'with_stdout', 'kill_after_timeout', @@ -249,6 +246,9 @@ class Git(LazyMixin): # Enables debugging of GitPython's git commands GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False) + # value of Windows process creation flag taken from MSDN + CREATE_NO_WINDOW = 0x08000000 + # Provide the full path to the git executable. Otherwise it assumes git is in the path _git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE" GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name) @@ -611,12 +611,8 @@ class Git(LazyMixin): cmd_not_found_exception = OSError # end handle + creationflags = self.CREATE_NO_WINDOW if sys.platform == 'win32' else 0 try: - if sys.platform == 'win32': - creationflags = CREATE_NO_WINDOW - else: - creationflags = 0 - proc = Popen(command, env=env, cwd=cwd, @@ -638,11 +634,6 @@ class Git(LazyMixin): def _kill_process(pid): """ Callback method to kill a process. """ - if sys.platform == 'win32': - creationflags = CREATE_NO_WINDOW - else: - creationflags = 0 - p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags) child_pids = [] for line in p.stdout: -- cgit v1.2.1