mirror of
https://github.com/gogcom/galaxy-integrations-python-api.git
synced 2026-01-02 11:58:14 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
701d3cf522 | ||
|
|
c8083b9006 | ||
|
|
0608ade6d3 | ||
|
|
c349a3df8e | ||
|
|
1fd959a665 | ||
|
|
234a21d085 | ||
|
|
90835ece58 | ||
|
|
9e1c8cfddd | ||
|
|
f7f170b9ca | ||
|
|
8ad5ed76b7 | ||
|
|
7727098c6f |
@@ -1,2 +1,6 @@
|
|||||||
|
-e .
|
||||||
pytest==4.2.0
|
pytest==4.2.0
|
||||||
pytest-flakes==4.0.0
|
pytest-flakes==4.0.0
|
||||||
|
# because of pip bug https://github.com/pypa/pip/issues/4780
|
||||||
|
aiohttp==3.5.4
|
||||||
|
certifi==2019.3.9
|
||||||
|
|||||||
9
setup.py
9
setup.py
@@ -2,9 +2,14 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="galaxy.plugin.api",
|
name="galaxy.plugin.api",
|
||||||
version="0.24",
|
version="0.28",
|
||||||
description="Galaxy python plugin API",
|
description="Galaxy python plugin API",
|
||||||
author='Galaxy team',
|
author='Galaxy team',
|
||||||
author_email='galaxy@gog.com',
|
author_email='galaxy@gog.com',
|
||||||
packages=find_packages(exclude=["tests"])
|
packages=find_packages("src"),
|
||||||
|
package_dir={'': 'src'},
|
||||||
|
install_requires=[
|
||||||
|
"aiohttp==3.5.4",
|
||||||
|
"certifi==2019.3.9"
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -180,8 +180,6 @@ class Server():
|
|||||||
try:
|
try:
|
||||||
result = await callback(*bound_args.args, **bound_args.kwargs)
|
result = await callback(*bound_args.args, **bound_args.kwargs)
|
||||||
self._send_response(request.id, result)
|
self._send_response(request.id, result)
|
||||||
except TypeError:
|
|
||||||
self._send_error(request.id, InvalidParams())
|
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
self._send_error(request.id, MethodNotFound())
|
self._send_error(request.id, MethodNotFound())
|
||||||
except JsonRpcError as error:
|
except JsonRpcError as error:
|
||||||
@@ -20,6 +20,7 @@ class NextStep():
|
|||||||
next_step: str
|
next_step: str
|
||||||
auth_params: Dict[str, str]
|
auth_params: Dict[str, str]
|
||||||
cookies: Optional[List[Cookie]] = None
|
cookies: Optional[List[Cookie]] = None
|
||||||
|
js: Optional[Dict[str, List[str]]] = None
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LicenseInfo():
|
class LicenseInfo():
|
||||||
43
src/galaxy/http.py
Normal file
43
src/galaxy/http.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import asyncio
|
||||||
|
import ssl
|
||||||
|
from http import HTTPStatus
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
import certifi
|
||||||
|
|
||||||
|
from galaxy.api.errors import (
|
||||||
|
AccessDenied, AuthenticationRequired,
|
||||||
|
BackendTimeout, BackendNotAvailable, BackendError, NetworkError, UnknownError
|
||||||
|
)
|
||||||
|
|
||||||
|
class HttpClient:
|
||||||
|
def __init__(self, limit=20, timeout=aiohttp.ClientTimeout(total=60), cookie_jar=None):
|
||||||
|
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
|
ssl_context.load_verify_locations(certifi.where())
|
||||||
|
connector = aiohttp.TCPConnector(limit=limit, timeout=timeout, ssl=ssl_context)
|
||||||
|
self._session = aiohttp.ClientSession(connector=connector, cookie_jar=cookie_jar)
|
||||||
|
|
||||||
|
async def close(self):
|
||||||
|
await self._session.close()
|
||||||
|
|
||||||
|
async def request(self, method, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
response = await self._session.request(method, *args, **kwargs)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
raise BackendTimeout()
|
||||||
|
except aiohttp.ClientConnectionError:
|
||||||
|
raise NetworkError()
|
||||||
|
except aiohttp.ServerDisconnectedError:
|
||||||
|
raise BackendNotAvailable()
|
||||||
|
if response.status == HTTPStatus.UNAUTHORIZED:
|
||||||
|
raise AuthenticationRequired()
|
||||||
|
if response.status == HTTPStatus.FORBIDDEN:
|
||||||
|
raise AccessDenied()
|
||||||
|
if response.status == HTTPStatus.SERVICE_UNAVAILABLE:
|
||||||
|
raise BackendNotAvailable()
|
||||||
|
if response.status >= 500:
|
||||||
|
raise BackendError()
|
||||||
|
if response.status >= 400:
|
||||||
|
raise UnknownError()
|
||||||
|
|
||||||
|
return response
|
||||||
Reference in New Issue
Block a user