Compare commits

...

14 commits

Author SHA1 Message Date
Lance Edgar f56cb41e69 docs: update project links, kallithea -> forgejo 2024-09-14 12:12:40 -05:00
Lance Edgar 07dda66bae docs: use markdown for readme file 2024-09-13 18:22:48 -05:00
Lance Edgar 949c9ee5a1 bump: version 0.4.5 → 0.4.6 2024-08-19 08:44:10 -05:00
Lance Edgar fa4cb5dc9a fix: avoid deprecated base class for config extension 2024-08-16 10:10:13 -05:00
Lance Edgar 7fe5e9aea6 bump: version 0.4.4 → 0.4.5 2024-07-02 01:23:02 -05:00
Lance Edgar 8021ac818e fix: fix signature for calls to get_engines() 2024-07-02 01:22:37 -05:00
Lance Edgar 55c84c6efe bump: version 0.4.3 → 0.4.4 2024-07-02 00:28:18 -05:00
Lance Edgar 56d7a48e45 fix: avoid deprecated function for engine config 2024-07-02 00:27:59 -05:00
Lance Edgar fe0840d3e0 bump: version 0.4.2 → 0.4.3 2024-07-01 23:22:07 -05:00
Lance Edgar f36759dc48 fix: remove references, dependency for six package 2024-07-01 16:40:46 -05:00
Lance Edgar ff0af6732a bump: version 0.4.1 → 0.4.2 2024-07-01 14:11:57 -05:00
Lance Edgar 6257362534 fix: remove legacy command definitions 2024-07-01 12:20:48 -05:00
Lance Edgar be4d6bfe4d bump: version 0.4.0 → 0.4.1 2024-06-14 17:37:04 -05:00
Lance Edgar f4682c9070 fix: fallback to importlib_metadata on older python 2024-06-14 17:35:23 -05:00
7 changed files with 58 additions and 134 deletions

View file

@ -5,6 +5,42 @@ All notable changes to rattail-tempmon will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## v0.4.6 (2024-08-19)
### Fix
- avoid deprecated base class for config extension
## v0.4.5 (2024-07-02)
### Fix
- fix signature for calls to `get_engines()`
## v0.4.4 (2024-07-02)
### Fix
- avoid deprecated function for engine config
## v0.4.3 (2024-07-01)
### Fix
- remove references, dependency for `six` package
## v0.4.2 (2024-07-01)
### Fix
- remove legacy command definitions
## v0.4.1 (2024-06-14)
### Fix
- fallback to `importlib_metadata` on older python
## v0.4.0 (2024-06-10) ## v0.4.0 (2024-06-10)
### Feat ### Feat

View file

