Exemplo n.º 1
0
 def buildConfig(self):
     cfg = ElementTree.Element("hackabot")
     net = ElementTree.SubElement(cfg, "network")
     net.attrib['nick'] = self.nickname
     net.attrib['name'] = self.username
     svr = ElementTree.SubElement(net, "server")
     svr.attrib['hostname'] = "127.0.0.1"
     svr.attrib['port'] = str(self.tester.port)
     join = ElementTree.SubElement(net, "autojoin")
     join.attrib['chan'] = self.channel
     return cfg
Exemplo n.º 2
0
        'root': root,
        'perl': "%s/lib/perl" % root,
        'mysql': "%s/lib/mysql" % root,
        'python': "%s/lib/python" % root,
    }

    if path:
        path = os.path.abspath(path)
        try:
            config = ElementTree.parse(path).getroot()
        except IOError, (exno, exstr):
            raise ConfigError("Failed to read %s: %s" % (path, exstr))
    elif xml:
        config = ElementTree.fromstring(xml)
    else:
        config = ElementTree.Element("hackabot")

    for key, value in defaults.iteritems():
        config.attrib.setdefault(key, value)

    if path:
        config.attrib['config'] = path

    return config

def run(argv=sys.argv):
    """Start up Hackabot"""

    options, conf = parse_options(argv)

    if options.file: