Refactor Query.get() => Session.get() per SQLAlchemy 1.4

This commit is contained in:
Lance Edgar 2023-02-11 22:24:56 -06:00
parent f7f60eff85
commit 995e0dde0a

View file

@ -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: