Commit 5e41f4c1 authored by Nicolas Delaby's avatar Nicolas Delaby

If subprocess command fails, then exit immediately and display error message

parent b678eb79
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import pkg_resources import pkg_resources
from re import findall from re import findall
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from subprocess import STDOUT
from zope.interface import implements from zope.interface import implements
from filter import Filter from filter import Filter
from os import environ, path from os import environ, path
...@@ -107,9 +108,10 @@ class MimeMapper(object): ...@@ -107,9 +108,10 @@ class MimeMapper(object):
"--hostname=%s" % hostname, "--hostname=%s" % hostname,
"--port=%s" % port] "--port=%s" % port]
stdout, stderr = Popen(command, process = Popen(command, stdout=PIPE, stderr=STDOUT, close_fds=True)
stdout=PIPE, stdout, stderr = process.communicate()
close_fds=True).communicate() if process.returncode:
raise ValueError(stdout)
filter_dict, type_dict = json.loads(stdout) filter_dict, type_dict = json.loads(stdout)
for filter_name, value in filter_dict.iteritems(): for filter_name, value in filter_dict.iteritems():
flag = value.get("Flags") flag = value.get("Flags")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment