Ejemplo n.º 1
0
    def __init__(self, path=None, xml=None, exit_cb=None, exit_args=()):
        self.config = parse_config(path, xml)
        self.dbpool = db.ConnectionPool(self.config)
        self.plugins = plugin.PluginManager()
        self._exit_cb = exit_cb
        self._exit_args = exit_args
        self._exit_deferred = None
        self._remote = remote.HBRemoteControl(self)
        self._networks = {}
        self._default = None

        for network in self.config.findall("network"):
            id = network.get("id", None)

            if id not in self._networks:
                net = HBotNetwork(self, network)
            else:
                raise ConfigError("Duplicate network id '%s'" % id)

            if not self._default:
                self._default = net

            self._networks[id] = net

        if len(self._networks) == 0:
            ConfigError("No networks defined!")
        elif len(self._networks) != 1 and None in self._networks:
            ConfigError("Missing network id!")

        self.connect()
Ejemplo n.º 2
0
    def __init__(self, path=None, xml=None, exit_cb=None, exit_args=()):
        self.config = parse_config(path, xml)
        self.dbpool = db.ConnectionPool(self.config)
        self.plugins = plugin.PluginManager()
        self._exit_cb = exit_cb
        self._exit_args = exit_args
        self._exit_deferred = None
        self._remote = remote.HBRemoteControl(self)
        self._networks = {}
        self._default = None

        for network in self.config.findall("network"):
            id = network.get("id", None)

            if id not in self._networks:
                net = HBotNetwork(self, network)
            else:
                raise ConfigError("Duplicate network id '%s'" % id)

            if not self._default:
                self._default = net

            self._networks[id] = net

        if len(self._networks) == 0:
            ConfigError("No networks defined!")
        elif len(self._networks) != 1 and None in self._networks:
            ConfigError("Missing network id!")

        self.connect()
Ejemplo n.º 3
0
    def __init__(self, path=None, xml=None):
        assert not (path and xml)

        if not (path or xml):
            xml = os.environ.get("HB_XML", None)

        self.conn = None
        self.conf = parse_config(path, xml)
Ejemplo n.º 4
0
 def setUp(self):
     self.config = parse_config(self.unittest_db)
     self._drop()
Ejemplo n.º 5
0
 def setUp(self):
     self.config = parse_config(self.unittest_db)
     self._drop()