|
|
|
@ -32,7 +32,6 @@ class Manager() :
|
|
|
|
|
self.config = args['config']
|
|
|
|
|
self.key = args['key']
|
|
|
|
|
self.actors = args['actors']
|
|
|
|
|
|
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
|
|
|
|
|
|
def status(self) :
|
|
|
|
@ -56,8 +55,38 @@ class Manager() :
|
|
|
|
|
self.LIMIT = -1
|
|
|
|
|
|
|
|
|
|
self.filter(meta)
|
|
|
|
|
if len(self.actors) > 0 :
|
|
|
|
|
self.setup(meta)
|
|
|
|
|
self._filter('scope','apps',meta,self.agents)
|
|
|
|
|
self._filter('','folders',meta,self.agents)
|
|
|
|
|
#if len(self.actors) > 0 :
|
|
|
|
|
# self.setup(meta)
|
|
|
|
|
def _filter(self,id,key,meta,values):
|
|
|
|
|
"""
|
|
|
|
|
This function is designed to perform a filter on a list of values given a full set
|
|
|
|
|
@param id
|
|
|
|
|
@param lvalues
|
|
|
|
|
@param values
|
|
|
|
|
"""
|
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
|
couchdb = self.factory.instance(type=read_class,args=read_args)
|
|
|
|
|
info = couchdb.view('config/'+key,key=self.key)
|
|
|
|
|
|
|
|
|
|
if info is None or (type(info) == list and len(info) == 0) :
|
|
|
|
|
return []
|
|
|
|
|
else:
|
|
|
|
|
#
|
|
|
|
|
# At this point we have a configuration we can keep apps/folders actors
|
|
|
|
|
#
|
|
|
|
|
r = []
|
|
|
|
|
plan = meta[id]
|
|
|
|
|
|
|
|
|
|
for item in values :
|
|
|
|
|
if item.getName() in plan :
|
|
|
|
|
item.init(info)
|
|
|
|
|
r.append(item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filter(self,meta) :
|
|
|
|
|
scope = []
|
|
|
|
@ -69,24 +98,29 @@ class Manager() :
|
|
|
|
|
self.agents = [agent for agent in self.agents if agent.getName() in scope]
|
|
|
|
|
if len(lactors) == 0 :
|
|
|
|
|
self.actors = []
|
|
|
|
|
|
|
|
|
|
self.actors = [ actor for actor in self.actors if actor.geIdentifier() in lactors]
|
|
|
|
|
self.actors = [ actor for actor in self.actors if actor.getIdentifier() in lactors]
|
|
|
|
|
if len(self.actors) > 0 :
|
|
|
|
|
#
|
|
|
|
|
# We should configure the actors accordingly and make sure they are operational
|
|
|
|
|
#
|
|
|
|
|
conf = {"folders":meta['folder_threshold'],"apps":None}
|
|
|
|
|
|
|
|
|
|
conf = {"apps":None}
|
|
|
|
|
#
|
|
|
|
|
# We need to get the configuration for the apps remotely
|
|
|
|
|
#
|
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
|
|
|
|
|
|
couchdb = self.factory.instance(type=read_class,args=read_args)
|
|
|
|
|
uinfo = couchdb.view('config/apps',key=self.key)
|
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
|
conf['apps'] = uinfo['apps']
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Threshold will always give a default value
|
|
|
|
|
#
|
|
|
|
|
info = couchdb.view('config/folders',key=self.key)
|
|
|
|
|
threshold = info
|
|
|
|
|
conf['folder_threshold'] = threshold
|
|
|
|
|
|
|
|
|
|
mailer = None
|
|
|
|
|
for actor in self.actors :
|
|
|
|
|
id = actor.getIdentifier()
|
|
|
|
@ -118,6 +152,9 @@ class Manager() :
|
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
|
conf['apps'] = uinfo['apps']
|
|
|
|
|
|
|
|
|
|
for agent in self.agents :
|
|
|
|
|
agent.init(conf['apps'])
|
|
|
|
|
|
|
|
|
|
mailer = None
|
|
|
|
|
for actor in self.actors :
|
|
|
|
|
id = actor.getIdentifier()
|
|
|
|
@ -183,9 +220,10 @@ class Manager() :
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
index = self.agents.index(agent)
|
|
|
|
|
|
|
|
|
|
if len(self.actors) > index and self.actors[index].getIdentifier() == agent.getName() :
|
|
|
|
|
actor = self.actors[index]
|
|
|
|
|
print self.analyze(row)
|
|
|
|
|
print actor.analyze(row)
|
|
|
|
|
|
|
|
|
|
self.lock.acquire()
|
|
|
|
|
store = self.factory.instance(type=write_class,args=read_args)
|
|
|
|
|