diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-12-06 14:54:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-12-06 14:54:40 +0000 |
commit | a08a8c698ad069857e5787db662388be09801152 (patch) | |
tree | 73a642c675358012475b7af383037469c549b129 /src/util | |
parent | b264be8a6c07161f96718f0c9e2914596f334fa9 (diff) | |
download | gnunet-a08a8c698ad069857e5787db662388be09801152.tar.gz gnunet-a08a8c698ad069857e5787db662388be09801152.zip |
calling gnunet-uri
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/gnunet-qr.py.in | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py.in index cb0545b96..aca002a70 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py.in | |||
@@ -1,6 +1,7 @@ | |||
1 | #!@PYTHON@ | 1 | #!/usr/bin/python |
2 | import sys | 2 | import sys |
3 | import getopt | 3 | import getopt |
4 | import subprocess | ||
4 | from sys import argv | 5 | from sys import argv |
5 | try: | 6 | try: |
6 | import zbar | 7 | import zbar |
@@ -16,6 +17,7 @@ Arguments mandatory for long options are also mandatory for short options.\n\ | |||
16 | -d, --device=DEVICE use device DEVICE\n\ | 17 | -d, --device=DEVICE use device DEVICE\n\ |
17 | -s, --silent do not show preview windows\n\ | 18 | -s, --silent do not show preview windows\n\ |
18 | -h, --help print this help\n\ | 19 | -h, --help print this help\n\ |
20 | -v, --verbose be verbose\n\ | ||
19 | Report bugs to gnunet-developers@gnu.org.\n\ | 21 | Report bugs to gnunet-developers@gnu.org.\n\ |
20 | GNUnet home page: http://www.gnu.org/software/gnunet/\n\ | 22 | GNUnet home page: http://www.gnu.org/software/gnunet/\n\ |
21 | General help using GNU software: http://www.gnu.org/gethelp/' | 23 | General help using GNU software: http://www.gnu.org/gethelp/' |
@@ -24,10 +26,13 @@ General help using GNU software: http://www.gnu.org/gethelp/' | |||
24 | if __name__ == '__main__': | 26 | if __name__ == '__main__': |
25 | configuration = '' | 27 | configuration = '' |
26 | device = '/dev/video0' | 28 | device = '/dev/video0' |
29 | url = '' | ||
30 | verbose = False | ||
31 | |||
27 | silent = False | 32 | silent = False |
28 | # Parse arguments | 33 | # Parse arguments |
29 | try: | 34 | try: |
30 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:s", ["config","help", "device","silent"]) | 35 | opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config","help", "device","silent","verbose"]) |
31 | except getopt.GetoptError as e: | 36 | except getopt.GetoptError as e: |
32 | help () | 37 | help () |
33 | print str (e) | 38 | print str (e) |
@@ -43,6 +48,8 @@ if __name__ == '__main__': | |||
43 | device = a | 48 | device = a |
44 | elif o in ("-s", "--silent"): | 49 | elif o in ("-s", "--silent"): |
45 | silent = True | 50 | silent = True |
51 | elif o in ("-v", "--verbose"): | ||
52 | silent = True | ||
46 | # create a Processor | 53 | # create a Processor |
47 | proc = zbar.Processor() | 54 | proc = zbar.Processor() |
48 | 55 | ||
@@ -58,9 +65,9 @@ if __name__ == '__main__': | |||
58 | 65 | ||
59 | # enable the preview window | 66 | # enable the preview window |
60 | if (True == silent): | 67 | if (True == silent): |
61 | proc.visible = False | ||
62 | else: | ||
63 | proc.visible = True | 68 | proc.visible = True |
69 | else: | ||
70 | proc.visible = False | ||
64 | 71 | ||
65 | # read at least one barcode (or until window closed) | 72 | # read at least one barcode (or until window closed) |
66 | try: | 73 | try: |
@@ -74,5 +81,20 @@ if __name__ == '__main__': | |||
74 | 81 | ||
75 | # extract results | 82 | # extract results |
76 | for symbol in proc.results: | 83 | for symbol in proc.results: |
77 | # do something useful with results | 84 | # do something useful with results |
78 | print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data \ No newline at end of file | 85 | if (verbose): |
86 | print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data | ||
87 | args = list() | ||
88 | args.append("gnunet-uri") | ||
89 | if (configuration != ''): | ||
90 | args.append ("-c " + str(configuration)) | ||
91 | args.append (url) | ||
92 | if (verbose): | ||
93 | for a in args: | ||
94 | cmd += str (a) | ||
95 | print 'Running ' + cmd | ||
96 | ls_output=subprocess.call(args) | ||
97 | print ls_output | ||
98 | exit (ls_output) | ||
99 | |||
100 | \ No newline at end of file | ||