]> git.ipfire.org Git - people/ms/libloc.git/blame - src/python/location-importer.in
python: Import downloader from database repository
[people/ms/libloc.git] / src / python / location-importer.in
CommitLineData
78ff0cf2
MT
1#!/usr/bin/python3
2###############################################################################
3# #
4# libloc - A library to determine the location of someone on the Internet #
5# #
6# Copyright (C) 2020 IPFire Development Team <info@ipfire.org> #
7# #
8# This library is free software; you can redistribute it and/or #
9# modify it under the terms of the GNU Lesser General Public #
10# License as published by the Free Software Foundation; either #
11# version 2.1 of the License, or (at your option) any later version. #
12# #
13# This library is distributed in the hope that it will be useful, #
14# but WITHOUT ANY WARRANTY; without even the implied warranty of #
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
16# Lesser General Public License for more details. #
17# #
18###############################################################################
19
20import argparse
21import logging
22import sys
23
24# Load our location module
25import location
3192b66c 26import location.importer
78ff0cf2
MT
27from location.i18n import _
28
29# Initialise logging
30log = logging.getLogger("location.importer")
31log.propagate = 1
32
33class CLI(object):
34 def parse_cli(self):
35 parser = argparse.ArgumentParser(
36 description=_("Location Importer Command Line Interface"),
37 )
38
39 # Global configuration flags
40 parser.add_argument("--debug", action="store_true",
41 help=_("Enable debug output"))
42
43 # version
44 parser.add_argument("--version", action="version",
45 version="%(prog)s @VERSION@")
46
47 args = parser.parse_args()
48
49 # Enable debug logging
50 if args.debug:
51 log.setLevel(logging.DEBUG)
52
53 return args
54
55 def run(self):
56 # Parse command line arguments
57 args = self.parse_cli()
58
59 # Call function
60 ret = self.handle_import(args)
61
62 # Return with exit code
63 if ret:
64 sys.exit(ret)
65
66 # Otherwise just exit
67 sys.exit(0)
68
69 def handle_import(self, ns):
70 pass
71
72
73def main():
74 # Run the command line interface
75 c = CLI()
76 c.run()
77
78main()