8 except ImportError as e:
9 print 'Cannot run gnunet-qr, please install zbar-python'
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\
16 -c, --config=FILENAME use configuration file FILENAME\n\
17 -d, --device=DEVICE use device DEVICE\n\
18 -s, --silent do not show preview windows\n\
19 -h, --help print this help\n\
20 -v, --verbose be verbose\n\
21 Report bugs to gnunet-developers@gnu.org.\n\
22 GNUnet home page: http://www.gnu.org/software/gnunet/\n\
23 General help using GNU software: http://www.gnu.org/gethelp/'
26 if __name__ == '__main__':
28 device = '/dev/video0'
34 opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config","help", "device","silent","verbose"])
35 except getopt.GetoptError as e:
40 if o in ("-h", "--help"):
43 elif o in ("-c", "--config"):
45 elif o in ("-d", "--device"):
47 elif o in ("-s", "--silent"):
49 elif o in ("-v", "--verbose"):
54 proc = zbar.Processor()
56 # configure the Processor
57 proc.parse_config('enable')
59 # initialize the Processor
62 print 'Opening video device ' + device
64 except Exception as e:
65 print 'Failed to open device ' + device
68 # enable the preview window
72 # proc.visible = False
75 # read at least one barcode (or until window closed)
80 except Exception as e:
81 # Window was closed without finding code
84 # hide the preview window
88 for symbol in proc.results:
89 # do something useful with results
91 print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data
93 args.append("gnunet-uri")
94 if (configuration != ''):
95 args.append (str("-c " + str(configuration)))
96 args.append (str(symbol.data))
101 print 'Running `' + cmd +'`'
102 res=subprocess.call(args)
104 print 'Failed to add URI ' + str(symbol.data)
106 print 'Added URI ' + str(symbol.data)