[Erp5-report] r35515 jerome - /erp5/trunk/products/ERP5/Document/PDFDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri May 21 12:46:56 CEST 2010
Author: jerome
Date: Fri May 21 12:46:55 2010
New Revision: 35515
URL: http://svn.erp5.org?rev=35515&view=rev
Log:
don't fail if pdftk is not found
Modified:
erp5/trunk/products/ERP5/Document/PDFDocument.py
Modified: erp5/trunk/products/ERP5/Document/PDFDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFDocument.py?rev=35515&r1=35514&r2=35515&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] Fri May 21 12:46:55 2010
@@ -231,22 +231,27 @@
result[key] = value
# Then we use pdftk to get extra metadata
- command_result = Popen(['pdftk', tmp.name, 'dump_data', 'output'],
+ try:
+ command_result = Popen(['pdftk', tmp.name, 'dump_data', 'output'],
stdout=PIPE).communicate()[0]
- h = command_result
- line_list = (line for line in h.splitlines())
- while True:
- try:
- line = line_list.next()
- except StopIteration:
- break
- if line.startswith('InfoKey'):
- key = line[len('InfoKey: '):]
- line = line_list.next()
- assert line.startswith('InfoValue: '),\
- "Wrong format returned by pdftk dump_data"
- value = line[len('InfoValue: '):]
- result.setdefault(key, value)
+ except OSError:
+ # pdftk not found
+ pass
+ else:
+ h = command_result
+ line_list = (line for line in h.splitlines())
+ while True:
+ try:
+ line = line_list.next()
+ except StopIteration:
+ break
+ if line.startswith('InfoKey'):
+ key = line[len('InfoKey: '):]
+ line = line_list.next()
+ assert line.startswith('InfoValue: '),\
+ "Wrong format returned by pdftk dump_data"
+ value = line[len('InfoValue: '):]
+ result.setdefault(key, value)
finally:
tmp.close()
More information about the Erp5-report
mailing list