[mirrorbrain-commits] r8297 - in /trunk: mb/mb.py mirrorprobe/mirrorprobe.py tools/scanner.pl

From: <poeml_at_mirrorbrain.org>
Date: Fri, 31 Aug 2012 20:31:00 -0000
Author: poeml
Date: Fri Aug 31 22:30:59 2012
New Revision: 8297

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8297&view=rev
Log:
- further work on r8295: option to specify the configuration file path (issue
  #114)

Modified:
    trunk/mb/mb.py
    trunk/mirrorprobe/mirrorprobe.py
    trunk/tools/scanner.pl

Modified: trunk/mb/mb.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb.py?rev=8297&r1=8296&r2=8297&view=diff
==============================================================================
--- trunk/mb/mb.py	(original)
+++ trunk/mb/mb.py	Fri Aug 31 22:30:59 2012
_at_@ -56,7 +56,8 @@
     def get_optparser(self):
         """Parser for global options (that are not specific to a subcommand)"""
         optparser = cmdln.CmdlnOptionParser(self, version=__version__)
-        optparser.add_option('-c', '--config', default='/etc/mirrorbrain.conf',
+        optparser.add_option('--config', dest="configpath", metavar="CONFIGPATH",
+                             default='/etc/mirrorbrain.conf',
                              help='location of configuration file '
                                   '(default: /etc/mirrorbrain.conf)')
         optparser.add_option('-d', '--debug', action='store_true',
_at_@ -75,7 +76,7 @@
         import os, mb.conf
         if not self.options.brain_instance:
             self.options.brain_instance = os.getenv('MB', default=None)
-        self.config = mb.conf.Config(conffile = self.options.config, instance = self.options.brain_instance)
+        self.config = mb.conf.Config(conffile = self.options.configpath, instance = self.options.brain_instance)
 
         # set up the database connection
         import mb.conn
_at_@ -800,6 +801,8 @@
         cmd = []
         cmd.append(opts.scanner or '/usr/bin/scanner')
 
+        if self.options.configpath:
+            cmd.append('--config %s' % self.options.configpath)
         if self.options.brain_instance:
             cmd.append('-b %s' % self.options.brain_instance)
 

Modified: trunk/mirrorprobe/mirrorprobe.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrorprobe/mirrorprobe.py?rev=8297&r1=8296&r2=8297&view=diff
==============================================================================
--- trunk/mirrorprobe/mirrorprobe.py	(original)
+++ trunk/mirrorprobe/mirrorprobe.py	Fri Aug 31 22:30:59 2012
_at_@ -145,8 +145,18 @@
     if '-b' in sys.argv:
         brain_instance = sys.argv[sys.argv.index('-b') + 1]
 
+    configpath = '/etc/mirrorbrain.conf'
+    if '--config' in sys.argv:
+        configpath = sys.argv[sys.argv.index('--config') + 1]
+
     import mb.conf
-    config = mb.conf.Config(instance = brain_instance)
+    import mb.mberr
+    try:
+        config = mb.conf.Config(conffile = configpath, instance = brain_instance)
+    except mb.mberr.NoConfigfile, e:
+        print >>sys.stderr, e.msg
+        sys.exit(1)
+
 
 
     LOGLEVEL = config.mirrorprobe.get('loglevel', 'INFO')
_at_@ -158,6 +168,11 @@
     #
     parser = OptionParser(usage="%prog [options] [<mirror identifier>+]", version="%prog 1.0")
 
+    parser.add_option("--config",
+                      dest="configpath",
+                      default='/etc/mirrorbrain.conf',
+                      help="location of the configuration file",
+                      metavar="CONFIGPATH")
     parser.add_option("-b", "--brain-instance",
                       dest="brain_instance",
                       default=None,

Modified: trunk/tools/scanner.pl
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/tools/scanner.pl?rev=8297&r1=8296&r2=8297&view=diff
==============================================================================
--- trunk/tools/scanner.pl	(original)
+++ trunk/tools/scanner.pl	Fri Aug 31 22:30:59 2012
_at_@ -125,6 +125,7 @@
 	elsif ($arg =~ m{^-e})                 { $enable_after_scan++; }
 	elsif ($arg =~ m{^-f})                 { $force_scan++; }
 	elsif ($arg =~ m{^-d})                 { $start_dir = shift; }
+	elsif ($arg =~ m{^--config})           { $cfgfile = shift; }
 	elsif ($arg =~ m{^-b})                 { $brain_instance = shift; }
 	elsif ($arg =~ m{^-l})                 { $list_only++; 
 						 $list_only++ if $arg =~ m{ll}; 




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Fri Aug 31 2012 - 20:31:02 GMT

This archive was generated by hypermail 2.3.0 : Fri Aug 31 2012 - 20:32:08 GMT