]> git.ipfire.org Git - location/libloc.git/commitdiff
location-query: Add command to show the database version
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 May 2020 14:00:20 +0000 (14:00 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 May 2020 14:25:34 +0000 (14:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-query.in

index 2e03b946e1ede64314b271e0b893c3d9dc30a0df..1768dc4ed84148f38243fb43d6decbefe8b774a7 100644 (file)
@@ -138,6 +138,11 @@ class CLI(object):
                        default="@databasedir@/signing-key.pem", help=_("Public Signing Key"),
                )
 
+               # Show the database version
+               version = subparsers.add_parser("version",
+                       help=_("Show database version"))
+               version.set_defaults(func=self.handle_version)
+
                # lookup an IP address
                lookup = subparsers.add_parser("lookup",
                        help=_("Lookup one or multiple IP addresses"),
@@ -250,6 +255,16 @@ class CLI(object):
                # Otherwise just exit
                sys.exit(0)
 
+       def handle_version(self, db, ns):
+               """
+                       Print the version of the database
+               """
+               t = time.strftime(
+                       "%a, %d %b %Y %H:%M:%S GMT", time.gmtime(db.created_at),
+               )
+
+               print(t)
+
        def handle_lookup(self, db, ns):
                ret = 0