diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-03-02 10:10:26 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-03-02 10:26:55 +0100 |
commit | 3ad3c0a1fb4227dc4525db9baf1a796801acaf43 (patch) | |
tree | 64a8c109942669f5fe7af7f0ee71bb2b35c6db33 /src | |
parent | 0f495e52f9d0011d95658f22e4f403653ba94230 (diff) | |
download | gnunet-3ad3c0a1fb4227dc4525db9baf1a796801acaf43.tar.gz gnunet-3ad3c0a1fb4227dc4525db9baf1a796801acaf43.zip |
better py3 support
Diffstat (limited to 'src')
-rwxr-xr-x | src/util/gnunet-qr.py.in | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py.in index ced7a5441..549ce5af1 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py.in | |||
@@ -6,11 +6,11 @@ from sys import argv | |||
6 | try: | 6 | try: |
7 | import zbar | 7 | import zbar |
8 | except ImportError as e: | 8 | except ImportError as e: |
9 | print 'Cannot run gnunet-qr, please install zbar-python' | 9 | print('Cannot run gnunet-qr, please install zbar-python') |
10 | sys.exit (1) | 10 | sys.exit (1) |
11 | 11 | ||
12 | def help (): | 12 | def help (): |
13 | print 'gnunet-qr\n\ | 13 | print('gnunet-qr\n\ |
14 | Scan a QR code using a video device and import\n\ | 14 | Scan a QR code using a video device and import\n\ |
15 | Arguments mandatory for long options are also mandatory for short options.\n\ | 15 | Arguments mandatory for long options are also mandatory for short options.\n\ |
16 | -c, --config=FILENAME use configuration file FILENAME\n\ | 16 | -c, --config=FILENAME use configuration file FILENAME\n\ |
@@ -20,7 +20,7 @@ Arguments mandatory for long options are also mandatory for short options.\n\ | |||
20 | -v, --verbose be verbose\n\ | 20 | -v, --verbose be verbose\n\ |
21 | Report bugs to gnunet-developers@gnu.org.\n\ | 21 | Report bugs to gnunet-developers@gnu.org.\n\ |
22 | GNUnet home page: http://www.gnu.org/software/gnunet/\n\ | 22 | GNUnet home page: http://www.gnu.org/software/gnunet/\n\ |
23 | General help using GNU software: http://www.gnu.org/gethelp/' | 23 | General help using GNU software: http://www.gnu.org/gethelp/') |
24 | 24 | ||
25 | 25 | ||
26 | if __name__ == '__main__': | 26 | if __name__ == '__main__': |
@@ -34,7 +34,7 @@ if __name__ == '__main__': | |||
34 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config","help", "device","silent","verbose"]) | 34 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config","help", "device","silent","verbose"]) |
35 | except getopt.GetoptError as e: | 35 | except getopt.GetoptError as e: |
36 | help () | 36 | help () |
37 | print str (e) | 37 | print(str (e)) |
38 | exit (1) | 38 | exit (1) |
39 | for o,a in opts: | 39 | for o,a in opts: |
40 | if o in ("-h", "--help"): | 40 | if o in ("-h", "--help"): |
@@ -49,7 +49,7 @@ if __name__ == '__main__': | |||
49 | elif o in ("-v", "--verbose"): | 49 | elif o in ("-v", "--verbose"): |
50 | verbose = True | 50 | verbose = True |
51 | if (True == verbose): | 51 | if (True == verbose): |
52 | print 'Initializing' | 52 | print('Initializing') |
53 | # create a Processor | 53 | # create a Processor |
54 | proc = zbar.Processor() | 54 | proc = zbar.Processor() |
55 | 55 | ||
@@ -59,10 +59,10 @@ if __name__ == '__main__': | |||
59 | # initialize the Processor | 59 | # initialize the Processor |
60 | try: | 60 | try: |
61 | if (True == verbose): | 61 | if (True == verbose): |
62 | print 'Opening video device ' + device | 62 | print('Opening video device ' + device) |
63 | proc.init(device) | 63 | proc.init(device) |
64 | except Exception as e: | 64 | except Exception as e: |
65 | print 'Failed to open device ' + device | 65 | print('Failed to open device ' + device) |
66 | exit (1) | 66 | exit (1) |
67 | 67 | ||
68 | # enable the preview window | 68 | # enable the preview window |
@@ -75,7 +75,7 @@ if __name__ == '__main__': | |||
75 | # read at least one barcode (or until window closed) | 75 | # read at least one barcode (or until window closed) |
76 | try: | 76 | try: |
77 | if (True == verbose): | 77 | if (True == verbose): |
78 | print 'Capturing' | 78 | print('Capturing') |
79 | proc.process_one() | 79 | proc.process_one() |
80 | except Exception as e: | 80 | except Exception as e: |
81 | # Window was closed without finding code | 81 | # Window was closed without finding code |
@@ -88,7 +88,7 @@ if __name__ == '__main__': | |||
88 | for symbol in proc.results: | 88 | for symbol in proc.results: |
89 | # do something useful with results | 89 | # do something useful with results |
90 | if (True == verbose): | 90 | if (True == verbose): |
91 | print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data | 91 | print('Found ', symbol.type, ' symbol ', '"%s"' % symbol.data) |
92 | args = list() | 92 | args = list() |
93 | args.append("gnunet-uri") | 93 | args.append("gnunet-uri") |
94 | if (configuration != ''): | 94 | if (configuration != ''): |
@@ -98,11 +98,11 @@ if __name__ == '__main__': | |||
98 | for a in args: | 98 | for a in args: |
99 | cmd += " " + str(a) | 99 | cmd += " " + str(a) |
100 | if (verbose): | 100 | if (verbose): |
101 | print 'Running `' + cmd +'`' | 101 | print('Running `' + cmd +'`') |
102 | res=subprocess.call(args) | 102 | res=subprocess.call(args) |
103 | if (0 != res): | 103 | if (0 != res): |
104 | print 'Failed to add URI ' + str(symbol.data) | 104 | print('Failed to add URI ' + str(symbol.data)) |
105 | else: | 105 | else: |
106 | print 'Added URI ' + str(symbol.data) | 106 | print('Added URI ' + str(symbol.data)) |
107 | exit (res) | 107 | exit (res) |
108 | exit (1) | 108 | exit (1) |