[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31135 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31135 - gnunet/src/util |
Date: |
Fri, 6 Dec 2013 11:55:43 +0100 |
Author: wachs
Date: 2013-12-06 11:55:43 +0100 (Fri, 06 Dec 2013)
New Revision: 31135
Added:
gnunet/src/util/gnunet-qr
Modified:
gnunet/src/util/Makefile.am
Log:
basic qr code reading
Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2013-12-06 10:40:15 UTC (rev 31134)
+++ gnunet/src/util/Makefile.am 2013-12-06 10:55:43 UTC (rev 31135)
@@ -128,6 +128,9 @@
libexec_PROGRAMS = \
gnunet-service-resolver
+bin_SCRIPTS =\
+ gnunet-qr
+
bin_PROGRAMS = \
gnunet-resolver \
gnunet-config \
Added: gnunet/src/util/gnunet-qr
===================================================================
--- gnunet/src/util/gnunet-qr (rev 0)
+++ gnunet/src/util/gnunet-qr 2013-12-06 10:55:43 UTC (rev 31135)
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+import sys
+import getopt
+from sys import argv
+try:
+ import zbar
+except ImportError as e:
+ print 'Cannot run gnunet-qr, please install zbar-python'
+ sys.exit (1)
+
+def help ():
+ print 'gnunet-qr\n\
+Scan a QR code using a video device and import\n\
+Arguments mandatory for long options are also mandatory for short options.\n\
+ -d, --device=DEVICE use device DEVICE\n\
+ -h, --help print this help\n\
+Report bugs to address@hidden
+GNUnet home page: http://www.gnu.org/software/gnunet/\n\
+General help using GNU software: http://www.gnu.org/gethelp/'
+
+
+if __name__ == '__main__':
+ # Parse arguments
+ try:
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "hd:", ["help", "device"])
+ except getopt.GetoptError as e:
+ help ()
+ print str (e)
+ exit (1)
+
+ device = '/dev/video0'
+ for o,a in opts:
+ if o in ("-h", "--help"):
+ help ()
+ sys.exit (0)
+ elif o in ("-d", "--device"):
+ device = a
+
+ # create a Processor
+ proc = zbar.Processor()
+
+ # configure the Processor
+ proc.parse_config('enable')
+
+ # initialize the Processor
+ proc.init(device)
+
+ # 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
Property changes on: gnunet/src/util/gnunet-qr
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31135 - gnunet/src/util,
gnunet <=