r34237 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34236‎ | r34237 | r34238 >
Date:09:27, 5 May 2008
Author:jojo
Status:old
Tags:
Comment:
added progress for PDF generation
Modified paths:
  • /trunk/extensions/Collection/Collection.i18n.php (modified) (history)
  • /trunk/extensions/Collection/pdf-server/pdf-server.py (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.i18n.php
@@ -100,6 +100,9 @@
101101 No more pages can be added.',
102102 'coll-generating_pdf_title' => 'Generating PDF',
103103 'coll-generating_pdf_text' => "'''Please wait while the PDF file is being generated.'''
 104+
 105+Progress: %(progress)d%%.
 106+
104107 This page should automatically refresh every few seconds.
105108 If this does not work, please press refresh button of your browser.",
106109 'coll-pdf_finished_text' => "The PDF file has been generated.
Index: trunk/extensions/Collection/pdf-server/pdf-server.py
@@ -78,6 +78,7 @@
7979 self.metabook_filename = os.path.join(self.collection_dir, 'metabook.json')
8080 self.pdf_filename = os.path.join(self.collection_dir, 'collection.pdf')
8181 self.error_filename = os.path.join(self.collection_dir, 'errors.txt')
 82+ self.progress_filename = os.path.join(self.collection_dir, 'progress.txt')
8283 self.removed_filename = os.path.join(self.collection_dir, 'removed.txt')
8384 self.generating_templ_filename = os.path.join(self.collection_dir, 'generating.html')
8485 self.finished_templ_filename = os.path.join(self.collection_dir, 'finished.html')
@@ -105,13 +106,14 @@
106107 'license': self.form.getvalue('license'),
107108 'template_blacklist': self.form.getvalue('template_blacklist'),
108109 'removed': self.removed_filename,
 110+ 'progress': self.progress_filename,
109111 'output': self.pdf_filename,
110112 }
111113
112114 os.makedirs(self.collection_dir)
113115 metabook = self.form.getvalue('metabook')
114116 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)
116118 assert rc == 0, 'Execution of mw-pdf failed.'
117119
118120 open(self.generating_templ_filename, 'wb').write(self.form.getvalue('generating_template'))
@@ -149,13 +151,18 @@
150152 html = open(self.error_templ_filename, 'rb').read()
151153 self.render_html(html)
152154 else:
 155+ progress = 0
 156+ try:
 157+ progress = int(open(self.progress_filename, 'rb').read())
 158+ except (IOError, ValueError):
 159+ pass
153160 query_args = urllib.urlencode({
154161 'command': 'pdf_status',
155162 'collection_id': self.collection_id,
156163 })
157164 meta = '<meta http-equiv="refresh" content="5; url=?%s">' % query_args
158165 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)
160167
161168 def do_pdf_download(self):
162169 self.headers['Content-Type'] = 'application/pdf'

Status & tagging log