#!/usr/bin/env python # -*- coding:utf-8 -*- """ message define file. form ini file. -- [email protected] blueantelope 2015-01-14 """ from __init__ import * import util from constant import * message_ini = util.load_ini(MESSAGE_INI_PATH) class HELP(object): mode = "Run mode; fg=foregound, bg=background" watchdog = "Open to check health, produce a daemon process as monitor" def __init__(self): self.mode = util.get_ini_value(message_ini, "help", "mode", self.mode) self.watchdog = util.get_ini_value(message_ini, "help", "watchdog", self.watchdog) class PAGE(object): keywords = "Continue System, CI" description = "@antelope.ci -- CI anywhere,Issue anytime" title = "@antelope.ci -- CI anywhere, Issue anytime" def __init__(self):
def loadSettings(self): ## load .ini and setup default value self.cfg = load_ini(config.SETTING_FILE_PATH) self.cfg.setValue('global/version', config.VERSION)
#!/usr/bin/env python # -*- coding:utf-8 -*- """ configuraion for webserver. form ini file. -- [email protected] blueantelope 2015-01-08 """ from __init__ import * import util from constant import * config_ini = util.load_ini(CONFIG_INI_PATH) # parse and objectify option: listening class Listening(object): switch = False ip = None port = 0 def __init__(self, option, _port): self.switch = util.get_ini_switch(config_ini, option) self.ip = util.get_ini_value(config_ini, option, IP_KEY, LISTENING_IP) self.port = util.get_ini_value(config_ini, option, PORT_KEY, _port) class HTTP(Listening): def __init__(self):
#!/usr/bin/env python # -*- coding:utf-8 -*- from __init__ import * import util main_ini = util.load_ini(MAIN_INI_PATH) class Source: def __init__(self, _source): self.name = None self.module = None self.root_link = None self.keys = None self.api = None if 'name' in _source: self.name = _source['name'] if 'module' in _source: self.module = _source['module'] if 'root_link' in _source: self.root_link = _source['root_link'] if 'keys' in _source: self.keys = _source['keys'] if 'api' in _source: self.api = _source['api'] class MyHouse: def __init__(self): _sources = util.get_ini_value(main_ini, 'myhouse', 'sources', '')
def test_load_ini(self): ini = util.load_ini(CONFIG_INI_PATH) ini_http = ini.options("http") print ini_http ini_http_ip = ini.get("http", "ip") print ini_http_ip
def test_get_ini_value(self): main_ini = util.load_ini(MAIN_INI_PATH) _value = util.get_ini_value(main_ini, 'myhouse', 'sources', None) _value = util.get_ini_value(main_ini, 'soufun', 'api-prefix', None) self.assertIsNotNone(_value)
def test_load_ini(self): main_ini = util.load_ini(MAIN_INI_PATH) self.assertIsNotNone(main_ini)
#!/usr/bin/env python # -*- coding:utf-8 -*- """ configuraion for webserver. form ini file. -- [email protected] blueantelope 2015-01-08 """ from __init__ import * import util from constant import * config_ini = util.load_ini(CONFIG_INI_PATH) # parse and objectify option: listening class Listening(object): switch = False ip = None port = 0 def __init__(self, option, _port): self.switch = util.get_ini_switch(config_ini, option) self.ip = util.get_ini_value(config_ini, option, IP_KEY, LISTENING_IP) self.port = util.get_ini_value(config_ini, option, PORT_KEY, _port) class HTTP(Listening): def __init__(self): super(HTTP, self).__init__(HTTP_KEY, HTTP_PORT)