Index: trunk/extensions/Collection/Collection.i18n.php |
— | — | @@ -100,6 +100,9 @@ |
101 | 101 | No more pages can be added.', |
102 | 102 | 'coll-generating_pdf_title' => 'Generating PDF', |
103 | 103 | 'coll-generating_pdf_text' => "'''Please wait while the PDF file is being generated.''' |
| 104 | + |
| 105 | +Progress: %(progress)d%%. |
| 106 | + |
104 | 107 | This page should automatically refresh every few seconds. |
105 | 108 | If this does not work, please press refresh button of your browser.", |
106 | 109 | 'coll-pdf_finished_text' => "The PDF file has been generated. |
Index: trunk/extensions/Collection/pdf-server/pdf-server.py |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | self.metabook_filename = os.path.join(self.collection_dir, 'metabook.json') |
80 | 80 | self.pdf_filename = os.path.join(self.collection_dir, 'collection.pdf') |
81 | 81 | self.error_filename = os.path.join(self.collection_dir, 'errors.txt') |
| 82 | + self.progress_filename = os.path.join(self.collection_dir, 'progress.txt') |
82 | 83 | self.removed_filename = os.path.join(self.collection_dir, 'removed.txt') |
83 | 84 | self.generating_templ_filename = os.path.join(self.collection_dir, 'generating.html') |
84 | 85 | self.finished_templ_filename = os.path.join(self.collection_dir, 'finished.html') |
— | — | @@ -105,13 +106,14 @@ |
106 | 107 | 'license': self.form.getvalue('license'), |
107 | 108 | 'template_blacklist': self.form.getvalue('template_blacklist'), |
108 | 109 | 'removed': self.removed_filename, |
| 110 | + 'progress': self.progress_filename, |
109 | 111 | 'output': self.pdf_filename, |
110 | 112 | } |
111 | 113 | |
112 | 114 | os.makedirs(self.collection_dir) |
113 | 115 | metabook = self.form.getvalue('metabook') |
114 | 116 | open(self.metabook_filename, 'wb').write(metabook) |
115 | | - rc = os.system('%(cmd)s --daemonize -l %(logfile)s -e %(errorfile)s -m %(metabook)s -b %(base_url)s -s %(shared_base_url)s --license %(license)s --template-blacklist %(template_blacklist)s -r $(removed)s -o %(output)s' % args) |
| 117 | + rc = os.system('%(cmd)s --daemonize -l %(logfile)s -e %(errorfile)s -m %(metabook)s -b %(base_url)s -s %(shared_base_url)s --license %(license)s --template-blacklist %(template_blacklist)s -r $(removed)s -p %(progress)s -o %(output)s' % args) |
116 | 118 | assert rc == 0, 'Execution of mw-pdf failed.' |
117 | 119 | |
118 | 120 | open(self.generating_templ_filename, 'wb').write(self.form.getvalue('generating_template')) |
— | — | @@ -149,13 +151,18 @@ |
150 | 152 | html = open(self.error_templ_filename, 'rb').read() |
151 | 153 | self.render_html(html) |
152 | 154 | else: |
| 155 | + progress = 0 |
| 156 | + try: |
| 157 | + progress = int(open(self.progress_filename, 'rb').read()) |
| 158 | + except (IOError, ValueError): |
| 159 | + pass |
153 | 160 | query_args = urllib.urlencode({ |
154 | 161 | 'command': 'pdf_status', |
155 | 162 | 'collection_id': self.collection_id, |
156 | 163 | }) |
157 | 164 | meta = '<meta http-equiv="refresh" content="5; url=?%s">' % query_args |
158 | 165 | html = open(self.generating_templ_filename, 'rb').read() |
159 | | - self.render_html(html, head_text=meta) |
| 166 | + self.render_html(html % {'progress': progress}, head_text=meta) |
160 | 167 | |
161 | 168 | def do_pdf_download(self): |
162 | 169 | self.headers['Content-Type'] = 'application/pdf' |