]> git.ipfire.org Git - location/libloc.git/blobdiff - src/python/location.in
location: End lookup after an invalid IP address was passed
[location/libloc.git] / src / python / location.in
index 070640c2ae5cd5a07ce3875e76f444d9a2c6d719..6885ea02b5765c4a8d1973162eed5ba9a76bdb56 100644 (file)
@@ -253,6 +253,7 @@ class CLI(object):
                                network = db.lookup(address)
                        except ValueError:
                                print(_("Invalid IP address: %s") % address, file=sys.stderr)
+                               return 2
 
                        args = {
                                "address" : address,
@@ -398,10 +399,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,11 +408,12 @@ 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 database has been updated recently (%s)") % \
-                                               format_timedelta(now - t),
+                                       _("The database has been updated recently"),
                                )
                                return 3