예제 #1
0
    def __init__(self, suite, suiterc, template_vars,
            template_vars_file, orientation="TB",
            should_hide=False):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.orientation = orientation
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file
        self.start_point_string = None
        self.stop_point_string = None
        self.filter_recs = []

        util.setup_icons()

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Cylc Suite Runtime Inheritance Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon( util.get_icon() )

        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In',
                self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out',
                self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit',
                self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100',
                self.widget.on_zoom_100),
            ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh',
                self.on_refresh),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action),
        ))
        actiongroup.add_toggle_actions((
            ('LeftToRight', 'transpose', 'Transpose',
             None, 'Transpose the graph', self.on_left_to_right),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        left_to_right_toolitem = uimanager.get_widget(
            '/ToolBar/LeftToRight')
        left_to_right_toolitem.set_active(self.orientation == "LR")

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        if not should_hide:
            self.show_all()
        self.load_config()
예제 #2
0
    def __init__(self, suite, suiterc, start_point_string, stop_point_string,
            template_vars, template_vars_file, orientation="TB",
            subgraphs_on=False, should_hide=False):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.orientation = orientation
        self.subgraphs_on = subgraphs_on
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file
        self.ignore_suicide = False
        self.start_point_string = start_point_string
        self.stop_point_string = stop_point_string
        self.filter_recs = []

        util.setup_icons()

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Cylc Suite Dependency Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon( util.get_icon() )
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # create new stock icons for group and ungroup actions
        imagedir = os.environ[ 'CYLC_DIR' ] + '/images/icons'
        factory = gtk.IconFactory()
        for i in [ 'group', 'ungroup' ]:
            pixbuf = gtk.gdk.pixbuf_new_from_file( imagedir + '/' + i + '.png' )
            iconset = gtk.IconSet(pixbuf)
            factory.add( i, iconset )
        factory.add_default()

        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In',
                self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out',
                self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit',
                self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100',
                self.widget.on_zoom_100),
            ('Group', 'group', 'Group', None, 'Group All Families',
                self.group_all),
            ('UnGroup', 'ungroup', 'Ungroup', None, 'Ungroup All Families',
                self.ungroup_all),
            ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh',
                self.on_refresh),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action),
        ))
        actiongroup.add_toggle_actions((
            ('LeftToRight', 'transpose', 'Transpose',
             None, 'Transpose the graph', self.on_left_to_right),
        ))
        actiongroup.add_toggle_actions((
            ('Subgraphs', gtk.STOCK_LEAVE_FULLSCREEN, 'Cycle Point Subgraphs',
             None, 'Organise by cycle point', self.on_subgraphs),
        ))
        actiongroup.add_toggle_actions((
            ('IgnoreSuicide', gtk.STOCK_CANCEL, 'Ignore Suicide Triggers',
             None, 'Ignore Suicide Triggers', self.on_igsui),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight')
        left_to_right_toolitem.set_active(self.orientation == "LR")

        subgraphs_toolitem = uimanager.get_widget(
            '/ToolBar/Subgraphs')
        subgraphs_toolitem.set_active(self.subgraphs_on)

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        eb = gtk.EventBox()
        eb.add( gtk.Label( "right-click on nodes to control family grouping" ) )
        eb.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse( '#8be' ) )
        vbox.pack_start( eb, False )

        self.set_focus(self.widget)

        if not should_hide:
            self.show_all()
        self.load_config()
예제 #3
0
파일: cylc_xdot.py 프로젝트: devkev/cylc
    def __init__(self, suite, suiterc, template_vars,
            template_vars_file, watch, outfile=None, orientation="TB" ):
        self.outfile = outfile
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.watch = []
        self.orientation = orientation
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Suite Runtime Namespace Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon( util.get_icon() )

        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # create new stock icons for group and ungroup actions
        imagedir = os.environ[ 'CYLC_DIR' ] + '/images/icons'
        factory = gtk.IconFactory()
        for i in [ 'group', 'ungroup' ]:
            pixbuf = gtk.gdk.pixbuf_new_from_file( imagedir + '/' + i + '.png' )
            iconset = gtk.IconSet(pixbuf)
            factory.add( i, iconset )
        factory.add_default()

        # Create actions
        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100),
            ('Help', gtk.STOCK_HELP, None, None, 'Help', helpwindow.graph_viewer ),
        ))
        actiongroup.add_toggle_actions((
            ('Landscape', gtk.STOCK_JUMP_TO, None, None, 'Landscape', self.on_landscape),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        landscape_toolitem = uimanager.get_widget('/ToolBar/Landscape')
        landscape_toolitem.set_active(self.orientation == "LR")

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        #eb = gtk.EventBox()
        #eb.add( gtk.Label( "right-click on nodes to control family grouping" ) )
        #eb.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse( '#8be' ) ) 
        #vbox.pack_start( eb, False )

        self.set_focus(self.widget)

        # find all suite.rc include-files
        self.rc_mtimes = {}
        self.rc_last_mtimes = {}
        for rc in watch:
            while True:
                try:
                    self.rc_last_mtimes[rc] = os.stat(rc).st_mtime
                except OSError:
                    # this happens occasionally when the file is being edited ... 
                    print >> sys.stderr, "Failed to get rc file mod time, trying again in 1 second"
                    time.sleep(1)
                else:
                    #self.rc_mtimes[rc] = self.rc_last_mtimes[rc]
                    break

        self.show_all()
        while True:
            if self.load_config():
                break
            else:
                time.sleep(1)
예제 #4
0
    def __init__(self,
                 suite,
                 suiterc,
                 template_vars,
                 template_vars_file,
                 orientation="TB",
                 should_hide=False):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.orientation = orientation
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file
        self.start_point_string = None
        self.stop_point_string = None
        self.filter_recs = []

        util.setup_icons()

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Cylc Suite Runtime Inheritance Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon(util.get_icon())

        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In',
             self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out',
             self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit',
             self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100',
             self.widget.on_zoom_100),
            ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh',
             self.on_refresh),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action),
        ))
        actiongroup.add_toggle_actions(
            (('LeftToRight', 'transpose', 'Transpose', None,
              'Transpose the graph', self.on_left_to_right), ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight')
        left_to_right_toolitem.set_active(self.orientation == "LR")

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        if not should_hide:
            self.show_all()
        self.load_config()
예제 #5
0
    def __init__(self,
                 suite,
                 suiterc,
                 start_point_string,
                 stop_point_string,
                 template_vars,
                 template_vars_file,
                 orientation="TB",
                 subgraphs_on=False,
                 ignore_suicide=True,
                 should_hide=False):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.orientation = orientation
        self.subgraphs_on = subgraphs_on
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file
        self.ignore_suicide = ignore_suicide
        self.start_point_string = start_point_string
        self.stop_point_string = stop_point_string
        self.filter_recs = []

        util.setup_icons()

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Cylc Suite Dependency Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon(util.get_icon())
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # create new stock icons for group and ungroup actions
        imagedir = os.environ['CYLC_DIR'] + '/images/icons'
        factory = gtk.IconFactory()
        for i in ['group', 'ungroup']:
            pixbuf = gtk.gdk.pixbuf_new_from_file(imagedir + '/' + i + '.png')
            iconset = gtk.IconSet(pixbuf)
            factory.add(i, iconset)
        factory.add_default()

        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In',
             self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out',
             self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit',
             self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100',
             self.widget.on_zoom_100),
            ('Group', 'group', 'Group', None, 'Group All Families',
             self.group_all),
            ('UnGroup', 'ungroup', 'Ungroup', None, 'Ungroup All Families',
             self.ungroup_all),
            ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh',
             self.on_refresh),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action),
        ))
        actiongroup.add_toggle_actions(
            (('LeftToRight', 'transpose', 'Transpose', None,
              'Transpose the graph', self.on_left_to_right), ))
        actiongroup.add_toggle_actions(
            (('Subgraphs', gtk.STOCK_LEAVE_FULLSCREEN, 'Cycle Point Subgraphs',
              None, 'Organise by cycle point', self.on_subgraphs), ))
        actiongroup.add_toggle_actions(
            (('IgnoreSuicide', gtk.STOCK_CANCEL, 'Ignore Suicide Triggers',
              None, 'Ignore Suicide Triggers', self.on_igsui), ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight')
        left_to_right_toolitem.set_active(self.orientation == "LR")

        subgraphs_toolitem = uimanager.get_widget('/ToolBar/Subgraphs')
        subgraphs_toolitem.set_active(self.subgraphs_on)

        igsui_toolitem = uimanager.get_widget('/ToolBar/IgnoreSuicide')
        igsui_toolitem.set_active(self.ignore_suicide)

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        eb = gtk.EventBox()
        eb.add(gtk.Label("right-click on nodes to control family grouping"))
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#8be'))
        vbox.pack_start(eb, False)

        self.set_focus(self.widget)

        if not should_hide:
            self.show_all()
        self.load_config()
예제 #6
0
    def __init__(self, suite, suiterc, template_vars,
            template_vars_file, watch, orientation="TB" ):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.watch = []
        self.orientation = orientation
        self.template_vars = template_vars
        self.template_vars_file = template_vars_file

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Suite Runtime Namespace Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon( util.get_icon() )

        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # create new stock icons for group and ungroup actions
        imagedir = os.environ[ 'CYLC_DIR' ] + '/images/icons'
        factory = gtk.IconFactory()
        for i in [ 'group', 'ungroup' ]:
            pixbuf = gtk.gdk.pixbuf_new_from_file( imagedir + '/' + i + '.png' )
            iconset = gtk.IconSet(pixbuf)
            factory.add( i, iconset )
        factory.add_default()

        # Create actions
        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In', self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out', self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit', self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100', self.widget.on_zoom_100),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action ),
        ))
        actiongroup.add_toggle_actions((
            ('Landscape', gtk.STOCK_JUMP_TO, None, None, 'Landscape', self.on_landscape),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        landscape_toolitem = uimanager.get_widget('/ToolBar/Landscape')
        landscape_toolitem.set_active(self.orientation == "LR")

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        #eb = gtk.EventBox()
        #eb.add( gtk.Label( "right-click on nodes to control family grouping" ) )
        #eb.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse( '#8be' ) ) 
        #vbox.pack_start( eb, False )

        self.set_focus(self.widget)

        # find all suite.rc include-files
        self.rc_mtimes = {}
        self.rc_last_mtimes = {}
        for rc in watch:
            while True:
                try:
                    self.rc_last_mtimes[rc] = os.stat(rc).st_mtime
                except OSError:
                    # this happens occasionally when the file is being edited ... 
                    print >> sys.stderr, "Failed to get rc file mod time, trying again in 1 second"
                    time.sleep(1)
                else:
                    #self.rc_mtimes[rc] = self.rc_last_mtimes[rc]
                    break

        self.show_all()
        while True:
            if self.load_config():
                break
            else:
                time.sleep(1)