summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Git.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-24 08:02:52 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-24 08:02:52 -0500
commitb9f1c40d4f581a1af37b7f15a5438e19d6df618b (patch)
tree17ca4be718237dd3502e2fdd891546e19813b261 /src/lib/Bcfg2/Server/Plugins/Git.py
parent53f1c977e2d9ce23d5292fa71e95c27ba6aa59ce (diff)
downloadbcfg2-b9f1c40d4f581a1af37b7f15a5438e19d6df618b.tar.gz
bcfg2-b9f1c40d4f581a1af37b7f15a5438e19d6df618b.tar.bz2
bcfg2-b9f1c40d4f581a1af37b7f15a5438e19d6df618b.zip
Git: fixed overly verbose error reporting
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Git.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Git.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py
index 759146059..c8362db41 100644
--- a/src/lib/Bcfg2/Server/Plugins/Git.py
+++ b/src/lib/Bcfg2/Server/Plugins/Git.py
@@ -2,7 +2,7 @@
git. """
import sys
-import Bcfg2.Server.Plugin
+from Bcfg2.Server.Plugin import Version, PluginExecutionError
from subprocess import Popen, PIPE
try:
@@ -12,16 +12,16 @@ except ImportError:
HAS_GITPYTHON = False
-class Git(Bcfg2.Server.Plugin.Version):
+class Git(Version):
""" The Git plugin provides a revision interface for Bcfg2 repos
using git. """
__author__ = 'bcfg-dev@mcs.anl.gov'
__vcs_metadata_path__ = ".git"
if HAS_GITPYTHON:
- __rmi__ = Bcfg2.Server.Plugin.Version.__rmi__ + ['Update']
+ __rmi__ = Version.__rmi__ + ['Update']
def __init__(self, core, datastore):
- Bcfg2.Server.Plugin.Version.__init__(self, core, datastore)
+ Version.__init__(self, core, datastore)
if HAS_GITPYTHON:
self.repo = git.Repo(self.vcs_root)
else:
@@ -51,11 +51,9 @@ class Git(Bcfg2.Server.Plugin.Version):
raise Exception(err)
return rv
except:
- err = sys.exc_info()[1]
- msg = "Git: Error getting revision from %s: %s" % (self.vcs_root,
- err)
- self.logger.error(msg)
- raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
+ raise PluginExecutionError("Git: Error getting revision from %s: "
+ "%s" % (self.vcs_root,
+ sys.exc_info()[1]))
def Update(self, ref=None):
""" Git.Update() => True|False
@@ -82,10 +80,8 @@ class Git(Bcfg2.Server.Plugin.Version):
try:
self._log_git_cmd(self.repo.git.checkout('-f', ref))
except git.GitCommandError:
- err = sys.exc_info()[1]
- msg = "Git: Failed to checkout %s: %s" % (ref, err)
- self.logger.error(msg)
- raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
+ raise PluginExecutionError("Git: Failed to checkout %s: %s" %
+ (ref, sys.exc_info()[1]))
# determine if we should try to pull to get the latest commit
# on this head
@@ -100,11 +96,9 @@ class Git(Bcfg2.Server.Plugin.Version):
(self.repo.head.ref.name, tracking))
try:
self._log_git_cmd(self.repo.git.pull("--rebase"))
- except: # pylint: disable=W0702
- err = sys.exc_info()[1]
- msg = "Git: Failed to pull from upstream: %s" % err
- self.logger.error(msg)
- raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
+ except git.GitCommandError:
+ raise PluginExecutionError("Git: Failed to pull from "
+ "upstream: %s" % sys.exc_info()[1])
self.logger.info("Git: Repo at %s updated to %s" %
(self.vcs_root, self.get_revision()))