[mirrorbrain-commits] r8061 - /trunk/mb/mb/conf.py

From: <poeml_at_mirrorbrain.org>
Date: Thu, 06 May 2010 22:34:55 -0000
Author: poeml
Date: Fri May  7 00:34:54 2010
New Revision: 8061

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8061&view=rev
Log:
mb.conf: read zsync_hashes config parameter from /etc/mirrorbrain.conf

Modified:
    trunk/mb/mb/conf.py

Modified: trunk/mb/mb/conf.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb/conf.py?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- trunk/mb/mb/conf.py (original)
+++ trunk/mb/mb/conf.py Fri May  7 00:34:54 2010
_at_@ -1,8 +1,12 @@
 
 import sys
+import os
 import ConfigParser
 import re
+import mb.mberr
 
+
+boolean_opts = ['zsync_hashes']
 
 class Config:
     """this class sets up a number dictionaries that contain configuration 
_at_@ -22,6 +26,10 @@
         self.dbconfig = {}
         self.mirrorprobe = {}
 
+        if not os.path.exists(conffile):
+            raise mb.mberr.NoConfigfile(conffile, 'No config file found. Please refer to:\n'
+                    'http://mirrorbrain.org/docs/installation/initial_config/#create-mirrorbrain-conf')
+
         cp = ConfigParser.SafeConfigParser()
         try:
             cp.read(conffile)
_at_@ -33,7 +41,6 @@
         # take care of the [general] section
         #
         self.general = dict(cp.items('general'))
-        #print self.general
 
         # transform 'str1, str2, str3' form into a list
         re_clist = re.compile('[, ]+')
_at_@ -54,6 +61,14 @@
                 raise KeyError('The config does not have a section named [%s] '
                                'for the instance %r' % (i, i))
             self.general[i] = dict(cp.items(i))
+            for b in boolean_opts:
+                try:
+                    self.general[i][b] = cp.getboolean(i, b)
+                except ValueError, e:
+                    raise mb.mberr.ConfigError('cannot parse setting in [%s] section: %r' % (i, b + str(e)), conffile)
+                except ConfigParser.NoOptionError, e:
+                    pass
+
 
 
         # all database configs are accessible via self.general, but 
_at_@ -66,9 +81,4 @@
         #
         self.mirrorprobe = dict(cp.items('mirrorprobe'))
 
-        #print self.general
-        #print self.instance
-        #print self.dbconfig
-        #print self.mirrorprobe
 
-




_______________________________________________
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 Thu May 06 2010 - 22:34:56 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT