Module: check_mk
Branch: master
Commit: 9b2d5d8b74d0ff71cf171dc708b49c42bbac6c17
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b2d5d8b74d0ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 20 14:39:06 2017 +0100
4387 FIX Git integration: Fixed error handling when enabling it while git is not
installed
Change-Id: Icf6dbaebd926d2190948567bf79cc825c6d78889
---
.werks/4387 | 10 ++++++++++
web/htdocs/watolib.py | 18 ++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/.werks/4387 b/.werks/4387
new file mode 100644
index 0000000..99c502b
--- /dev/null
+++ b/.werks/4387
@@ -0,0 +1,10 @@
+Title: Git integration: Fixed error handling when enabling it while git is not installed
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.5.0i1
+Date: 1487597918
+
+
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 63786cc..7d38969 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -7565,8 +7565,16 @@ def unlock_exclusive():
def git_command(args):
command = [ "git" ] + [ a.encode("utf-8") for a in args ]
- p = subprocess.Popen(command, cwd=cmk.paths.default_config_dir,
+ try:
+ p = subprocess.Popen(command, cwd=cmk.paths.default_config_dir,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ except OSError, e:
+ if e.errno == 2:
+ raise MKGeneralException(_("Error executing GIT command
<tt>%s</tt>:<br><br>%s") %
+ (subprocess.list2cmdline(command), e))
+ else:
+ raise
+
status = p.wait()
if status != 0:
raise MKGeneralException(_("Error executing GIT command
<tt>%s</tt>:<br><br>%s") %
@@ -7615,9 +7623,15 @@ def git_add_files():
def git_has_pending_changes():
- return subprocess.Popen(["git", "status",
"--porcelain"],
+ try:
+ return subprocess.Popen(["git", "status",
"--porcelain"],
cwd=cmk.paths.default_config_dir,
stdout=subprocess.PIPE).stdout.read() != ""
+ except OSError, e:
+ if e.errno == 2:
+ return False # ignore missing git command
+ else:
+ raise
# Make sure that .gitignore-files are present and uptodate. Only files below the
"wato" directories