diff --git a/rattail_tempmon/commands.py b/rattail_tempmon/commands.py index 5504630..1289ac5 100644 --- a/rattail_tempmon/commands.py +++ b/rattail_tempmon/commands.py @@ -32,8 +32,6 @@ import logging from rattail import commands from rattail.time import localtime, make_utc -from rattail_tempmon.db import Session as TempmonSession, model as tempmon - log = logging.getLogger(__name__) @@ -62,6 +60,8 @@ class PurgeTempmon(commands.Subcommand): "occur, but rollback (abort) the transaction at the end.") def run(self, args): + from rattail_tempmon.db import Session as TempmonSession, model as tempmon + cutoff = localtime(self.config).date() - datetime.timedelta(days=args.keep) cutoff = localtime(self.config, datetime.datetime.combine(cutoff, datetime.time(0))) session = TempmonSession()