@ -1,6 +1,5 @@
rattail-tempmon # rattail-tempmon
===============
Rattail is a retail software framework, released under the GNU General Public Rattail is a retail software framework, released under the GNU General Public
License. License.
@ -8,6 +7,5 @@ License.
This is the ``rattail-tempmon`` package, which provides a database schema, and This is the ``rattail-tempmon`` package, which provides a database schema, and
client/server daemons for recording and processing temperature data. client/server daemons for recording and processing temperature data.
Please see Rattail's `home page`_ for more information. Please see Rattail's [home page](https://rattailproject.org/) for more
information.
.. _home page: https://rattailproject.org/

View file

@ -6,9 +6,9 @@ build-backend = "hatchling.build"
[project] [project]
name = "rattail-tempmon" name = "rattail-tempmon"
version = "0.4.0" version = "0.4.6"
description = "Retail Software Framework - Temperature monitoring add-on" description = "Retail Software Framework - Temperature monitoring add-on"
readme = "README.rst" readme = "README.md"
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
license = {text = "GNU GPL v3+"} license = {text = "GNU GPL v3+"}
classifiers = [ classifiers = [
@ -24,29 +24,20 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"rattail[db]", "rattail[db]",
"six",
"sqlsoup", "sqlsoup",
] ]
[project.urls] [project.urls]
Homepage = "https://rattailproject.org" Homepage = "https://rattailproject.org"
Repository = "https://kallithea.rattailproject.org/rattail-project/rattail-tempmon" Repository = "https://forgejo.wuttaproject.org/rattail/rattail-tempmon"
Changelog = "https://kallithea.rattailproject.org/rattail-project/rattail-tempmon/files/master/CHANGES.rst" Changelog = "https://forgejo.wuttaproject.org/rattail/rattail-tempmon/src/branch/master/CHANGELOG.md"
[project.entry-points."rattail.config.extensions"] [project.entry-points."rattail.config.extensions"]
tempmon = "rattail_tempmon.config:TempmonConfigExtension" tempmon = "rattail_tempmon.config:TempmonConfigExtension"
[project.entry-points."rattail.subcommands"]
export-hotcooler = "rattail_tempmon.commands:ExportHotCooler"
purge-tempmon = "rattail_tempmon.commands:PurgeTempmon"
tempmon-client = "rattail_tempmon.commands:TempmonClient"
tempmon-problems = "rattail_tempmon.commands:TempmonProblems"
tempmon-server = "rattail_tempmon.commands:TempmonServer"
[project.entry-points."rattail.typer_imports"] [project.entry-points."rattail.typer_imports"]
rattail_tempmon = "rattail_tempmon.commands" rattail_tempmon = "rattail_tempmon.commands"

View file

@ -1,6 +1,9 @@
# -*- coding: utf-8; -*- # -*- coding: utf-8; -*-
from importlib.metadata import version try:
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
__version__ = version('rattail-tempmon') __version__ = version('rattail-tempmon')

View file

@ -32,7 +32,7 @@ from pathlib import Path
import typer import typer
from typing_extensions import Annotated from typing_extensions import Annotated
from rattail.commands import rattail_typer, Subcommand, ImportSubcommand from rattail.commands import rattail_typer
from rattail.commands.typer import importer_command, typer_get_runas_user from rattail.commands.typer import importer_command, typer_get_runas_user
from rattail.commands.importing import ImportCommandHandler from rattail.commands.importing import ImportCommandHandler
@ -156,33 +156,6 @@ def tempmon_server(
daemon.stop() daemon.stop()
class ExportHotCooler(ImportSubcommand):
"""
Export data from Rattail-Tempmon to HotCooler
"""
name = 'export-hotcooler'
description = __doc__.strip()
handler_spec = 'rattail_tempmon.hotcooler.importing.tempmon:FromTempmonToHotCooler'
class PurgeTempmon(Subcommand):
"""
Purge stale data from Tempmon database
"""
name = 'purge-tempmon'
description = __doc__.strip()
def add_parser_args(self, parser):
parser.add_argument('--keep', metavar='DAYS', required=True, type=int,
help="Number of days for which data should be kept.")
parser.add_argument('--dry-run', action='store_true',
help="Go through the full motions and allow logging etc. to "
"occur, but rollback (abort) the transaction at the end.")
def run(self, args):
do_purge(self.config, args.keep, dry_run=args.dry_run, progress=self.progress)
def do_purge(config, keep_days, dry_run=False, progress=None): def do_purge(config, keep_days, dry_run=False, progress=None):
from rattail_tempmon.db import Session, model from rattail_tempmon.db import Session, model
from rattail.db.util import finalize_session from rattail.db.util import finalize_session
@ -205,76 +178,3 @@ def do_purge(config, keep_days, dry_run=False, progress=None):
message="Purging stale readings") message="Purging stale readings")
log.info("deleted %s stale readings", len(readings)) log.info("deleted %s stale readings", len(readings))
finalize_session(session, dry_run=dry_run) finalize_session(session, dry_run=dry_run)
class TempmonClient(Subcommand):
"""
Manage the tempmon-client daemon
"""
name = 'tempmon-client'
description = __doc__.strip()
def add_parser_args(self, parser):
subparsers = parser.add_subparsers(title='subcommands')
start = subparsers.add_parser('start', help="Start daemon")
start.set_defaults(subcommand='start')
stop = subparsers.add_parser('stop', help="Stop daemon")
stop.set_defaults(subcommand='stop')
parser.add_argument('-p', '--pidfile',
help="Path to PID file.", metavar='PATH')
parser.add_argument('-D', '--daemonize', action='store_true',
help="Daemonize when starting.")
def run(self, args):
from rattail_tempmon.client import make_daemon
daemon = make_daemon(self.config, args.pidfile)
if args.subcommand == 'start':
daemon.start(args.daemonize)
elif args.subcommand == 'stop':
daemon.stop()
class TempmonServer(Subcommand):
"""
Manage the tempmon-server daemon
"""
name = 'tempmon-server'
description = __doc__.strip()
def add_parser_args(self, parser):
subparsers = parser.add_subparsers(title='subcommands')
start = subparsers.add_parser('start', help="Start daemon")
start.set_defaults(subcommand='start')
stop = subparsers.add_parser('stop', help="Stop daemon")
stop.set_defaults(subcommand='stop')
parser.add_argument('-p', '--pidfile',
help="Path to PID file.", metavar='PATH')
parser.add_argument('-D', '--daemonize', action='store_true',
help="Daemonize when starting.")
def run(self, args):
from rattail_tempmon.server import make_daemon
daemon = make_daemon(self.config, args.pidfile)
if args.subcommand == 'start':
daemon.start(args.daemonize)
elif args.subcommand == 'stop':
daemon.stop()
class TempmonProblems(Subcommand):
"""
Email report(s) of various Tempmon data problems
"""
name = 'tempmon-problems'
description = __doc__.strip()
def run(self, args):
from rattail_tempmon import problems
problems.disabled_probes(self.config, progress=self.progress)

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2017 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,14 +24,13 @@
Tempmon config extension Tempmon config extension
""" """
from __future__ import unicode_literals, absolute_import from wuttjamaican.db import get_engines
from wuttjamaican.conf import WuttaConfigExtension
from rattail.config import ConfigExtension
from rattail.db.config import get_engines
from rattail_tempmon.db import Session from rattail_tempmon.db import Session
class TempmonConfigExtension(ConfigExtension): class TempmonConfigExtension(WuttaConfigExtension):
""" """
Config extension for tempmon; adds tempmon DB engine/Session etc. Expects Config extension for tempmon; adds tempmon DB engine/Session etc. Expects
something like this in your config: something like this in your config:
@ -53,10 +52,10 @@ class TempmonConfigExtension(ConfigExtension):
def configure(self, config): def configure(self, config):
# tempmon # tempmon
config.tempmon_engines = get_engines(config, section='rattail_tempmon.db') config.tempmon_engines = get_engines(config, 'rattail_tempmon.db')
config.tempmon_engine = config.tempmon_engines.get('default') config.tempmon_engine = config.tempmon_engines.get('default')
Session.configure(bind=config.tempmon_engine) Session.configure(bind=config.tempmon_engine)
# hotcooler # hotcooler
config.hotcooler_engines = get_engines(config, section='hotcooler.db') config.hotcooler_engines = get_engines(config, 'hotcooler.db')
config.hotcooler_engine = config.hotcooler_engines.get('default') config.hotcooler_engine = config.hotcooler_engines.get('default')

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,13 +24,10 @@
Tempmon server daemon Tempmon server daemon
""" """
from __future__ import unicode_literals, absolute_import
import time import time
import datetime import datetime
import logging import logging
import six
import humanize import humanize
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy.exc import OperationalError from sqlalchemy.exc import OperationalError
@ -91,7 +88,7 @@ class TempmonServerDaemon(Daemon):
# first time after DB stop. but in the case of DB stop, # first time after DB stop. but in the case of DB stop,
# subsequent errors will instead match the second test # subsequent errors will instead match the second test
if error.connection_invalidated or ( 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 # only suppress logging for 3 failures, after that we let them go
# TODO: should make the max attempts configurable # TODO: should make the max attempts configurable
@ -99,7 +96,7 @@ class TempmonServerDaemon(Daemon):
log_error = False log_error = False
log.debug("database connection failure #%s: %s", log.debug("database connection failure #%s: %s",
self.failed_checks, self.failed_checks,
six.text_type(error)) str(error))
# send error email unless we're suppressing it for now # send error email unless we're suppressing it for now
if log_error: if log_error: