Commit cf2a7922 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor code to prevent OSError exception and make possible retry the conversion

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41928 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dae3ce51
......@@ -90,12 +90,10 @@ class OOHandler:
"""start the Monitor"""
self.monitor = MonitorTimeout(openoffice, self.timeout)
self.monitor.start()
return
def _stopTimeout(self):
"""stop the Monitor"""
self.monitor.terminate()
return
def _subprocess(self, command):
"""Run one procedure"""
......@@ -107,10 +105,14 @@ class OOHandler:
stderr=PIPE,
close_fds=True)
stdout, stderr = process.communicate()
except OSError, e:
self.monitor = process = None
stdout, stderr = "", "OSError: %s" % e
finally:
self._stopTimeout()
if pid_exists(process.pid):
process.terminate()
if self.monitor is not None and process is not None:
self._stopTimeout()
if pid_exists(process.pid):
process.terminate()
return stdout, stderr
def _callUnoConverter(self, *feature_list, **kw):
......
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