diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-14 13:05:08 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-14 13:05:08 -0400 |
commit | 3d06f311274d6b942ee89d8cdb13b2ecc99af1b0 (patch) | |
tree | bc3d6403e053f0e30f525c6555bd00dd0d0c973e /src/lib/Bcfg2/Server/Plugins/Git.py | |
parent | acb1dde9ba48b04d1ceb701ce849e96cef3d0070 (diff) | |
download | bcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.tar.gz bcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.tar.bz2 bcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.zip |
use Executor class for better subprocess calling on server
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Git.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Git.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py index c8362db41..781413e1a 100644 --- a/src/lib/Bcfg2/Server/Plugins/Git.py +++ b/src/lib/Bcfg2/Server/Plugins/Git.py @@ -3,12 +3,12 @@ git. """ import sys from Bcfg2.Server.Plugin import Version, PluginExecutionError -from subprocess import Popen, PIPE try: import git HAS_GITPYTHON = True except ImportError: + from Bcfg2.Utils import Executor HAS_GITPYTHON = False @@ -24,10 +24,12 @@ class Git(Version): Version.__init__(self, core, datastore) if HAS_GITPYTHON: self.repo = git.Repo(self.vcs_root) + self.cmd = None else: self.logger.debug("Git: GitPython not found, using CLI interface " "to Git") self.repo = None + self.cmd = Executor() self.logger.debug("Initialized git plugin with git directory %s" % self.vcs_path) @@ -45,11 +47,10 @@ class Git(Version): cmd = ["git", "--git-dir", self.vcs_path, "--work-tree", self.vcs_root, "rev-parse", "HEAD"] self.debug_log("Git: Running cmd") - proc = Popen(cmd, stdout=PIPE, stderr=PIPE) - rv, err = proc.communicate() - if proc.wait(): - raise Exception(err) - return rv + result = self.cmd.run(cmd) + if not result.success: + raise Exception(result.stderr) + return result.stdout except: raise PluginExecutionError("Git: Error getting revision from %s: " "%s" % (self.vcs_root, |