summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-08 08:12:47 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-08 08:12:47 -0500
commite1edce98761782fe51c451be4f5e114c75f46bd5 (patch)
treee7a5cb607b9173d8ab53eca1da20a2be72981846 /src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py
parent55807333ccb7d80c4e2f074c2a1a10f554e57289 (diff)
downloadbcfg2-e1edce98761782fe51c451be4f5e114c75f46bd5.tar.gz
bcfg2-e1edce98761782fe51c451be4f5e114c75f46bd5.tar.bz2
bcfg2-e1edce98761782fe51c451be4f5e114c75f46bd5.zip
Cfg: better error handling from verifiers, :test
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py
index b702ac899..8e2d98db9 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgExternalCommandVerifier.py
@@ -23,10 +23,18 @@ class CfgExternalCommandVerifier(CfgVerifier):
def verify_entry(self, entry, metadata, data):
try:
proc = Popen(self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
- err = proc.communicate(input=data)[1]
+ out, err = proc.communicate(input=data)
rv = proc.wait()
if rv != 0:
- raise CfgVerificationError(err)
+ if not err:
+ if out:
+ # got nothing on stderr, try stdout
+ err = out
+ else:
+ err = "Non-zero return value %s" % rv
+ raise CfgVerificationError(err.strip())
+ except CfgVerificationError:
+ raise
except:
err = sys.exc_info()[1]
raise CfgVerificationError("Error running external command "