### If no doctype given, check list of acceptable formats for input file ext doctype
### FIXME: This should go into the for-loop to match each individual input filename
ifoutputfmt:
inputext=os.path.splitext(inputfn)[1]
inputfmt=fmts.byextension(inputext)
ifinputfmt:
forfmtinoutputfmt:
ifinputfmt[0].doctype==fmt.doctype:
doctype=inputfmt[0].doctype
outputfmt=fmt
break
else:
outputfmt=outputfmt[0]
# print >> sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype)
else:
outputfmt=outputfmt[0]
### No format found, throw error
ifnotoutputfmt:
ifdoctype:
print>>sys.stderr,'unoconv: format [%s/%s] is not known to unoconv.'%(op.doctype,op.format)
else:
print>>sys.stderr,'unoconv: format [%s] is not known to unoconv.'%op.format
die(1)
returnoutputfmt
defconvert(self,inputfn):
globalexitcode
document=None
outputfmt=self.getformat(inputfn)
ifop.verbose>0:
print>>sys.stderr,'Input file:',inputfn
ifnotos.path.exists(inputfn):
print>>sys.stderr,'unoconv: file `%s\' does not exist.'%inputfn
error("unoconv: could not find an existing connection to LibreOffice at %s:%s."%(op.server,op.port))
ifop.connection:
info(0,"Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\""%(op.server,op.server,op.port,op.connection))
else:
info(0,"Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\""%(op.server,op.server,op.port,op.server,op.port))
info(0,"Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=localhost,port=%s;urp;\""%(op.server,op.port))
exitcode=1
# except UnboundLocalError:
# die(252, "Failed to connect to remote listener.")
exceptOSError:
error("Warning: failed to launch Office suite. Aborting.")