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