diff --git a/docverter.py b/docverter.py index 33b6057..c1871c7 100644 --- a/docverter.py +++ b/docverter.py @@ -82,14 +82,28 @@ def _process_file(source_text, to_format, from_format, extra_args): temp_file.write(source_text) temp_file.seek(0) - resp = requests.post( - url, + req = requests.Request( + 'POST', url, data={'from': from_format, 'to': to_format}, files={'input_files[]': temp_file}, ) + prepared = req.prepare() + session = requests.Session() + resp = session.send(prepared) + # import pdb; pdb.set_trace() if resp.ok: return resp.text else: + if resp.status_code == 500: + req = prepared + print('**** Got a 500 error from server *****') + print('{}\n{}\n{}\n\n{}'.format( + '-----------START-----------', + req.method + ' ' + req.url, + '\n'.join('{}: {}'.format(k, v) + for k, v in req.headers.items()), + req.body, + )) print('temp_file = %r' % temp_file) print('temp_file.name = %r' % temp_file.name) raise RuntimeError(