From 995e0dde0acaf7d00cbad8b4d55fb500fc8fd88f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 11 Feb 2023 22:24:56 -0600 Subject: [PATCH] Refactor `Query.get()` => `Session.get()` per SQLAlchemy 1.4 --- rattail_tempmon/client.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/rattail_tempmon/client.py b/rattail_tempmon/client.py index f8694b5..5173c67 100644 --- a/rattail_tempmon/client.py +++ b/rattail_tempmon/client.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -24,15 +24,12 @@ TempMon client daemon """ -from __future__ import unicode_literals, absolute_import - import time import datetime import random import socket import logging -import six from sqlalchemy.exc import OperationalError from sqlalchemy.orm.exc import NoResultFound @@ -86,7 +83,7 @@ class TempmonClient(Daemon): session = Session() try: - client = session.query(tempmon.Client).get(client_uuid) + client = session.get(tempmon.Client, client_uuid) self.delay = client.delay or 60 if client.enabled: for probe in client.enabled_probes(): @@ -111,7 +108,7 @@ class TempmonClient(Daemon): # first time after DB stop. but in the case of DB stop, # subsequent errors will instead match the second test if error.connection_invalidated or ( - 'could not connect to server: Connection refused' in six.text_type(error)): + 'could not connect to server: Connection refused' in str(error)): # only suppress logging for 3 failures, after that we let them go # TODO: should make the max attempts configurable @@ -119,7 +116,7 @@ class TempmonClient(Daemon): log_error = False log.debug("database connection failure #%s: %s", self.failed_checks, - six.text_type(error)) + str(error)) # send error email unless we're suppressing it for now if log_error: