WIP: Start unoconv as a listener.

pull/2/head
Raphaël Vinot 2015-05-26 18:08:57 +02:00
parent b2447d9d56
commit dcc3c7eda8
2 changed files with 9 additions and 6 deletions

View File

@ -118,9 +118,8 @@ class KittenGroomer(KittenGroomerBase):
'inode': self.inode,
}
# Dirty trick to run libreoffice at least once and avoid unoconv to crash...
lo = LIBREOFFICE + ' --headless'
self._run_process(lo, 5)
unoconv_listener = UNOCONV + ' --listener'
self._run_process(unoconv_listener, background=True)
# ##### Helpers #####
def _init_subtypes_application(self, subtypes_application):
@ -145,7 +144,7 @@ class KittenGroomer(KittenGroomerBase):
else:
tmp_log.debug(self.cur_file.log_string)
def _run_process(self, command_line, timeout=0):
def _run_process(self, command_line, timeout=0, background=False):
'''Run subprocess, wait until it finishes'''
if timeout != 0:
deadline = time.time() + timeout
@ -153,6 +152,10 @@ class KittenGroomer(KittenGroomerBase):
deadline = None
args = shlex.split(command_line)
p = subprocess.Popen(args)
if background:
# FIXME: This timer is here to make sure the unoconv listener is properly started.
time.sleep(10)
return True
while True:
code = p.poll()
if code is not None:

View File

@ -89,10 +89,10 @@ class KittenGroomerBase(object):
self.src_root_dir = root_src
self.dst_root_dir = root_dst
self.log_root_dir = os.path.join(self.dst_root_dir, 'logs')
self._safe_mkdir(self.log_root_dir)
self.log_processing = os.path.join(self.log_root_dir, 'processing.log')
# quickSetup(file=self.log_processing)
quickSetup()
quickSetup(file=self.log_processing)
self.log_name = log.name('files')
self.cur_file = None