Beispiel #1
0
class CylcDotViewerCommon(xdot.DotWindow):

    def __init__(self, *args, **kwargs):
        xdot.DotWindow.__init__(self, *args, **kwargs)
        self.suiterc = None

    def load_config(self):
        """Load the suite config."""
        if self.suiterc:
            is_reload = True
            collapsed = self.suiterc.closed_families
        else:
            is_reload = False
            collapsed = []
        try:
            self.suiterc = SuiteConfig(
                self.suite, self.file, self.template_vars,
                is_reload=is_reload, collapsed=collapsed,
                cli_initial_point_string=self.start_point_string,
                vis_start_string=self.start_point_string,
                vis_stop_string=self.stop_point_string)
        except Exception as exc:
            msg = "Failed - parsing error?\n\n" + str(exc)
            ERR.error(msg)
            dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                    buttons=gtk.BUTTONS_OK,
                                    message_format=msg)
            dia.run()
            dia.destroy()
            return False
        self.inherit = self.suiterc.get_parent_lists()
        return True

    def on_refresh(self, w):
        """Re-load the suite config and refresh the graph."""
        if self.load_config():
            self.get_graph()
        else:
            self.set_dotcode('graph {}')

    def set_filter_graph_patterns(self, filter_patterns):
        """Set some regular expressions to filter out graph nodes."""
        self.filter_recs = [re.compile(_) for _ in filter_patterns]

    def filter_graph(self):
        """Apply any filter patterns to remove graph nodes."""
        if not self.filter_recs:
            return
        filter_nodes = set()
        for node in self.graph.nodes():
            for filter_rec in self.filter_recs:
                if filter_rec.search(node.get_name()):
                    filter_nodes.add(node)
        self.graph.cylc_remove_nodes_from(filter_nodes)
Beispiel #2
0
class CylcDotViewerCommon(xdot.DotWindow):
    def __init__(self,
                 suite,
                 suiterc,
                 template_vars,
                 orientation="TB",
                 should_hide=False,
                 start_point_string=None,
                 stop_point_string=None,
                 interactive=True):
        self.suite = suite
        self.suiterc = None
        self.template_vars = template_vars
        self.orientation = orientation
        self.should_hide = should_hide
        self.start_point_string = start_point_string
        self.stop_point_string = stop_point_string
        self.interactive = interactive

        self.outfile = None
        self.disable_output_image = False
        self.file = suiterc
        self.filter_recs = []

        util.setup_icons()
        gtk.Window.__init__(self)
        self.graph = xdot.Graph()
        self.set_icon(util.get_icon())
        self.set_default_size(512, 512)
        self.vbox = gtk.VBox()
        self.add(self.vbox)
        self.widget = xdot.DotWidget()

    def load_config(self):
        """Load the suite config."""
        if self.suiterc:
            is_reload = True
            collapsed = self.suiterc.closed_families
        else:
            is_reload = False
            collapsed = []
        try:
            self.suiterc = SuiteConfig(
                self.suite,
                self.file,
                self.template_vars,
                is_reload=is_reload,
                collapsed=collapsed,
                cli_initial_point_string=self.start_point_string,
                vis_start_string=self.start_point_string,
                vis_stop_string=self.stop_point_string)
        except Exception as exc:
            msg = "Failed - parsing error?\n\n" + str(exc)
            ERR.error(msg)
            if self.interactive:
                dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                        buttons=gtk.BUTTONS_OK,
                                        message_format=msg)
                dia.run()
                dia.destroy()
                return False
            sys.exit(1)
        self.inherit = self.suiterc.get_parent_lists()
        return True

    def on_refresh(self, w):
        """Re-load the suite config and refresh the graph."""
        if self.load_config():
            self.get_graph()
        else:
            self.set_dotcode('graph {}')

    def set_filter_graph_patterns(self, filter_patterns):
        """Set some regular expressions to filter out graph nodes."""
        self.filter_recs = [re.compile(_) for _ in filter_patterns]

    def filter_graph(self):
        """Apply any filter patterns to remove graph nodes."""
        if not self.filter_recs:
            return
        filter_nodes = set()
        for node in self.graph.nodes():
            for filter_rec in self.filter_recs:
                if filter_rec.search(node.get_name()):
                    filter_nodes.add(node)
        self.graph.cylc_remove_nodes_from(filter_nodes)
Beispiel #3
0
class CylcDotViewerCommon(xdot.DotWindow):

    def __init__(self, suite, suiterc, template_vars, orientation="TB",
                 should_hide=False, start_point_string=None,
                 stop_point_string=None, interactive=True):
        self.suite = suite
        self.suiterc = None
        self.template_vars = template_vars
        self.orientation = orientation
        self.should_hide = should_hide
        self.start_point_string = start_point_string
        self.stop_point_string = stop_point_string
        self.interactive = interactive

        self.outfile = None
        self.disable_output_image = False
        self.file = suiterc
        self.filter_recs = []

        util.setup_icons()
        gtk.Window.__init__(self)
        self.graph = xdot.Graph()
        self.set_icon(util.get_icon())
        self.set_default_size(512, 512)
        self.vbox = gtk.VBox()
        self.add(self.vbox)
        self.widget = xdot.DotWidget()

    def load_config(self):
        """Load the suite config."""
        if self.suiterc:
            is_reload = True
            collapsed = self.suiterc.closed_families
        else:
            is_reload = False
            collapsed = []
        try:
            self.suiterc = SuiteConfig(
                self.suite, self.file, self.template_vars,
                is_reload=is_reload, collapsed=collapsed,
                cli_initial_point_string=self.start_point_string,
                vis_start_string=self.start_point_string,
                vis_stop_string=self.stop_point_string)
        except Exception as exc:
            msg = "Failed - parsing error?\n\n" + str(exc)
            ERR.error(msg)
            if self.interactive:
                dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                        buttons=gtk.BUTTONS_OK,
                                        message_format=msg)
                dia.run()
                dia.destroy()
                return False
            sys.exit(1)
        self.inherit = self.suiterc.get_parent_lists()
        return True

    def on_refresh(self, w):
        """Re-load the suite config and refresh the graph."""
        if self.load_config():
            self.get_graph()
        else:
            self.set_dotcode('graph {}')

    def set_filter_graph_patterns(self, filter_patterns):
        """Set some regular expressions to filter out graph nodes."""
        self.filter_recs = [re.compile(_) for _ in filter_patterns]

    def filter_graph(self):
        """Apply any filter patterns to remove graph nodes."""
        if not self.filter_recs:
            return
        filter_nodes = set()
        for node in self.graph.nodes():
            for filter_rec in self.filter_recs:
                if filter_rec.search(node.get_name()):
                    filter_nodes.add(node)
        self.graph.cylc_remove_nodes_from(filter_nodes)