mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-10 03:02:17 +03:00
scope implemented
This commit is contained in:
parent
79b8b083f1
commit
b44e46d20f
3 changed files with 47 additions and 8 deletions
23
opt/ahenk/base/Scope.py
Normal file
23
opt/ahenk/base/Scope.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
|
||||
class Scope(object):
|
||||
"""docstring for Scope"""
|
||||
def __init__(self):
|
||||
super(Scope, self).__init__()
|
||||
self.customMap = {}
|
||||
self.configurationManager=None
|
||||
|
||||
def getCustomMap(self):
|
||||
return self.customMap
|
||||
|
||||
def putCustomMap(self,name,value):
|
||||
self.custom[name]=value
|
||||
|
||||
def getConfigurationManager(self):
|
||||
return self.configurationManager
|
||||
|
||||
def serConfigurationManager(self,configurationManager):
|
||||
self.configurationManager = configurationManager
|
|
@ -4,17 +4,29 @@
|
|||
|
||||
import logging
|
||||
import logging.config
|
||||
from ahenkd import AhenkDeamon
|
||||
|
||||
class Logger(object):
|
||||
"""docstring for Logger"""
|
||||
def __init__(self, logfilepath, loglevel):
|
||||
def __init__(self):
|
||||
super(Logger, self).__init__()
|
||||
logging.config.fileConfig('logging.conf')
|
||||
self.logger = logging.basicConfig(filename=logfilepath,level=loglevel)
|
||||
|
||||
scope = AhenkDeamon.scope()
|
||||
configManager = scope.getConfigurationManager()
|
||||
|
||||
logging.config.fileConfig(configManager.get('BASE','logConfigurationFilePath'))
|
||||
self.logger = logging.getLogger()
|
||||
|
||||
def getLogger(self):
|
||||
return self.logger
|
||||
|
||||
def info(self,logstring):
|
||||
self.logger.info(logstring)
|
||||
|
||||
def warning(self,logstring):
|
||||
self.logger.warning(logstring)
|
||||
self.logger.warning(logstring)
|
||||
|
||||
def error(self,logstring):
|
||||
self.logger.error(logstring)
|
||||
|
||||
def debug(self,logstring):
|
||||
self.logger.debug(logstring)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import configparser
|
||||
import slixmpp
|
||||
from slixmpp.exceptions import IqError, IqTimeout
|
||||
from ahenkd import AhenkDeamon
|
||||
|
||||
"""
|
||||
--fetch parameters of connection from conf file
|
||||
|
@ -24,13 +25,16 @@ from slixmpp.exceptions import IqError, IqTimeout
|
|||
|
||||
class Messaging(slixmpp.ClientXMPP):
|
||||
|
||||
def __init__(self,configurationManager,logger):
|
||||
def __init__(self):
|
||||
|
||||
# global scope of ahenk
|
||||
scope = AhenkDeamon.scope()
|
||||
|
||||
# logger comes from ahenk deamon
|
||||
self.logger = logger
|
||||
self.logger = scope.getLogger()
|
||||
|
||||
# configurationManager comes from ahenk deamon
|
||||
self.configurationManager = configurationManager
|
||||
self.configurationManager = scope.getConfigurationManager()
|
||||
|
||||
#set parameters
|
||||
slixmpp.ClientXMPP.__init__(self, self.configurationManager.get('CONNECTION', 'jid'), self.configurationManager.get('Connection_Param', 'password'))
|
||||
|
|
Loading…
Reference in a new issue