Example #1
0
    def configs(self):
        for conf_obj in set(config.load_configs(os.path.abspath(self.config))):
            startup = getattr(conf_obj, "startup", None)
            if startup is None:
                continue

            params = startup()
            names = set([params["bot_name"], params["module"]])
            if self.disable is not None and names & set(self.disable):
                continue
            if self.enable is not None and not (names & set(self.enable)):
                continue
            yield conf_obj
Example #2
0
    def run(self):
        print "digraph G {"
        print "node [ shape=box, style=filled, color=lightgrey ];"

        dot = Dot(config.load_configs(self.config))
        services = dot.services()
        sessions = dot.sessions()

        def missing(x):
            return self.show_startups and x not in services

        for session in sessions:
            conf = dict(session.conf)
            path = session.path
            src = conf.pop("src_room", None)
            dst = conf.pop("dst_room", None)

            node = None
            if session.service != "roomgraph":
                node = "node " + session.service + " " + (src or "@") + " " + (dst or "@")
                if missing(session.service):
                    print line(node, label=session.service, shape="ellipse", fontsize=12, fontcolor="white", color="red")
                else:
                    print line(node, label=session.service, shape="ellipse", fontsize=12, style="")

            label_list = list()
            if path:
                label_list.append(".".join(path))
            if self.show_attributes:
                for item in conf.items():
                    label_list.append("  %r=%r" % item)
            label = "\\n".join(label_list)

            color = "red" if missing(session.service) else "black"
            if src is None:
                if node is not None and dst is not None:
                    print line(node, dst, label=label, color=color, fontsize=10)
            else:
                if node is not None and dst is None:
                    print line(src, node, label=label, color=color, fontsize=10)
                elif node is None and dst is not None:
                    print line(src, dst, label=label, color=color, fontsize=10)
                elif node is not None and dst is not None:
                    print line(src, node, label="", color=color, fontsize=10)
                    print line(node, dst, label=label, color=color, fontsize=10)

        print '}'
Example #3
0
    def configs(inner, self):
        conf_path = os.path.abspath(self.config)
        last_mtime = None
        error_msg = None

        while True:
            try:
                mtime = os.path.getmtime(conf_path)
                if last_mtime != mtime:
                    last_mtime = mtime
                    inner.send(self.SET, config.load_configs(conf_path))
                    error_msg = None
            except BaseException, exception:
                if error_msg != str(exception):
                    error_msg = str(exception)
                    self.log.error("Couldn't load module %r: %s", 
                                   self.config, error_msg)

            yield inner, timer.sleep(self.poll_interval)
Example #4
0
    def run(self):
        print "digraph G {"
        print "node [ shape=box, style=filled, color=lightgrey ];"

        dot = Dot(config.load_configs(self.config))
        services = dot.services()
        sessions = dot.sessions()

        def missing(x):
            return self.show_startups and x not in services

        for session in sessions:
            conf = dict(session.conf)
            path = session.path
            src = conf.pop("src_room", None)
            dst = conf.pop("dst_room", None)

            node = None
            if session.service != "roomgraph":
                node = "node " + session.service + " " + (src or "@") + " " + (
                    dst or "@")
                if missing(session.service):
                    print line(node,
                               label=session.service,
                               shape="ellipse",
                               fontsize=12,
                               fontcolor="white",
                               color="red")
                else:
                    print line(node,
                               label=session.service,
                               shape="ellipse",
                               fontsize=12,
                               style="")

            label_list = list()
            if path:
                label_list.append(".".join(path))
            if self.show_attributes:
                for item in conf.items():
                    label_list.append("  %r=%r" % item)
            label = "\\n".join(label_list)

            color = "red" if missing(session.service) else "black"
            if src is None:
                if node is not None and dst is not None:
                    print line(node,
                               dst,
                               label=label,
                               color=color,
                               fontsize=10)
            else:
                if node is not None and dst is None:
                    print line(src,
                               node,
                               label=label,
                               color=color,
                               fontsize=10)
                elif node is None and dst is not None:
                    print line(src, dst, label=label, color=color, fontsize=10)
                elif node is not None and dst is not None:
                    print line(src, node, label="", color=color, fontsize=10)
                    print line(node,
                               dst,
                               label=label,
                               color=color,
                               fontsize=10)

        print '}'