]> git.ipfire.org Git - location/libloc.git/blobdiff - src/python/location.in
location.in: do not confuse UTC with local time zones
[location/libloc.git] / src / python / location.in
index 8cdd1409e34b176d9bb5f832ffc697a3975f61fe..0d09210d13fd25722252df77a3342cd98f1af385 100644 (file)
@@ -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):