Commit cce06aeb authored by Boris Kocherov's avatar Boris Kocherov

improve logging

parent a5157949
......@@ -58,6 +58,8 @@ class Application(object):
finally:
if pid_exists(process_pid) or self.status():
Process(process_pid).kill()
logger.debug("Process " + str(process_pid) + " killed with returncode " + str(self.process.returncode))
logger.debug("Process " + str(process_pid) + " terminated with returncode " + str(self.process.returncode))
delattr(self, "process")
def loadSettings(self, hostname, port, path_run_dir, **kwargs):
......
......@@ -119,11 +119,18 @@ class Handler(object):
self._startTimeout()
process = Popen(command_list, stdout=PIPE, stderr=PIPE, close_fds=True,
env=openoffice.environment_dict.copy())
logger.debug("Process " + str(process.pid) + " runned")
stdout, stderr = process.communicate()
finally:
self._stopTimeout()
if pid_exists(process.pid):
logger.debug("Process " + str(process.pid) + " terminated")
process.terminate()
if (process.returncode < 0 and process.returncode != -6) or stderr:
logger.error("Process " + str(process.pid) + " command:" + " ".join(command_list))
logger.error("Process " + str(process.pid) + " stdout:" + stdout)
logger.error("Process " + str(process.pid) + " stderr:" + stderr)
logger.debug("Process " + str(process.pid) + " terminated with returncode " + str(process.returncode))
return stdout, stderr
def _callUnoConverter(self, *feature_list, **kw):
......@@ -131,7 +138,9 @@ class Handler(object):
if not openoffice.status():
openoffice.start()
command_list = self._getCommand(*feature_list, **kw)
logger.debug("run convert first")
stdout, stderr = self._subprocess(command_list)
logger.debug("stop convert first")
if not stdout and stderr:
first_error = stderr
logger.error(stderr)
......@@ -139,10 +148,11 @@ class Handler(object):
openoffice.restart()
kw['document_url'] = self.document.getUrl()
command = self._getCommand(*feature_list, **kw)
logger.debug("run convert second")
stdout, stderr = self._subprocess(command)
logger.debug("stop convert second")
if not stdout and stderr:
second_error = "\nerror of the second run: " + stderr
logger.error(second_error)
raise Exception(first_error + second_error)
return stdout, stderr
......
......@@ -33,6 +33,7 @@ from subprocess import STDOUT
from zope.interface import implements
from filter import Filter
from os import environ, path
from cloudooo.util import logger
from cloudooo.interfaces.mimemapper import IMimemapper
from types import InstanceType
import json
......@@ -124,8 +125,10 @@ class MimeMapper(object):
"--hostname=%s" % hostname,
"--port=%s" % port]
process = Popen(command, stdout=PIPE, stderr=STDOUT, close_fds=True)
process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True)
stdout, stderr = process.communicate()
if stderr:
logger.error(stderr)
if process.returncode:
raise ValueError(stdout)
filter_dict, type_dict = json.loads(stdout)
......
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