Merge lp:~florent.x/openobject-addons/trunk-1290820-report_webkit into lp:openobject-addons

Proposed by Florent
Status: Work in progress
Proposed branch: lp:~florent.x/openobject-addons/trunk-1290820-report_webkit
Merge into: lp:openobject-addons
Diff against target: 46 lines (+5/-3)
1 file modified
report_webkit/webkit_report.py (+5/-3)
To merge this branch: bzr merge lp:~florent.x/openobject-addons/trunk-1290820-report_webkit
Reviewer Review Type Date Requested Status
Nicolas Bessi - Camptocamp (community) Disapprove
OpenERP Core Team Pending
Review via email: mp+210387@code.launchpad.net

Description of the change

Fixes bug #1290820

The temporary HTML files become thread-safe.

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Thanks for the fix.

Deprecated by:
https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix-1319095/+merge/219399

So I mark it as disapprove

Regards

Nicolas

review: Disapprove

Unmerged revisions

9197. By Florent

[FIX] report_webkit: use thread-safe names for temporary HTML files.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'report_webkit/webkit_report.py'
2--- report_webkit/webkit_report.py 2013-10-27 12:31:04 +0000
3+++ report_webkit/webkit_report.py 2014-03-11 12:45:10 +0000
4@@ -35,6 +35,7 @@
5 import sys
6 from openerp import report
7 import tempfile
8+import thread
9 import time
10 import logging
11
12@@ -157,6 +158,7 @@
13 webkit_header = report_xml.webkit_header
14 tmp_dir = tempfile.gettempdir()
15 out_filename = tempfile.mktemp(suffix=".pdf", prefix="webkit.tmp.")
16+ timestamp = '%x.%x' % (thread.get_ident(), 1e7 * time.time())
17 file_to_del = [out_filename]
18 if comm_path:
19 command = [comm_path]
20@@ -169,7 +171,7 @@
21 if header :
22 head_file = file( os.path.join(
23 tmp_dir,
24- str(time.time()) + '.head.html'
25+ timestamp + '.head.html'
26 ),
27 'w'
28 )
29@@ -180,7 +182,7 @@
30 if footer :
31 foot_file = file( os.path.join(
32 tmp_dir,
33- str(time.time()) + '.foot.html'
34+ timestamp + '.foot.html'
35 ),
36 'w'
37 )
38@@ -203,7 +205,7 @@
39 command.extend(['--page-size', str(webkit_header.format).replace(',', '.')])
40 count = 0
41 for html in html_list :
42- html_file = file(os.path.join(tmp_dir, str(time.time()) + str(count) +'.body.html'), 'w')
43+ html_file = file(os.path.join(tmp_dir, timestamp + str(count) +'.body.html'), 'w')
44 count += 1
45 html_file.write(html.encode('utf-8'))
46 html_file.close()

Subscribers

People subscribed via source and target branches

to all changes: