Compare commits

...

8 Commits
0.16 ... 0.19

Author SHA1 Message Date
Aliaksei Paulouski
d759b4aa85 Increment version 2019-03-28 14:37:30 +01:00
Romuald Juchnowicz-Bierbasz
9b33397827 Add NextStep and pass_login_credentials 2019-03-28 10:20:16 +01:00
Romuald Juchnowicz-Bierbasz
e09e443064 Increment version 2019-03-27 15:15:25 +01:00
Romuald Juchnowicz-Bierbasz
00ed52384a Exclude tests from package 2019-03-27 15:14:29 +01:00
Aliaksei Paulouski
958d9bc0e6 Fix send_message message param name 2019-03-25 11:46:30 +01:00
Pawel Kierski
d73d048ff7 Increment version to 0.17 2019-03-12 16:10:23 +01:00
Aliaksei Paulouski
e06e40f845 Fix duplicated error code 2019-03-12 15:53:42 +01:00
Paweł Kierski
833e6999d7 Return JSON-RPC reponse on generic Exception 2019-03-12 15:38:22 +01:00
5 changed files with 22 additions and 10 deletions

View File

@@ -1,8 +1,6 @@
from galaxy.api.jsonrpc import ApplicationError from galaxy.api.jsonrpc import ApplicationError, UnknownError
class UnknownError(ApplicationError): UnknownError = UnknownError
def __init__(self, data=None):
super().__init__(0, "Unknown error", data)
class AuthenticationRequired(ApplicationError): class AuthenticationRequired(ApplicationError):
def __init__(self, data=None): def __init__(self, data=None):

View File

@@ -25,7 +25,7 @@ class MethodNotFound(JsonRpcError):
class InvalidParams(JsonRpcError): class InvalidParams(JsonRpcError):
def __init__(self): def __init__(self):
super().__init__(-32601, "Invalid params") super().__init__(-32602, "Invalid params")
class Timeout(JsonRpcError): class Timeout(JsonRpcError):
def __init__(self): def __init__(self):
@@ -41,6 +41,10 @@ class ApplicationError(JsonRpcError):
raise ValueError("The error code in reserved range") raise ValueError("The error code in reserved range")
super().__init__(code, message, data) super().__init__(code, message, data)
class UnknownError(ApplicationError):
def __init__(self, data=None):
super().__init__(0, "Unknown error", data)
Request = namedtuple("Request", ["method", "params", "id"], defaults=[{}, None]) Request = namedtuple("Request", ["method", "params", "id"], defaults=[{}, None])
Method = namedtuple("Method", ["callback", "internal", "sensitive_params"]) Method = namedtuple("Method", ["callback", "internal", "sensitive_params"])
@@ -171,8 +175,9 @@ class Server():
self._send_error(request.id, MethodNotFound()) self._send_error(request.id, MethodNotFound())
except JsonRpcError as error: except JsonRpcError as error:
self._send_error(request.id, error) self._send_error(request.id, error)
except Exception: #pylint: disable=broad-except except Exception as e: #pylint: disable=broad-except
logging.exception("Unexpected exception raised in plugin handler") logging.exception("Unexpected exception raised in plugin handler")
self._send_error(request.id, UnknownError(str(e)))
asyncio.create_task(handle()) asyncio.create_task(handle())

View File

@@ -49,6 +49,7 @@ class Plugin():
# implemented by developer # implemented by developer
self._register_method("init_authentication", self.authenticate, sensitive_params=["stored_credentials"]) self._register_method("init_authentication", self.authenticate, sensitive_params=["stored_credentials"])
self._register_method("pass_login_credentials", self.pass_login_credentials)
self._register_method( self._register_method(
"import_owned_games", "import_owned_games",
self.get_owned_games, self.get_owned_games,
@@ -274,6 +275,9 @@ class Plugin():
""" """
raise NotImplementedError() raise NotImplementedError()
async def pass_login_credentials(self, step, credentials, cookies):
raise NotImplementedError()
async def get_owned_games(self): async def get_owned_games(self):
raise NotImplementedError() raise NotImplementedError()
@@ -298,7 +302,7 @@ class Plugin():
async def get_users(self, user_id_list): async def get_users(self, user_id_list):
raise NotImplementedError() raise NotImplementedError()
async def send_message(self, room_id, message): async def send_message(self, room_id, message_text):
raise NotImplementedError() raise NotImplementedError()
async def mark_as_read(self, room_id, last_message_id): async def mark_as_read(self, room_id, last_message_id):

View File

@@ -1,5 +1,5 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Optional from typing import List, Dict, Optional
from galaxy.api.consts import LicenseType, LocalGameState, PresenceState from galaxy.api.consts import LicenseType, LocalGameState, PresenceState
@@ -8,6 +8,11 @@ class Authentication():
user_id: str user_id: str
user_name: str user_name: str
@dataclass
class NextStep():
next_step: str
auth_params: Dict[str, str]
@dataclass @dataclass
class LicenseInfo(): class LicenseInfo():
license_type: LicenseType license_type: LicenseType

View File

@@ -2,9 +2,9 @@ from setuptools import setup, find_packages
setup( setup(
name="galaxy.plugin.api", name="galaxy.plugin.api",
version="0.16", version="0.19",
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() packages=find_packages(exclude=["tests"])
) )