]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/libloc-0.9.1-location-query-require-at-least-one-flag.patch
libloc: Import upstream patches.
[ipfire-2.x.git] / src / patches / libloc-0.9.1-location-query-require-at-least-one-flag.patch
1 commit 228d0e74ec47c9954d3a0e1da2e1c0fc6c1b518f
2 Author: Michael Tremer <michael.tremer@ipfire.org>
3 Date: Wed Jun 3 16:15:24 2020 +0000
4
5 location-query: Require at least one flag
6
7 Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
8
9 diff --git a/src/python/location-query.in b/src/python/location-query.in
10 index 5f05b5c..dfdff8c 100644
11 --- a/src/python/location-query.in
12 +++ b/src/python/location-query.in
13 @@ -246,7 +246,13 @@ class CLI(object):
14 args.family = 0
15
16 # Call function
17 - ret = args.func(db, args)
18 + try:
19 + ret = args.func(db, args)
20 +
21 + # Catch invalid inputs
22 + except ValueError as e:
23 + sys.stderr.write("%s\n" % e)
24 + ret = 2
25
26 # Return with exit code
27 if ret:
28 @@ -451,6 +457,9 @@ class CLI(object):
29 if ns.anycast:
30 flags |= location.NETWORK_FLAG_ANYCAST
31
32 + if not flags:
33 + raise ValueError(_("You must at least pass one flag"))
34 +
35 with self.__get_output_formatter(ns) as f:
36 for n in db.search_networks(flags=flags, family=ns.family):
37 f.network(n)