X-Git-Url: http://git.ipfire.org/?p=location%2Flibloc.git;a=blobdiff_plain;f=src%2Fpython%2Flocation.in;h=0d09210d13fd25722252df77a3342cd98f1af385;hp=8cdd1409e34b176d9bb5f832ffc697a3975f61fe;hb=60c1ac0307312614bd6980d30b44bb59b5a6ab6e;hpb=a243587a0e73f74010248ed6483baa7d0d7030d4 diff --git a/src/python/location.in b/src/python/location.in index 8cdd140..0d09210 100644 --- a/src/python/location.in +++ b/src/python/location.in @@ -398,10 +398,7 @@ class CLI(object): def handle_update(self, db, ns): if ns.cron and db: - now = datetime.datetime.utcnow() - - # Parse the database timestamp - t = datetime.datetime.utcfromtimestamp(db.created_at) + now = time.time() if ns.cron == "daily": delta = datetime.timedelta(days=1) @@ -410,22 +407,20 @@ class CLI(object): elif ns.cron == "monthly": delta = datetime.timedelta(days=30) + delta = delta.total_seconds() + # Check if the database has recently been updated - if t >= (now - delta): + if db.created_at >= (now - delta): log.info( - _("The datase has recently be updated recently (%s)") % \ - format_timedelta(now - t), + _("The database has been updated recently"), ) return 3 # Fetch the timestamp we need from DNS t = location.discover_latest_version() - # Parse timestamp into datetime format - timestamp = datetime.datetime.utcfromtimestamp(t) if t else None - # Check the version of the local database - if db and timestamp and db.created_at >= timestamp.timestamp(): + if db and t and db.created_at >= t: log.info("Already on the latest version") return @@ -453,13 +448,7 @@ class CLI(object): return 0 - def handle_verify(self, ns): - try: - db = location.Database(ns.database) - except FileNotFoundError as e: - log.error("%s: %s" % (ns.database, e)) - return 127 - + def handle_verify(self, db, ns): # Verify the database with open(ns.public_key, "r") as f: if not db.verify(f):