Don't call office converter if not initialized

This commit is contained in:
Roberto Rosario
2011-11-22 05:08:04 -04:00
parent 99e6bf652f
commit ba7016b0bc
+10 -8
View File
@@ -50,17 +50,19 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
if os.path.exists(output_filepath): if os.path.exists(output_filepath):
return output_filepath return output_filepath
office_converter.convert(input_filepath, mimetype=mimetype)
if office_converter: if office_converter:
try: try:
input_filepath = office_converter.output_filepath office_converter.convert(input_filepath, mimetype=mimetype)
mimetype = 'application/pdf' if office_converter.exists:
input_filepath = office_converter.output_filepath
mimetype = 'application/pdf'
else:
# Recycle the already detected mimetype
mimetype = office_converter.mimetype
except OfficeConverter: except OfficeConverter:
raise UnknownFileFormat('office converter exception') raise UnknownFileFormat('office converter exception')
else:
# Recycle the already detected mimetype
mimetype = office_converter.mimetype
if size: if size:
transformations.append( transformations.append(