New attribute autoconnect in server tag

This commit is contained in:
Némunaire 2012-06-29 01:02:15 +02:00
parent 5bfcd61931
commit 22348e53b5
2 changed files with 11 additions and 0 deletions

View File

@ -170,6 +170,7 @@ def load_module(config, servers):
def load_file(filename, servers):
"""Realy load a file"""
global MODS
config = xmlparser.parse_file(filename)
if config.getName() == "nemubotconfig" or config.getName() == "config":
#Preset each server in this file
@ -180,6 +181,8 @@ def load_file(filename, servers):
print (" Server `%s' successfully added." % srv.id)
else:
print (" Server `%s' already added, skiped." % srv.id)
if srv.autoconnect:
srv.launch(MODS)
#Load files asked by the configuration file
for load in config.getNodes("load"):
load_file(load["path"], servers)

View File

@ -58,6 +58,14 @@ class Server(threading.Thread):
else:
return None
@property
def autoconnect(self):
if self.node.hasAttribute("autoconnect"):
value = self.node["autoconnect"].lower()
return value != "no" and value != "off" and value != "false"
else:
return False
@property
def id(self):
return self.host + ":" + str(self.port)