summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Lint/Validate.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-14 13:05:08 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-14 13:05:08 -0400
commit3d06f311274d6b942ee89d8cdb13b2ecc99af1b0 (patch)
treebc3d6403e053f0e30f525c6555bd00dd0d0c973e /src/lib/Bcfg2/Server/Lint/Validate.py
parentacb1dde9ba48b04d1ceb701ce849e96cef3d0070 (diff)
downloadbcfg2-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/Lint/Validate.py')
-rw-r--r--src/lib/Bcfg2/Server/Lint/Validate.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Validate.py b/src/lib/Bcfg2/Server/Lint/Validate.py
index 7a9d9f877..dd45ac62e 100644
--- a/src/lib/Bcfg2/Server/Lint/Validate.py
+++ b/src/lib/Bcfg2/Server/Lint/Validate.py
@@ -5,8 +5,8 @@ import sys
import glob
import fnmatch
import lxml.etree
-from subprocess import Popen, PIPE, STDOUT
import Bcfg2.Server.Lint
+from Bcfg2.Utils import Executor
class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
@@ -44,6 +44,7 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
self.filelists = {}
self.get_filelists()
+ self.cmd = Executor()
def Run(self):
schemadir = self.config['schema']
@@ -94,11 +95,10 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
try:
datafile = lxml.etree.parse(filename)
except SyntaxError:
- lint = Popen(["xmllint", filename], stdout=PIPE, stderr=STDOUT)
+ result = self.cmd.run(["xmllint", filename])
self.LintError("xml-failed-to-parse",
- "%s fails to parse:\n%s" % (filename,
- lint.communicate()[0]))
- lint.wait()
+ "%s fails to parse:\n%s" %
+ (filename, result.stdout + result.stderr))
return False
except IOError:
self.LintError("xml-failed-to-read",
@@ -110,11 +110,11 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
if self.files is None:
cmd.append("--xinclude")
cmd.extend(["--noout", "--schema", schemafile, filename])
- lint = Popen(cmd, stdout=PIPE, stderr=STDOUT)
- output = lint.communicate()[0]
- if lint.wait():
+ result = self.cmd.run(cmd)
+ if not result.success:
self.LintError("xml-failed-to-verify",
- "%s fails to verify:\n%s" % (filename, output))
+ "%s fails to verify:\n%s" %
+ (filename, result.stdout + result.stderr))
return False
return True