gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31138 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r31138 - gnunet/src/util
Date: Fri, 6 Dec 2013 13:26:29 +0100

Author: wachs
Date: 2013-12-06 13:26:29 +0100 (Fri, 06 Dec 2013)
New Revision: 31138

Modified:
   gnunet/src/util/gnunet-qr.py.in
Log:
added config + silent mode


Modified: gnunet/src/util/gnunet-qr.py.in
===================================================================
--- gnunet/src/util/gnunet-qr.py.in     2013-12-06 12:23:19 UTC (rev 31137)
+++ gnunet/src/util/gnunet-qr.py.in     2013-12-06 12:26:29 UTC (rev 31138)
@@ -12,7 +12,9 @@
  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\
+  -c, --config=FILENAME      use configuration file FILENAME\n\
   -d, --device=DEVICE        use device DEVICE\n\
+  -s, --silent               do not show preview windows\n\
   -h, --help                 print this help\n\
 Report bugs to address@hidden
 GNUnet home page: http://www.gnu.org/software/gnunet/\n\
@@ -20,48 +22,57 @@
 
 
 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()
+       configuration = ''
+       device = '/dev/video0'
+       silent = False
+       # Parse arguments
+       try:
+               opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:s", 
["config","help", "device","silent"])
+       except getopt.GetoptError as e:
+               help ()
+               print str (e)
+               exit (1)
 
-    # configure the Processor
-    proc.parse_config('enable')
+               for o,a in opts:
+                       if o in ("-h", "--help"):
+                               help ()            
+                               sys.exit (0)
+                       elif o in ("-c", "--config"):
+                               configuration = a
+                       elif o in ("-d", "--device"):
+                               device = a
+                       elif o in ("-s", "--silent"):
+                               silent = True
+       # create a Processor
+       proc = zbar.Processor()
 
-    # initialize the Processor
-    try:
-        proc.init(device)
-    except Exception as e:
-        print 'Failed to open device ' + device
-        exit (1)
+       # configure the Processor
+       proc.parse_config('enable')
 
-    # 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:
+               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
+       
+       # 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
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]