summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Git.py
diff options
context:
space:
mode:
authorJake Davis <jake.davis@nasa.gov>2012-10-21 10:25:01 -0500
committerSol Jerome <sol.jerome@gmail.com>2012-10-21 10:25:46 -0500
commit77f95ece65628db007376fd0177ec701a94b4a28 (patch)
tree662776b39856184ad0a96443658536dc6265b793 /src/lib/Bcfg2/Server/Plugins/Git.py
parentd26379d404d3c68ab52623731fa297084394a03f (diff)
downloadbcfg2-77f95ece65628db007376fd0177ec701a94b4a28.tar.gz
bcfg2-77f95ece65628db007376fd0177ec701a94b4a28.tar.bz2
bcfg2-77f95ece65628db007376fd0177ec701a94b4a28.zip
Git.py - fallback to native git when dulwich not installed
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Git.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Git.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py
index 56f05e4f6..177770a12 100644
--- a/src/lib/Bcfg2/Server/Plugins/Git.py
+++ b/src/lib/Bcfg2/Server/Plugins/Git.py
@@ -1,7 +1,12 @@
""" The Git plugin provides a revision interface for Bcfg2 repos using
git. """
-from dulwich.repo import Repo
+try:
+ from dulwich.repo import Repo
+except ImportError:
+ # fallback to shell commands when dulwich unavailable
+ from subprocess import Popen, PIPE
+
import Bcfg2.Server.Plugin
@@ -22,6 +27,11 @@ class Git(Bcfg2.Server.Plugin.Plugin,
"""Read git revision information for the Bcfg2 repository."""
try:
return Repo(self.datastore).head()
+ except NameError:
+ return Popen("env LC_ALL=C git log -1 --pretty=format:%H",
+ shell=True,
+ cwd=self.datastore,
+ stdout=PIPE).stdout.readline()
except:
msg = "Failed to read git repository"
self.logger.error(msg)