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, 'inode': self.inode,
} }
# Dirty trick to run libreoffice at least once and avoid unoconv to crash... unoconv_listener = UNOCONV + ' --listener'
lo = LIBREOFFICE + ' --headless' self._run_process(unoconv_listener, background=True)
self._run_process(lo, 5)
# ##### Helpers ##### # ##### Helpers #####
def _init_subtypes_application(self, subtypes_application): def _init_subtypes_application(self, subtypes_application):
@ -145,7 +144,7 @@ class KittenGroomer(KittenGroomerBase):
else: else:
tmp_log.debug(self.cur_file.log_string) 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''' '''Run subprocess, wait until it finishes'''
if timeout != 0: if timeout != 0:
deadline = time.time() + timeout deadline = time.time() + timeout
@ -153,6 +152,10 @@ class KittenGroomer(KittenGroomerBase):
deadline = None deadline = None
args = shlex.split(command_line) args = shlex.split(command_line)
p = subprocess.Popen(args) 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: while True:
code = p.poll() code = p.poll()
if code is not None: if code is not None:

View File

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