From f7e0575167cd9084dc089c88f9e5b4d65966923d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 21 Dec 2022 18:26:42 +0000 Subject: [PATCH 1/2] LICENSE: Linting EOF blank line added. --- LICENSE | 1 - 1 file changed, 1 deletion(-) diff --git a/LICENSE b/LICENSE index 8cdb8451..23cb7903 100644 --- a/LICENSE +++ b/LICENSE @@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. - From 292b449cf68be4b189986bf2b867d6c30c041785 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 22 Dec 2022 09:15:16 +0000 Subject: [PATCH 2/2] Fix up companion.Session.close() refactor * When PyCharm made a mess I accidentally undid two renames in EDMarketConnector.py... * ... but one of those actually *does* need to only close the session. So made a new Session.close() that performs only the closing, with Session.reinit_session() now utilising that. --- EDMarketConnector.py | 2 +- companion.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 8dd45f8c..bed58e99 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1253,7 +1253,7 @@ class AppWindow(object): except companion.CredentialsRequireRefresh: # We need to 'close' the auth else it'll see STATE_OK and think login() isn't needed - companion.session.close() + companion.session.reinit_session() # LANG: Frontier CAPI Access Token expired, trying to get a new one self.status['text'] = _('CAPI: Refreshing access token...') if companion.session.login(): diff --git a/companion.py b/companion.py index 725c9101..41fc3b7d 100644 --- a/companion.py +++ b/companion.py @@ -732,6 +732,14 @@ class Session(object): self.auth = None raise # Bad thing happened + def close(self) -> None: + """Close the `request.Session().""" + try: + self.requests_session.close() + + except Exception as e: + logger.debug('Frontier Auth: closing', exc_info=e) + def reinit_session(self, reopen: bool = True) -> None: """ Re-initialise the session's `request.Session()`. @@ -739,11 +747,7 @@ class Session(object): :param reopen: Whether to open a new session. """ self.state = Session.STATE_INIT - try: - self.requests_session.close() - - except Exception as e: - logger.debug('Frontier Auth: closing', exc_info=e) + self.close() if reopen: self.requests_session = requests.Session()