diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-12-06 16:25:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-12-06 16:25:50 +0000 |
commit | 2c30f1f771195b1be3439908d2291bcc717986bb (patch) | |
tree | d491e84cfba821c2e5583222bb14b3f48c310f58 /src/util | |
parent | df5c2d0c0b1f81967590bbcdc48ce19c6042c272 (diff) | |
download | gnunet-2c30f1f771195b1be3439908d2291bcc717986bb.tar.gz gnunet-2c30f1f771195b1be3439908d2291bcc717986bb.zip |
not working
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/gnunet-qr.py.in | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py.in index aca002a70..6f6118b28 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py.in | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/python | 1 | #@PYTHON@ |
2 | import sys | 2 | import sys |
3 | import getopt | 3 | import getopt |
4 | import subprocess | 4 | import subprocess |
@@ -28,7 +28,6 @@ if __name__ == '__main__': | |||
28 | device = '/dev/video0' | 28 | device = '/dev/video0' |
29 | url = '' | 29 | url = '' |
30 | verbose = False | 30 | verbose = False |
31 | |||
32 | silent = False | 31 | silent = False |
33 | # Parse arguments | 32 | # Parse arguments |
34 | try: | 33 | try: |
@@ -37,19 +36,21 @@ if __name__ == '__main__': | |||
37 | help () | 36 | help () |
38 | print str (e) | 37 | print str (e) |
39 | exit (1) | 38 | exit (1) |
40 | 39 | print "asdsa" | |
41 | for o,a in opts: | 40 | for o,a in opts: |
42 | if o in ("-h", "--help"): | 41 | if o in ("-h", "--help"): |
43 | help () | 42 | help () |
44 | sys.exit (0) | 43 | sys.exit (0) |
45 | elif o in ("-c", "--config"): | 44 | elif o in ("-c", "--config"): |
46 | configuration = a | 45 | configuration = a |
47 | elif o in ("-d", "--device"): | 46 | elif o in ("-d", "--device"): |
48 | device = a | 47 | device = a |
49 | elif o in ("-s", "--silent"): | 48 | elif o in ("-s", "--silent"): |
50 | silent = True | 49 | silent = True |
51 | elif o in ("-v", "--verbose"): | 50 | elif o in ("-v", "--verbose"): |
52 | silent = True | 51 | verbose = True |
52 | id (True == verbose): | ||
53 | print 'Initializing' | ||
53 | # create a Processor | 54 | # create a Processor |
54 | proc = zbar.Processor() | 55 | proc = zbar.Processor() |
55 | 56 | ||
@@ -58,19 +59,24 @@ if __name__ == '__main__': | |||
58 | 59 | ||
59 | # initialize the Processor | 60 | # initialize the Processor |
60 | try: | 61 | try: |
62 | id (True == verbose): | ||
63 | print 'Opening video device ' + device | ||
61 | proc.init(device) | 64 | proc.init(device) |
62 | except Exception as e: | 65 | except Exception as e: |
63 | print 'Failed to open device ' + device | 66 | print 'Failed to open device ' + device |
64 | exit (1) | 67 | exit (1) |
65 | 68 | ||
66 | # enable the preview window | 69 | # enable the preview window |
67 | if (True == silent): | 70 | #if (True == silent): |
68 | proc.visible = True | 71 | # proc.visible = True |
69 | else: | 72 | #else: |
70 | proc.visible = False | 73 | # proc.visible = False |
71 | 74 | ||
75 | proc.visible = True | ||
72 | # read at least one barcode (or until window closed) | 76 | # read at least one barcode (or until window closed) |
73 | try: | 77 | try: |
78 | id (True == verbose): | ||
79 | print 'Capturing' | ||
74 | proc.process_one() | 80 | proc.process_one() |
75 | except Exception as e: | 81 | except Exception as e: |
76 | # Window was closed without finding code | 82 | # Window was closed without finding code |
@@ -82,19 +88,20 @@ if __name__ == '__main__': | |||
82 | # extract results | 88 | # extract results |
83 | for symbol in proc.results: | 89 | for symbol in proc.results: |
84 | # do something useful with results | 90 | # do something useful with results |
85 | if (verbose): | 91 | if (True == verbose): |
86 | print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data | 92 | print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data |
87 | args = list() | 93 | args = list() |
88 | args.append("gnunet-uri") | 94 | args.append("gnunet-uri") |
89 | if (configuration != ''): | 95 | if (configuration != ''): |
90 | args.append ("-c " + str(configuration)) | 96 | args.append (str("-c " + str(configuration))) |
91 | args.append (url) | 97 | args.append (str(symbol.data)) |
98 | cmd = '' | ||
99 | for a in args: | ||
100 | cmd += " " + str(a) | ||
92 | if (verbose): | 101 | if (verbose): |
93 | for a in args: | ||
94 | cmd += str (a) | ||
95 | print 'Running ' + cmd | 102 | print 'Running ' + cmd |
96 | ls_output=subprocess.call(args) | 103 | res=subprocess.call(args) |
97 | print ls_output | 104 | if (0 != res): |
98 | exit (ls_output) | 105 | print 'Failed to ' |
99 | 106 | exit (res) | |
100 | \ No newline at end of file | 107 | exit (1) |