]> git.ipfire.org Git - location/libloc.git/blobdiff - src/python/location.in
location update: Remove double conversion of timestamps
[location/libloc.git] / src / python / location.in
index 5189738c449cb082e0d3cef6b88d57e4818335b7..070640c2ae5cd5a07ce3875e76f444d9a2c6d719 100644 (file)
@@ -401,7 +401,7 @@ class CLI(object):
                        now = datetime.datetime.utcnow()
 
                        # Parse the database timestamp
-                       t = datetime.datetime.fromtimestamp(db.created_at)
+                       t = datetime.datetime.utcfromtimestamp(db.created_at)
 
                        if ns.cron == "daily":
                                delta = datetime.timedelta(days=1)
@@ -413,19 +413,16 @@ class CLI(object):
                        # Check if the database has recently been updated
                        if t >= (now - delta):
                                log.info(
-                                       _("The datase has recently be updated recently (%s)") % \
+                                       _("The database has been updated recently (%s)") % \
                                                format_timedelta(now - t),
                                )
-                               return
+                               return 3
 
                # Fetch the timestamp we need from DNS
                t = location.discover_latest_version()
 
-               # Parse timestamp into datetime format
-               timestamp = datetime.datetime.fromtimestamp(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 +450,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):