Commit 8d7f618d authored by Devaev Maxim's avatar Devaev Maxim

Refactoring

parent ca308c0d
......@@ -37,6 +37,8 @@ class Application(object) :
self._main_loop.quit()
logger.verbose("GObject loop closed")
###
def loadModules(self) :
sys.path.append(const.FUNCTIONS_DIR)
sys.path.append(const.ACTIONS_DIR)
......@@ -60,6 +62,8 @@ class Application(object) :
sys.path.remove(const.FUNCTIONS_DIR)
sys.path.remove(const.ACTIONS_DIR)
###
def loadApplicationConfigs(self) :
config.loadConfigs(only_sections_list = (config.APPLICATION_SECTION,))
......@@ -77,6 +81,8 @@ class Application(object) :
config.loadConfigs(exclude_sections_list = (config.APPLICATION_SECTION,))
###
def initBus(self) :
bus_type = config.value(config.APPLICATION_SECTION, "bus_type")
service_name = config.value(config.APPLICATION_SECTION, "service_name")
......@@ -91,6 +97,8 @@ class Application(object) :
logger.verbose("Connected to D-Bus \"%s\" as \"%s\"" % (bus_type, service_name))
###
def initServices(self) :
for service_name in self._services_dict.keys() :
if config.value(service_name, "enabled") :
......
# -*- coding: utf-8 -*-
##### Public methods #####
def joinPath(first, *others_list) :
return joinItems("/", first, *others_list)
def joinMethod(first, *others_list) :
return joinItems(".", first, *others_list)
##### Private methods #####
def joinItems(separator, first, *others_list) :
for others_list_item in others_list :
......@@ -18,3 +10,11 @@ def joinItems(separator, first, *others_list) :
first += separator + others_list_item
return first
##### Public methods #####
def joinPath(first, *others_list) :
return joinItems("/", first, *others_list)
def joinMethod(first, *others_list) :
return joinItems(".", first, *others_list)
......@@ -32,6 +32,21 @@ class UnknownMessageType(Exception) :
pass
##### Private methods #####
def log(message_type, message) :
if not message_type in ALL_MESSAGES_LIST :
raise UnknownMessageType("Message type \"%d\" not in list %s" % (message_type, ALL_MESSAGES_LIST))
if message_type[2] <= config.value(config.APPLICATION_SECTION, "log_level") :
message_type_texts_list = ("Error", "Warning", "Notice", "Info", "Details", "Debug")
message = "[ %s ]: %s" % (message_type_texts_list[message_type[0]], message)
print >> sys.stderr, const.MY_NAME, message
if config.value(config.RUNTIME_SECTION, "use_syslog") :
syslog.syslog(message_type[1], message)
##### Public methods #####
def error(message) :
log(ERROR_MESSAGE, message)
......@@ -55,18 +70,3 @@ def attachException(message_type = ERROR_MESSAGE) :
for line in traceback.format_exc().splitlines() :
log(message_type, line)
##### Private methods #####
def log(message_type, message) :
if not message_type in ALL_MESSAGES_LIST :
raise UnknownMessageType("Message type \"%d\" not in list %s" % (message_type, ALL_MESSAGES_LIST))
if message_type[2] <= config.value(config.APPLICATION_SECTION, "log_level") :
message_type_texts_list = ("Error", "Warning", "Notice", "Info", "Details", "Debug")
message = "[ %s ]: %s" % (message_type_texts_list[message_type[0]], message)
print >> sys.stderr, const.MY_NAME, message
if config.value(config.RUNTIME_SECTION, "use_syslog") :
syslog.syslog(message_type[1], message)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment