GithubHelp home page GithubHelp logo

rolzwy7 / regonapi Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 9.0 93 KB

Python 3 API Client for Polish REGON database (Baza Internetowa Regon - BIR)

License: MIT License

Python 100.00%
bir1 bir11 regon baza polish database polska regon-api api python

regonapi's Introduction

Hi there 👋

regonapi's People

Contributors

damianwasik98 avatar dolohow avatar rolzwy7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

regonapi's Issues

Server returned response (200) with invalid XML

W sytuacji, kiedy serwer BIR1 jest wyłączony dla celów serwisowych, aplikacja wykorzystująca gusregon zwraca błąd w postaci Server returned response (200) with invalid XML: Invalid XML content received (AttValue: " or ' expected, line 8, column 18). mimo, iż korzystam z klauzuli try ... except. Obecnie używam requests.exceptions.ConnectionError co nie wiem, czy jest najlepszym rozwiązaniem.

Traceback wygląda tak:

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/loader.py" in parse_xml
50. forbid_entities=settings.forbid_entities)

File "/opt/venvs/xxx/lib/python3.5/site-packages/defusedxml/lxml.py" in fromstring
143. rootelement = _etree.fromstring(text, parser, base_url=base_url)

File "src/lxml/etree.pyx" in lxml.etree.fromstring
3211.

File "src/lxml/parser.pxi" in lxml.etree._parseMemoryDocument
1877.

File "src/lxml/parser.pxi" in lxml.etree._parseDoc
1765.

File "src/lxml/parser.pxi" in lxml.etree._BaseParser._parseDoc
1127.

File "src/lxml/parser.pxi" in lxml.etree._ParserContext._handleParseResultDoc
601.

File "src/lxml/parser.pxi" in lxml.etree._handleParseResult
711.

File "src/lxml/parser.pxi" in lxml.etree._raiseParseError
640.

During handling of the above exception (AttValue: " or ' expected, line 8, column 18 (, line 8)), another exception occurred:

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/wsdl/bindings/soap.py" in process_reply
170. doc = parse_xml(content, self.transport, settings=client.settings)

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/loader.py" in parse_xml
54. content=content

During handling of the above exception (Invalid XML content received (AttValue: " or ' expected, line 8, column 18)), another exception occurred:

File "/opt/venvs/xxx/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)

File "/opt/venvs/xxx/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)

File "/opt/venvs/xxx/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/formtools/wizard/views.py" in dispatch
248. response = super(WizardView, self).dispatch(request, *args, **kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/formtools/wizard/views.py" in post
303. self.storage.set_step_data(self.steps.current, self.process_step(form))

File "/opt/venvs/xxx/lib/python3.5/site-packages/xxx/service_requests/views.py" in process_step
141. gus = GUS(api_key=settings.BIR1_API_KEY)

File "/opt/venvs/xxx/lib/python3.5/site-packages/gusregon/gus.py" in init
40. self.headers.update({'sid': self._service('Zaloguj', self.api_key)})

File "/opt/venvs/xxx/lib/python3.5/site-packages/gusregon/gus.py" in _service
44. return service(*args, **kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/proxy.py" in call
42. self._op_name, args, kwargs)

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/wsdl/bindings/soap.py" in send
132. return self.process_reply(client, operation_obj, response)

File "/opt/venvs/xxx/lib/python3.5/site-packages/zeep/wsdl/bindings/soap.py" in process_reply
176. content=response.content)

Exception Type: TransportError at /xxx/
Exception Value: Server returned response (200) with invalid XML: Invalid XML content received (AttValue: " or ' expected, line 8, column 18).
Content: b'<html xmlns:v="urn:schemas-microsoft-com:vml"\r\nxmlns:o="urn:schemas-microsoft-com:office:office"\r\nxmlns:w="urn:schemas-microsoft-com:office:word"\r\nxmlns:m="http://schemas.microsoft.com/office/2004/12/omml"\r\nxmlns="http://www.w3.org/TR/REC-html40">\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<link rel=colorSchemeMapping\r\nhref="SERWIS_NIEDOSTEPNY_pliki/colorschememapping.xml">\r\n\r\n<style>\r\n\r\n</style>\r\n\r\n\r\n\r\n<body lang=PL link="#0563C1" vlink="#954F72" style='tab-interval:35.4pt'>\r\n\r\n

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><span\r\nstyle='font-size:72.0pt;line-height:107%;font-family:"Segoe UI Semibold",sans-serif'>SERWIS\r\nNIEDOST\xcaPNY<o:p></o:p>

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><span\r\nstyle='font-size:48.0pt;line-height:107%;font-family:"Segoe UI Semibold",sans-serif'> \r\n<o:p></o:p>

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><span\r\nstyle='mso-fareast-language:PL;mso-no-proof:yes'><![if !vml]><img width=225 height=224\r\nsrc="SERWIS_NIEDOSTEPNY_pliki/image001.jpg" v:shapes="Obraz_x0020_2"><![endif]>

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><span\r\nstyle='font-size:48.0pt;line-height:107%;font-family:"Segoe UI Semibold",sans-serif'>PRZEPRASZAMY<o:p></o:p>

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><a\r\nhref="http://www.stat.gov.pl/">STRONA G\xa3\xd3WNA GUS

\r\n\r\n<p class=MsoNormal align=center style='text-align:center'><span\r\nstyle='mso-fareast-language:PL;mso-no-proof:yes'><![if !vml]><img border=0 width=318 height=159\r\nsrc="SERWIS_NIEDOSTEPNY_pliki/image002.png" v:shapes="Obraz_x0020_3"><![endif]>

\r\n\r\n
\r\n\r\n\r\n\r\n\r\n'

Zastanawiam się, jak mogę przechwycić powyższy błąd, aby zabezpieczyć się przed wysypaniem się własnej aplikacji.

Nowa wersja na pypi.org

Hej, czy moglibyście podbić wersję na pypi.org na taką zawierającą zmiany z przed 9 miesięcy? (requirements.txt i setup.py)

ImportError: cannot import name 'validators'

PyPy 7.1.1 (Python 2.7.13, x64)
macOS Catalina

In [1]: from RegonAPI import RegonAPI
   ...:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-4203aa602030> in <module>()
----> 1 from RegonAPI import RegonAPI

/project/env/site-packages/RegonAPI/__init__.pyc in <module>()
----> 1 from RegonAPI.regon_api import *

/project/env/site-packages/RegonAPI/regon_api.pyc in <module>()
     12 from RegonAPI.exceptions import ApiInvalidBIRVersionProvided
     13 from RegonAPI.exceptions import ApiAuthenticationError
---> 14 from RegonAPI.operations import RegonAPIOperations
     15 from RegonAPI.settings import logging_level
     16 from RegonAPI.settings import logging_file_handler_level

/project/env/site-packages/RegonAPI/operations.pyc in <module>()
      5 from RegonAPI.parsers import parse_xml_response
      6 from RegonAPI.exceptions import ApiUnknownReportNameError
----> 7 from RegonAPI import validators
      8 from RegonAPI.settings import OPERATIONS
      9

/project/env/site-packages/RegonAPI/validators.pyc in <module>()
      5 import re
      6
----> 7 from RegonAPI import converters
      8
      9

/project/env/site-packages/RegonAPI/converters.pyc in <module>()
      6
      7 from RegonAPI.exceptions import RegonConvertionError
----> 8 from RegonAPI import validators
      9
     10
ImportError: cannot import name 'validators'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.