Permalink
Browse files

fixed evaluation bug,

updated readme
  • Loading branch information...
Felix Richter Felix Richter
Felix Richter authored and Felix Richter committed Jan 24, 2011
1 parent fc29604 commit d46e1d0bc540268e161e04bf9f339c1dfa0e27f9
Showing with 36 additions and 8 deletions.
  1. +20 −0 README.md
  2. +6 −6 genericore/auto_amqp.py
  3. +10 −2 genericore/utils.py
View
@@ -3,6 +3,11 @@ GENERICORE
This is the python port of genericore, the generic information gathering
framework.
+Disclamer
+---------
+The python-genericore and it's submodules are currently under HEAVY
+development and may suck balls in the current state. I appologize for that.
+
Submodules
==========
Currently the python implementation has the following submodules
@@ -34,6 +39,21 @@ Currently the python implementation has the following submodules
In addition to that, auto\_amqp.py needs to hold a "default parameter"
list called DEFAULT\_CONFIG.
+Configurator
+===========
+
+python-genericore provides a extensive configuration submodule whichs
+allows the modules to evaluate/mix and merge configuration files.
+
+The class *Configurable* provides a basic functionality to load
+configuration into the variable _config_ via load\_conf. this can be used
+to merge two configurations.
+
+In addition to that there is a *Configurator* class which provides basic
+functionality for parsing defaults. please see main.py of mail\_proc how to
+use these two.
+
+
Dependencies
===========
* simplejson
View
@@ -87,11 +87,11 @@ def populate_parser(self,parser):
def eval_parser(self,parsed):
""" loads its individual configuration from the parsed output """
conf = self.config['amqp']['connection']
- conf['host'] = parsed.amqpHost if 'amqpHost' in dir(parsed) else conf['host']
- conf['port'] = parsed.amqpHost if 'amqpPort' in dir(parsed) else conf['port']
- conf['username'] = parsed.amqpHost if 'amqpUsername' in dir(parsed) else conf['username']
- conf['password'] = parsed.amqpHost if 'amqpPassword' in dir(parsed) else conf['password']
- conf['heartbeat'] = parsed.amqpHost if 'amqpHeartbeat' in dir(parsed) else conf['heartbeat']
- conf['vhost'] = parsed.amqpHost if 'amqpVhost' in dir(parsed) else conf['vhost']
+ conf['host'] = parsed.amqpHost if parsed.amqpHost else conf['host']
+ conf['port'] = parsed.amqpPort if parsed.amqpPort else conf['port']
+ conf['login'] = parsed.amqpUsername if parsed.amqpUsername else conf['login']
+ conf['password'] = parsed.amqpPassword if parsed.amqpPassword else conf['password']
+ conf['heartbeat'] = parsed.amqpHeartbeat if parsed.amqpHeartbeat in dir(parsed) else conf['heartbeat']
+ conf['vhost'] = parsed.amqpVhost if parsed.amqpVhost else conf['vhost']
View
@@ -15,7 +15,7 @@ def load_conf(self,new_config):
""" loads and merges configuration from the given dictionary """
if not new_config:
return
- stack = [(self.config, new_config)]
+ stack = [(self.config,new_config)]
while stack:
current_dst, current_src = stack.pop()
for key in current_src:
@@ -45,21 +45,29 @@ def __init__(self,PROTO_VERSION,conf=None):
self.PROTO_VERSION = PROTO_VERSION
def configure(self,conf_list):
+ """ configures all configurable objects with current config """
for i in conf_list:
i.load_conf(self.config)
+
+ def blend(self,conf_list):
+ """ blends all configurations of all configurables into this object """
+ for i in conf_list:
+ self.load_conf(i.config)
+
def populate_parser(self,parser):
parser.add_argument('-c','--config',dest='genConfig', help='configuration file',metavar='FILE')
#parser.add_argument('-d','--debug_level',help='Debug Level')
parser.add_argument('--unique-key',action='store_true', help='Unique Key')
def eval_parser(self,parsed):
if 'genConfig' in dir(parsed):
+ print 'loading file %s' % parsed.genConfig
self.load_conf_file(parsed.genConfig)
if 'unique-key' in dir(parsed):
print self.generate_unique(parsed)
sys.exit(0)
def generate_unique(self,args):
- print(hashlib.sha1(str(self.PROTO_VERSION) +
+ return (hashlib.sha1(str(self.PROTO_VERSION) +
json.dumps(args,sort_keys=True)).hexdigest())

0 comments on commit d46e1d0

Please sign in to comment.