fix: remove legacy command definitions

This commit is contained in:
Lance Edgar 2024-07-01 12:20:48 -05:00
parent be4d6bfe4d
commit 6257362534
2 changed files with 1 additions and 109 deletions

View file

@ -39,14 +39,6 @@ Changelog = "https://kallithea.rattailproject.org/rattail-project/rattail-tempmo
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

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