mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 22:32:21 +03:00
merge conflicts
This commit is contained in:
commit
390d1f3b12
4 changed files with 52 additions and 0 deletions
|
@ -10,6 +10,7 @@ from base.messaging.MessageReceiver import MessageReceiver
|
||||||
from base.messaging.MessageSender import MessageSender
|
from base.messaging.MessageSender import MessageSender
|
||||||
from base.registration.Registration import Registration
|
from base.registration.Registration import Registration
|
||||||
from base.messaging.MessageResponseQueue import MessageResponseQueue
|
from base.messaging.MessageResponseQueue import MessageResponseQueue
|
||||||
|
from base.event.EventManager import EventManager
|
||||||
from base.plugin.PluginManager import PluginManager
|
from base.plugin.PluginManager import PluginManager
|
||||||
from base.task.TaskManager import TaskManager
|
from base.task.TaskManager import TaskManager
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
|
@ -20,6 +21,10 @@ import sys,logging,queue,time
|
||||||
class AhenkDeamon(BaseDaemon):
|
class AhenkDeamon(BaseDaemon):
|
||||||
"""docstring for AhenkDeamon"""
|
"""docstring for AhenkDeamon"""
|
||||||
|
|
||||||
|
def reload(self,msg):
|
||||||
|
# reload service here
|
||||||
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print ("merhaba dunya")
|
print ("merhaba dunya")
|
||||||
|
|
||||||
|
@ -39,6 +44,12 @@ class AhenkDeamon(BaseDaemon):
|
||||||
logger.info("this is info log")
|
logger.info("this is info log")
|
||||||
globalscope.setLogger(logger)
|
globalscope.setLogger(logger)
|
||||||
|
|
||||||
|
eventManager = EventManager()
|
||||||
|
globalscope.setEventManager(eventManager)
|
||||||
|
|
||||||
|
eventManager.register_event('registration_ok',self.reload)
|
||||||
|
|
||||||
|
|
||||||
pluginManager = PluginManager()
|
pluginManager = PluginManager()
|
||||||
pluginManager.loadPlugins()
|
pluginManager.loadPlugins()
|
||||||
globalscope.setPluginManager(pluginManager)
|
globalscope.setPluginManager(pluginManager)
|
||||||
|
|
|
@ -18,6 +18,8 @@ class Scope(object):
|
||||||
self.taskManager=None
|
self.taskManager=None
|
||||||
self.responseQueue=None
|
self.responseQueue=None
|
||||||
self.registration=None
|
self.registration=None
|
||||||
|
self.eventManager=None
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getInstance():
|
def getInstance():
|
||||||
|
@ -78,3 +80,9 @@ class Scope(object):
|
||||||
|
|
||||||
def setRegistration(self,registration):
|
def setRegistration(self,registration):
|
||||||
self.registration=registration
|
self.registration=registration
|
||||||
|
|
||||||
|
def getEventManager(self):
|
||||||
|
return self.eventManager
|
||||||
|
|
||||||
|
def setEventManager(self,eventManager):
|
||||||
|
self.eventManager=eventManager
|
||||||
|
|
19
opt/ahenk/base/event/EventBase.py
Normal file
19
opt/ahenk/base/event/EventBase.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# @author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||||
|
|
||||||
|
class EventBase():
|
||||||
|
listeners = []
|
||||||
|
def __init__(self):
|
||||||
|
self.listeners.append(self)
|
||||||
|
self.listener_events = []
|
||||||
|
def register_event(self, event_name, callback_func):
|
||||||
|
self.listener_events.append({'event_name' : event_name, 'callback_func' : callback_func})
|
||||||
|
|
||||||
|
|
||||||
|
class Event():
|
||||||
|
def __init__(self, event_name, *callback_args):
|
||||||
|
for listener in EventBase.listeners:
|
||||||
|
for listener_cls in listener.listener_events:
|
||||||
|
if listener_cls['event_name'] == event_name:
|
||||||
|
listener_cls['callback_func'](*callback_args)
|
14
opt/ahenk/base/event/EventManager.py
Normal file
14
opt/ahenk/base/event/EventManager.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# @author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||||
|
|
||||||
|
from base.event.EventBase import EventBase,Event
|
||||||
|
|
||||||
|
class EventManager(EventBase):
|
||||||
|
"""docstring for EventManager"""
|
||||||
|
def __init__(self):
|
||||||
|
EventBase.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
def fireEvent(self,event_name,*args):
|
||||||
|
Event(event_name,*args)
|
Loading…
Reference in a new issue