- # initialize the Processor
- try:
- proc.init(device)
- except Exception as e:
- print 'Failed to open device ' + device
- exit (1)
-
- # enable the preview window
- proc.visible = True
-
- # read at least one barcode (or until window closed)
- try:
- proc.process_one()
- except Exception as e:
- # Window was closed without finding code
- exit (1)
-
- # hide the preview window
- proc.visible = False
-
- # extract results
- for symbol in proc.results:
- # do something useful with results
- print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data
+ # initialize the Processor
+ try:
+ if (True == verbose):
+ print 'Opening video device ' + device
+ proc.init(device)
+ except Exception as e:
+ print 'Failed to open device ' + device
+ exit (1)
+
+ # enable the preview window
+ #if (True == silent):
+ # proc.visible = True
+ #else:
+ # proc.visible = False
+
+ proc.visible = True
+ # read at least one barcode (or until window closed)
+ try:
+ if (True == verbose):
+ print 'Capturing'
+ proc.process_one()
+ except Exception as e:
+ # Window was closed without finding code
+ exit (1)
+
+ # hide the preview window
+ proc.visible = False
+
+ # extract results
+ for symbol in proc.results:
+ # do something useful with results
+ if (True == verbose):
+ print 'Found ', symbol.type, ' symbol ', '"%s"' % symbol.data
+ args = list()
+ args.append("gnunet-uri")
+ if (configuration != ''):
+ args.append (str("-c " + str(configuration)))
+ args.append (str(symbol.data))
+ cmd = ''
+ for a in args:
+ cmd += " " + str(a)
+ if (verbose):
+ print 'Running `' + cmd +'`'
+ res=subprocess.call(args)
+ if (0 != res):
+ print 'Failed to add URI ' + str(symbol.data)
+ else:
+ print 'Added URI ' + str(symbol.data)
+ exit (res)
+ exit (1)