Skip to content
Browse files

GitCore: Abstract out __pipe

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information...
1 parent d7a50e2 commit aa80f4556bbb0ba68008ccf910418ade2fbeff55 @andersk andersk committed Oct 20, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 tracext/git/PyGIT.py
View
14 tracext/git/PyGIT.py
@@ -48,17 +48,19 @@ def __build_git_cmd(self, gitcmd, *args):
return cmd
+ def __pipe(self, git_cmd, *cmd_args, **kw):
+ if sys.platform == "win32":
+ return Popen(self.__build_git_cmd(git_cmd, *cmd_args), **kw)
+ else:
+ return Popen(self.__build_git_cmd(git_cmd, *cmd_args),
+ close_fds=True, **kw)
+
def __execute(self, git_cmd, *cmd_args):
"execute git command and return file-like object of stdout"
#print >>sys.stderr, "DEBUG:", git_cmd, cmd_args
- if sys.platform == "win32":
- p = Popen(self.__build_git_cmd(git_cmd, *cmd_args),
- stdin=None, stdout=PIPE, stderr=PIPE)
- else:
- p = Popen(self.__build_git_cmd(git_cmd, *cmd_args),
- stdin=None, stdout=PIPE, stderr=PIPE, close_fds=True)
+ p = self.__pipe(git_cmd, *cmd_args, stdout=PIPE, stderr=PIPE)
stdout_data, stderr_data = p.communicate()
#TODO, do something with p.returncode, e.g. raise exception

0 comments on commit aa80f45

Please sign in to comment.
Something went wrong with that request. Please try again.