From 8c97f44ec0bb8d0d33f5f73e74a490a193159751 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Thu, 11 Aug 2022 18:44:04 +0200 Subject: [PATCH 1/3] [AsyncTools] add log_exceptions param --- octobot_commons/asyncio_tools.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/octobot_commons/asyncio_tools.py b/octobot_commons/asyncio_tools.py index c8d14ccb..1030c7b3 100644 --- a/octobot_commons/asyncio_tools.py +++ b/octobot_commons/asyncio_tools.py @@ -19,22 +19,22 @@ import octobot_commons.constants as constants import octobot_commons.logging as logging_util -LOGGER = logging_util.get_logger("asyncio_tools") - -def run_coroutine_in_asyncio_loop(coroutine, async_loop): +def run_coroutine_in_asyncio_loop(coroutine, async_loop, log_exceptions=True): """ Run a coroutine in the specified asyncio loop :param coroutine: the coroutine to run :param async_loop: the asyncio loop + :param log_exceptions: logs exceptions when True :return: the execution result """ + logger = logging_util.get_logger("asyncio_tools") current_task_before_start = asyncio.current_task(async_loop) future = asyncio.run_coroutine_threadsafe(coroutine, async_loop) try: return future.result(constants.DEFAULT_FUTURE_TIMEOUT) except asyncio.TimeoutError as timeout_error: - LOGGER.error( + logger.error( f"{coroutine} coroutine took too long to execute, cancelling the task. " f"(current task before starting this one: {current_task_before_start}, actual current " f"task before cancel: {asyncio.current_task(async_loop)})" @@ -42,11 +42,12 @@ def run_coroutine_in_asyncio_loop(coroutine, async_loop): future.cancel() raise timeout_error except Exception as global_exception: - LOGGER.exception( - global_exception, - True, - f"{coroutine} coroutine raised an exception: {global_exception}", - ) + if log_exceptions: + logger.exception( + global_exception, + True, + f"{coroutine} coroutine raised an exception: {global_exception}", + ) raise global_exception From 2de3f24595654f613518b09a72f3e796eb6dec06 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Thu, 11 Aug 2022 18:44:42 +0200 Subject: [PATCH 2/3] [Authentication] add must_be_authenticated_through_authenticator --- octobot_commons/authentication.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/octobot_commons/authentication.py b/octobot_commons/authentication.py index 127e68a9..3131f24f 100644 --- a/octobot_commons/authentication.py +++ b/octobot_commons/authentication.py @@ -69,6 +69,13 @@ def is_logged_in(self): """ raise NotImplementedError + @abc.abstractmethod + def must_be_authenticated_through_authenticator(self): + """ + :return: True when this authenticator has to be validated + """ + raise NotImplementedError + @abc.abstractmethod def ensure_token_validity(self): """ From e8c5755132641994e9e628ab0193b68f73d27f50 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Thu, 11 Aug 2022 18:48:50 +0200 Subject: [PATCH 3/3] [Version] v1.7.13 --- CHANGELOG.md | 5 +++++ README.md | 2 +- octobot_commons/__init__.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7f9435..54145237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.7.13] - 2022-08-11 +### Updated +- [Authenticator] API +- [AsyncTool] API + ## [1.7.12] - 2022-08-10 ### Updated - [Authenticator] API diff --git a/README.md b/README.md index fdf562f0..c429ac66 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OctoBot-Commons [1.7.12](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md) +# OctoBot-Commons [1.7.13](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b31f3ab3511744a5a5ca6b9bb48e77bb)](https://app.codacy.com/gh/Drakkar-Software/OctoBot-Commons?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot-Commons&utm_campaign=Badge_Grade_Dashboard) [![PyPI](https://img.shields.io/pypi/v/OctoBot-Commons.svg)](https://pypi.python.org/pypi/OctoBot-Commons/) [![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot-Commons/badge.svg?branch=master)](https://coveralls.io/github/Drakkar-Software/OctoBot-Commons?branch=master) diff --git a/octobot_commons/__init__.py b/octobot_commons/__init__.py index f0ac1765..f7b9918d 100644 --- a/octobot_commons/__init__.py +++ b/octobot_commons/__init__.py @@ -16,7 +16,7 @@ # License along with this library. PROJECT_NAME = "OctoBot-Commons" -VERSION = "1.7.12" # major.minor.revision +VERSION = "1.7.13" # major.minor.revision MARKET_SEPARATOR = "/" DICT_BULLET_TOKEN_STR = "\n "