Index: trunk/extensions/Collection/pdf-server/pdfserver.py |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | def json_response(self, data): |
72 | 72 | return { |
73 | 73 | 'content_type': 'application/json', |
74 | | - 'content': simplejson.dumps(data), |
| 74 | + 'content': simplejson.dumps(data).encode('utf-8'), |
75 | 75 | } |
76 | 76 | |
77 | 77 | def error_response(self, error): |
— | — | @@ -127,9 +127,9 @@ |
128 | 128 | result = self.error_response('error executing command %r: %s' % (command, e)) |
129 | 129 | |
130 | 130 | if 'content_type' in result: |
131 | | - print 'Content-Type: %s' % result['content_type'] |
| 131 | + print 'Content-Type: %s' % result['content_type'].encode('utf-8', 'ignore') |
132 | 132 | if 'file_extension' in result: |
133 | | - print 'Content-Disposition: inline;filename="collection.%s"' % result['file_extension'] |
| 133 | + print 'Content-Disposition: inline;filename="collection.%s"' % result['file_extension'].encode('utf-8', 'ignore') |
134 | 134 | content = result.get('content', '') |
135 | 135 | print 'Content-Length: %d' % len(content) |
136 | 136 | print # end of headers |
Index: trunk/extensions/Collection/pdf-server/tests.py |
— | — | @@ -12,14 +12,14 @@ |
13 | 13 | |
14 | 14 | def setup_module(module): |
15 | 15 | pdfserver.cache_dir = tempfile.mkdtemp() |
16 | | - fd, pdfserver.mwpdf_logfile = tempfile.mkstemp() |
| 16 | + fd, pdfserver.mwrender_logfile = tempfile.mkstemp() |
17 | 17 | os.close(fd) |
18 | 18 | fd, pdfserver.mwzip_logfile = tempfile.mkstemp() |
19 | 19 | os.close(fd) |
20 | 20 | |
21 | 21 | def teardown_module(module): |
22 | 22 | shutil.rmtree(pdfserver.cache_dir) |
23 | | - os.unlink(pdfserver.mwpdf_logfile) |
| 23 | + os.unlink(pdfserver.mwrender_logfile) |
24 | 24 | os.unlink(pdfserver.mwzip_logfile) |
25 | 25 | |
26 | 26 | class FakeFieldStorage(object): |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | assert 'no command' in result['error'] |
70 | 70 | |
71 | 71 | def test_missings_args(): |
72 | | - for cmd in ('pdf_generate', 'zip_post'): |
| 72 | + for cmd in ('render', 'zip_post'): |
73 | 73 | result = make_call({ |
74 | 74 | 'command': cmd, |
75 | 75 | }) |
— | — | @@ -76,14 +76,15 @@ |
77 | 77 | |
78 | 78 | def test_no_collection_id(): |
79 | 79 | result = make_call({ |
80 | | - 'command': 'pdf_status', |
| 80 | + 'command': 'render_status', |
81 | 81 | }) |
82 | 82 | assert 'collection ID' in result['error'] |
83 | 83 | |
84 | 84 | def test_pdf_generate(): |
85 | 85 | result = make_call({ |
86 | | - 'command': 'pdf_generate', |
| 86 | + 'command': 'render', |
87 | 87 | 'base_url': 'http://en.wikipedia.org/w/', |
| 88 | + 'writer': 'rl', |
88 | 89 | 'metabook': simplejson.dumps({ |
89 | 90 | 'title': 'A Title', |
90 | 91 | 'subtitle': 'A Subtitle', |
— | — | @@ -101,12 +102,12 @@ |
102 | 103 | while True: |
103 | 104 | time.sleep(0.5) |
104 | 105 | result = make_call({ |
105 | | - 'command': 'pdf_status', |
| 106 | + 'command': 'render_status', |
106 | 107 | 'collection_id': collection_id, |
107 | 108 | }) |
108 | 109 | assert result['collection_id'] == collection_id |
109 | 110 | if result['state'] == 'progress': |
110 | | - progress = result['progress'] |
| 111 | + progress = result['status']['progress'] |
111 | 112 | print 'progress:', progress |
112 | 113 | assert progress >= last_progress |
113 | 114 | last_progress = progress |
— | — | @@ -117,7 +118,7 @@ |
118 | 119 | raise RuntimeError('unexpected state %r' % result['state']) |
119 | 120 | |
120 | 121 | result = make_call({ |
121 | | - 'command': 'pdf_download', |
| 122 | + 'command': 'download', |
122 | 123 | 'collection_id': collection_id, |
123 | 124 | }) |
124 | 125 | assert result == 'pdf' |