docraptor / docraptor-python Goto Github PK
View Code? Open in Web Editor NEWA native Python client for the DocRaptor document generation service.
License: Other
A native Python client for the DocRaptor document generation service.
License: Other
We are running Linux OpenSuse LEAP 42.1.
With the latest docraptor==0.2.1 client (Python) we receive the folloing error (likely because of some issue with the local cert store of OpenSuse. I suggest that the Python API should receive an optional parameter verify_cert=True|False (True by default) in order to have a workaround without hacking the Docraptor sources.
Andreas
https://docraptor.com//docs
Traceback (most recent call last):
File "test.py", line 43, in <module>
"document_type": "pdf", # pdf or xls or xlsx
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/apis/doc_api.py", line 203, in create_doc
callback=params.get('callback'))
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/api_client.py", line 325, in call_api
response_type, auth_settings, callback)
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/api_client.py", line 149, in __call_api
post_params=post_params, body=body)
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/api_client.py", line 361, in request
body=body)
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/rest.py", line 204, in POST
body=body)
File "/data/home/ajung/src/zopyx_ne.no/lib/python2.7/site-packages/docraptor/rest.py", line 165, in request
raise ApiException(status=0, reason=msg)
docraptor.rest.ApiException: (0)
Reason: SSLError
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
It's easy for generated clients to return accidentally utf8 encoded data, which ends up corrupting PDF/XLS/XLSX files. Let's add a test to ensure this can never happen.
Using the sample code from the README
$ python3 ./dr.py
Traceback (most recent call last):
File "./dr.py", line 13, in <module>
"document_type": "pdf", # pdf or xls or xlsx
File "/usr/local/lib/python3.5/site-packages/docraptor/apis/doc_api.py", line 203, in create_doc
callback=params.get('callback'))
File "/usr/local/lib/python3.5/site-packages/docraptor/api_client.py", line 322, in call_api
response_type, auth_settings, callback)
File "/usr/local/lib/python3.5/site-packages/docraptor/api_client.py", line 149, in __call_api
post_params=post_params, body=body)
File "/usr/local/lib/python3.5/site-packages/docraptor/api_client.py", line 358, in request
body=body)
File "/usr/local/lib/python3.5/site-packages/docraptor/rest.py", line 208, in POST
body=body)
File "/usr/local/lib/python3.5/site-packages/docraptor/rest.py", line 171, in request
r.data = r.data.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: invalid continuation byte
Python packages support setting the alpha/beta/production status of a build. We started with beta but I think it's time we go to production ready / stable.
After updating urllib3
to more recent version (due to CVE-2023-43804) I'm seeing following warning:
[REDACTED].py: in generate_pdf
response = doc_api.create_async_doc(options)
../venv/lib/python3.10/site-packages/docraptor/api/doc_api.py:67: in create_async_doc
return self.create_async_doc_with_http_info(doc, **kwargs) # noqa: E501
../venv/lib/python3.10/site-packages/docraptor/api/doc_api.py:172: in create_async_doc_with_http_info
return self.api_client.call_api(
../venv/lib/python3.10/site-packages/docraptor/api_client.py:378: in call_api
return self.__call_api(resource_path, method,
../venv/lib/python3.10/site-packages/docraptor/api_client.py:185: in __call_api
response_data = self.request(
../venv/lib/python3.10/site-packages/docraptor/api_client.py:422: in request
return self.rest_client.POST(url,
../venv/lib/python3.10/site-packages/docraptor/rest.py:272: in POST
return self.request("POST", url,
../venv/lib/python3.10/site-packages/docraptor/rest.py:231: in request
raise ApiException(http_resp=r)
../venv/lib/python3.10/site-packages/docraptor/exceptions.py:110: in __init__
self.headers = http_resp.getheaders()
../venv/lib/python3.10/site-packages/docraptor/rest.py:42: in getheaders
return self.urllib3_response.getheaders()
../venv/lib/python3.10/site-packages/urllib3/response.py:667: in getheaders
warnings.warn(
E DeprecationWarning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.
This issue has been fixed in this PR of openapi-generator
and that the fix was released on version v6.4.0
, but this repository is using an older version:
docraptor-python/.generator-revision
Line 1 in b8b08c1
The DocApi.create_doc()
method's docstring includes the wrong return type:
docraptor-python/docraptor/api/doc_api.py
Lines 203 to 206 in 92acc8d
Similarly for DocApi.create_doc_with_http_info
:
docraptor-python/docraptor/api/doc_api.py
Lines 241 to 244 in 92acc8d
The correct return type here are bytes
and tuple(bytes, status_code(int), headers(HTTPHeaderDict))
, respectively.
Since Python 3, str
is reserved for unicode strings, not the byte strings return by HTTP calls.
I know a picture isn't proof but absent a share environment, here's the best I can do.
It doesn't affect the working of the library, but it does anyone using any type checking or type hints, e.g. PyCharm below:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.