7 except ImportError as e:
8 print 'Cannot run gnunet-qr, please install zbar-python'
13 Scan a QR code using a video device and import\n\
14 Arguments mandatory for long options are also mandatory for short options.\n\
15 -d, --device=DEVICE use device DEVICE\n\
16 -h, --help print this help\n\
17 Report bugs to gnunet-developers@gnu.org.\n\
18 GNUnet home page: http://www.gnu.org/software/gnunet/\n\
19 General help using GNU software: http://www.gnu.org/gethelp/'
22 if __name__ == '__main__':
25 opts, args = getopt.gnu_getopt(sys.argv[1:], "hd:", ["help", "device"])
26 except getopt.GetoptError as e:
31 device = '/dev/video0'
33 if o in ("-h", "--help"):
36 elif o in ("-d", "--device"):
39 proc = zbar.Processor()
41 # configure the Processor
42 proc.parse_config('enable')
44 # initialize the Processor
47 except Exception as e:
48 print 'Failed to open device ' + device
51 # enable the preview window
54 # read at least one barcode (or until window closed)
57 except Exception as e:
58 # Window was closed without finding code
61 # hide the preview window
65 for symbol in proc.results:
66 # do something useful with results
67 print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data