(self, url, type, **kwargs)
| 71 | return cls._instance |
| 72 | |
| 73 | def get(self, url, type, **kwargs): |
| 74 | self.__networkAccessCheck(type) |
| 75 | |
| 76 | headers = self.__getHeaders() |
| 77 | proxies = self.__getProxies() |
| 78 | |
| 79 | try: |
| 80 | resp = requests.get(url, headers=headers, proxies=proxies, **kwargs) |
| 81 | resp.raise_for_status() |
| 82 | return resp |
| 83 | except requests.exceptions.HTTPError as error: |
| 84 | pyfalog.warning('HTTPError:') |
| 85 | pyfalog.warning(error) |
| 86 | if error.response.status_code == 404: |
| 87 | raise RequestError() |
| 88 | elif error.response.status_code == 403: |
| 89 | raise AuthenticationError() |
| 90 | elif error.response.status_code >= 500: |
| 91 | raise ServerError() |
| 92 | raise Error(error) |
| 93 | except requests.exceptions.Timeout: |
| 94 | raise TimeoutError() |
| 95 | except (KeyboardInterrupt, SystemExit): |
| 96 | raise |
| 97 | except Exception as error: |
| 98 | raise Error(error) |
| 99 | |
| 100 | def post(self, url, type, jsonData, **kwargs): |
| 101 | self.__networkAccessCheck(type) |
no test coverage detected