[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31136 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31136 - gnunet/src/util |
Date: |
Fri, 6 Dec 2013 13:12:09 +0100 |
Author: wachs
Date: 2013-12-06 13:12:09 +0100 (Fri, 06 Dec 2013)
New Revision: 31136
Added:
gnunet/src/util/gnunet-qr.py.in
Removed:
gnunet/src/util/gnunet-qr
Modified:
gnunet/src/util/Makefile.am
Log:
detect python interpreter
error handling
Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2013-12-06 10:55:43 UTC (rev 31135)
+++ gnunet/src/util/Makefile.am 2013-12-06 12:12:09 UTC (rev 31136)
@@ -137,7 +137,12 @@
$(GNUNET_ECC) \
gnunet-uri
+do_subst = $(SED) -e 's,address@hidden@],$(PYTHON),g'
+gnunet-qr: gnunet-qr.py.in Makefile
+ $(do_subst) < gnunet-qr.py.in > gnunet-qr
+ chmod +x gnunet-qr
+
gnunet_service_resolver_SOURCES = \
gnunet-service-resolver.c
gnunet_service_resolver_LDADD = \
Deleted: gnunet/src/util/gnunet-qr
===================================================================
--- gnunet/src/util/gnunet-qr 2013-12-06 10:55:43 UTC (rev 31135)
+++ gnunet/src/util/gnunet-qr 2013-12-06 12:12:09 UTC (rev 31136)
@@ -1,64 +0,0 @@
-#!/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
Added: gnunet/src/util/gnunet-qr.py.in
===================================================================
--- gnunet/src/util/gnunet-qr.py.in (rev 0)
+++ gnunet/src/util/gnunet-qr.py.in 2013-12-06 12:12:09 UTC (rev 31136)
@@ -0,0 +1,67 @@
address@hidden@
+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
+ 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
Property changes on: gnunet/src/util/gnunet-qr.py.in
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31136 - gnunet/src/util,
gnunet <=