diff options
author | ng0 <ng0@n0.is> | 2019-02-26 17:00:07 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-02-26 17:00:07 +0000 |
commit | 2f5618398764eeea0cd84aaa40f4e4dad8b64eff (patch) | |
tree | 10371e41ad9c51a26cb05970c3be433ee7aec49f | |
parent | db724d0b09369dc95078744d44c968c1096f7cb2 (diff) | |
download | gnunet-2f5618398764eeea0cd84aaa40f4e4dad8b64eff.tar.gz gnunet-2f5618398764eeea0cd84aaa40f4e4dad8b64eff.zip |
make lint happy
-rwxr-xr-x | src/util/gnunet-qr.py | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/src/util/gnunet-qr.py b/src/util/gnunet-qr.py index 6cb9633f0..d42160ad8 100755 --- a/src/util/gnunet-qr.py +++ b/src/util/gnunet-qr.py | |||
@@ -23,90 +23,90 @@ Arguments mandatory for long options are also mandatory for short options.\n\ | |||
23 | -h, --help print this help\n\ | 23 | -h, --help print this help\n\ |
24 | -v, --verbose be verbose\n\ | 24 | -v, --verbose be verbose\n\ |
25 | Report bugs to gnunet-developers@gnu.org.\n\ | 25 | Report bugs to gnunet-developers@gnu.org.\n\ |
26 | GNUnet home page: http://www.gnu.org/software/gnunet/\n\ | 26 | GNUnet home page: https://gnunet.org/\n\ |
27 | General help using GNU software: http://www.gnu.org/gethelp/') | 27 | General help using GNU software: https://www.gnu.org/gethelp/') |
28 | 28 | ||
29 | 29 | ||
30 | if __name__ == '__main__': | 30 | if __name__ == '__main__': |
31 | configuration = '' | 31 | configuration = '' |
32 | device = '/dev/video0' | 32 | device = '/dev/video0' |
33 | url = '' | 33 | url = '' |
34 | verbose = False | 34 | verbose = False |
35 | silent = False | 35 | silent = False |
36 | # Parse arguments | 36 | # Parse arguments |
37 | try: | 37 | try: |
38 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config", "help", "device", "silent", "verbose"]) | 38 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config", "help", "device", "silent", "verbose"]) |
39 | except getopt.GetoptError as e: | 39 | except getopt.GetoptError as e: |
40 | help() | 40 | help() |
41 | print(str(e)) | 41 | print(str(e)) |
42 | exit(1) | 42 | exit(1) |
43 | for o, a in opts: | 43 | for o, a in opts: |
44 | if o in ("-h", "--help"): | 44 | if o in ("-h", "--help"): |
45 | help() | 45 | help() |
46 | sys.exit(0) | 46 | sys.exit(0) |
47 | elif o in ("-c", "--config"): | 47 | elif o in ("-c", "--config"): |
48 | configuration = a | 48 | configuration = a |
49 | elif o in ("-d", "--device"): | 49 | elif o in ("-d", "--device"): |
50 | device = a | 50 | device = a |
51 | elif o in ("-s", "--silent"): | 51 | elif o in ("-s", "--silent"): |
52 | silent = True | 52 | silent = True |
53 | elif o in ("-v", "--verbose"): | 53 | elif o in ("-v", "--verbose"): |
54 | verbose = True | 54 | verbose = True |
55 | if (True == verbose): | 55 | if (True == verbose): |
56 | print('Initializing') | 56 | print('Initializing') |
57 | # create a Processor | 57 | # create a Processor |
58 | proc = zbar.Processor() | 58 | proc = zbar.Processor() |
59 | 59 | ||
60 | # configure the Processor | 60 | # configure the Processor |
61 | proc.parse_config('enable') | 61 | proc.parse_config('enable') |
62 | 62 | ||
63 | # initialize the Processor | 63 | # initialize the Processor |
64 | try: | 64 | try: |
65 | if (True == verbose): | 65 | if (True == verbose): |
66 | print('Opening video device ' + device) | 66 | print('Opening video device ' + device) |
67 | proc.init(device) | 67 | proc.init(device) |
68 | except Exception as e: | 68 | except Exception as e: |
69 | print('Failed to open device ' + device) | 69 | print('Failed to open device ' + device) |
70 | exit(1) | 70 | exit(1) |
71 | 71 | ||
72 | # enable the preview window | 72 | # enable the preview window |
73 | # if (True == silent): | 73 | # if (True == silent): |
74 | # proc.visible = True | 74 | # proc.visible = True |
75 | # else: | 75 | # else: |
76 | # proc.visible = False | 76 | # proc.visible = False |
77 | 77 | ||
78 | proc.visible = True | 78 | proc.visible = True |
79 | # read at least one barcode (or until window closed) | 79 | # read at least one barcode (or until window closed) |
80 | try: | 80 | try: |
81 | if (True == verbose): | 81 | if (True == verbose): |
82 | print('Capturing') | 82 | print('Capturing') |
83 | proc.process_one() | 83 | proc.process_one() |
84 | except Exception as e: | 84 | except Exception as e: |
85 | # Window was closed without finding code | 85 | # Window was closed without finding code |
86 | exit(1) | 86 | exit(1) |
87 | 87 | ||
88 | # hide the preview window | 88 | # hide the preview window |
89 | proc.visible = False | 89 | proc.visible = False |
90 | 90 | ||
91 | # extract results | 91 | # extract results |
92 | for symbol in proc.results: | 92 | for symbol in proc.results: |
93 | # do something useful with results | 93 | # do something useful with results |
94 | if (True == verbose): | 94 | if (True == verbose): |
95 | print('Found ', symbol.type, ' symbol ', '"%s"' % symbol.data) | 95 | print('Found ', symbol.type, ' symbol ', '"%s"' % symbol.data) |
96 | args = list() | 96 | args = list() |
97 | args.append("gnunet-uri") | 97 | args.append("gnunet-uri") |
98 | if (configuration != ''): | 98 | if (configuration != ''): |
99 | args.append(str("-c " + str(configuration))) | 99 | args.append(str("-c " + str(configuration))) |
100 | args.append(str(symbol.data)) | 100 | args.append(str(symbol.data)) |
101 | cmd = '' | 101 | cmd = '' |
102 | for a in args: | 102 | for a in args: |
103 | cmd += " " + str(a) | 103 | cmd += " " + str(a) |
104 | if (verbose): | 104 | if (verbose): |
105 | print('Running `' + cmd +'`') | 105 | print('Running `' + cmd +'`') |
106 | res = subprocess.call(args) | 106 | res = subprocess.call(args) |
107 | if (0 != res): | 107 | if (0 != res): |
108 | print('Failed to add URI ' + str(symbol.data)) | 108 | print('Failed to add URI ' + str(symbol.data)) |
109 | else: | 109 | else: |
110 | print('Added URI ' + str(symbol.data)) | 110 | print('Added URI ' + str(symbol.data)) |
111 | exit(res) | 111 | exit(res) |
112 | exit(1) | 112 | exit(1) |