From 9b975d9fcf5924800f9ea5d68d7d79f743ca9af7 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Tue, 20 May 2008 22:27:42 +0200 Subject: removed some more spaces --- lib/git_python/git.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/git_python') diff --git a/lib/git_python/git.py b/lib/git_python/git.py index ee256356..2251ecb2 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -11,25 +11,25 @@ class Git(MethodMissingMixin): def __init__(self, git_dir): super(Git, self).__init__() self.git_dir = git_dir - + git_binary = "/usr/bin/env git" - + @property def get_dir(self): return self.git_dir - + def execute(self, command): """ Handles executing the command on the shell and consumes and returns the returned information (stdout) - + ``command`` The command to execute """ print command - proc = subprocess.Popen(command, + proc = subprocess.Popen(command, shell=True, - stdout=subprocess.PIPE + stdout=subprocess.PIPE ) stdout_value = proc.communicate()[0] return stdout_value @@ -51,31 +51,31 @@ class Git(MethodMissingMixin): else: args.append("--%s=%r" % (dashify(k), v)) return args - + def method_missing(self, method, *args, **kwargs): """ Run the given git command with the specified arguments and return the result as a String - + ``method`` is the command - + ``args`` is the list of arguments - + ``kwargs`` is a dict of keyword arguments Examples git.rev_list('master', max_count=10, header=True) - + Returns str """ opt_args = self.transform_kwargs(**kwargs) ext_args = map(lambda a: (a == '--') and a or "%s" % shell_escape(a), args) args = opt_args + ext_args - + call = "%s --git-dir=%s %s %s" % (self.git_binary, self.git_dir, dashify(method), ' '.join(args)) stdout_value = self.execute(call) return stdout_value -- cgit v1.2.1 From ae54e18d7ca7bc8b8fbc667119fb60b25f0f3871 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Tue, 20 May 2008 23:26:06 +0200 Subject: made subprocess not use a shell... --- lib/git_python/__init__.py | 2 +- lib/git_python/git.py | 20 +++++++++++--------- lib/git_python/utils.py | 3 --- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'lib/git_python') diff --git a/lib/git_python/__init__.py b/lib/git_python/__init__.py index 71142a40..11f93313 100644 --- a/lib/git_python/__init__.py +++ b/lib/git_python/__init__.py @@ -11,7 +11,7 @@ from git_python.repo import Repo from git_python.stats import Stats from git_python.tag import Tag from git_python.tree import Tree -from git_python.utils import shell_escape, dashify, touch +from git_python.utils import dashify, touch __all__ = [ name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj)) ] diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 2251ecb2..25cd1cce 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -12,8 +12,6 @@ class Git(MethodMissingMixin): super(Git, self).__init__() self.git_dir = git_dir - git_binary = "/usr/bin/env git" - @property def get_dir(self): return self.git_dir @@ -26,12 +24,14 @@ class Git(MethodMissingMixin): ``command`` The command to execute """ - print command + print ' '.join(command) proc = subprocess.Popen(command, - shell=True, + cwd = self.git_dir, stdout=subprocess.PIPE ) - stdout_value = proc.communicate()[0] + proc.wait() + stdout_value = proc.stdout.read() + proc.stdout.close() return stdout_value def transform_kwargs(self, **kwargs): @@ -44,12 +44,13 @@ class Git(MethodMissingMixin): if v is True: args.append("-%s" % k) else: - args.append("-%s %r" % (k, v)) + args.append("-%s" % k) + args.append(v) else: if v is True: args.append("--%s" % dashify(k)) else: - args.append("--%s=%r" % (dashify(k), v)) + args.append("--%s=%s" % (dashify(k), v)) return args def method_missing(self, method, *args, **kwargs): @@ -73,9 +74,10 @@ class Git(MethodMissingMixin): str """ opt_args = self.transform_kwargs(**kwargs) - ext_args = map(lambda a: (a == '--') and a or "%s" % shell_escape(a), args) + ext_args = map(lambda a: (a == '--') and a or "%s" % a, args) args = opt_args + ext_args - call = "%s --git-dir=%s %s %s" % (self.git_binary, self.git_dir, dashify(method), ' '.join(args)) + call = ['git-'+dashify(method)] + call.extend(args) stdout_value = self.execute(call) return stdout_value diff --git a/lib/git_python/utils.py b/lib/git_python/utils.py index 2bd6f2cd..c2140ba0 100644 --- a/lib/git_python/utils.py +++ b/lib/git_python/utils.py @@ -1,6 +1,3 @@ -def shell_escape(string): - return str(string).replace("'", "\\\\'") - def dashify(string): return string.replace('_', '-') -- cgit v1.2.1 From 30472cf3132b8c03e528b23d1c7533de740e28ab Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Tue, 20 May 2008 23:43:56 +0200 Subject: removed some unused stuff --- lib/git_python/git.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/git_python') diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 25cd1cce..8711c1fb 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -74,10 +74,10 @@ class Git(MethodMissingMixin): str """ opt_args = self.transform_kwargs(**kwargs) - ext_args = map(lambda a: (a == '--') and a or "%s" % a, args) - args = opt_args + ext_args + args = opt_args + list(args) call = ['git-'+dashify(method)] call.extend(args) + stdout_value = self.execute(call) return stdout_value -- cgit v1.2.1 From 71cd409660bc5b8c211dc7c51afae481d822d593 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Wed, 21 May 2008 19:39:55 +0200 Subject: fixed errors in the test, two permission errors remaining, thx to mock?!?! Also removed the shell_escape tests... --- lib/git_python/git.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/git_python') diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 8711c1fb..2cec4954 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -25,6 +25,7 @@ class Git(MethodMissingMixin): The command to execute """ print ' '.join(command) + print self.git_dir proc = subprocess.Popen(command, cwd = self.git_dir, stdout=subprocess.PIPE @@ -74,7 +75,8 @@ class Git(MethodMissingMixin): str """ opt_args = self.transform_kwargs(**kwargs) - args = opt_args + list(args) + ext_args = map(lambda a: (a == '--') and a or "%s" % a, args) + args = opt_args + ext_args call = ['git-'+dashify(method)] call.extend(args) -- cgit v1.2.1 From 70094734d601e1220c95ac586fdffbda3a23e10b Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Thu, 22 May 2008 23:12:48 +0200 Subject: removed stupid print --- lib/git_python/git.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/git_python') diff --git a/lib/git_python/git.py b/lib/git_python/git.py index 2cec4954..aad1f85d 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -25,7 +25,6 @@ class Git(MethodMissingMixin): The command to execute """ print ' '.join(command) - print self.git_dir proc = subprocess.Popen(command, cwd = self.git_dir, stdout=subprocess.PIPE -- cgit v1.2.1