示例#1
0
    def _add_script_table_row(self, table, scriptname, parent):
        tablerow = TableRow()
        # scriptname cell
        scriptname_cell = TableCell(scriptname)

        # command cell (we use
        # an empty cell as default)
        command_cell = TableCell()

        # parent cell
        if parent is None:
            parent = '(defined here)'
            # if script is defined here, instead of inherited
            # we make the command anchors.
            durl = 'delete.%s.%s' % (table.context, scriptname)
            eurl = 'edit.%s.%s' % (table.context, scriptname)
            delanchor = Anchor('delete', href=durl)
            editanchor = Anchor('edit', href=eurl)
            command_cell = TableCell(editanchor)
            command_cell.append(Break())
            command_cell.append(delanchor)
        parent_cell = TableCell(parent)

        # append the cells to the rows
        tablerow.append(scriptname_cell)
        tablerow.append(parent_cell)
        tablerow.append(command_cell)
        table.append(tablerow)
示例#2
0
    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SectionTitle('Family:  %s' % family)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'

        self.body.append(title)
        parent_anchor = Anchor('Parents', href='edit.parents.%s' % family)
        self.body.append(SectionTitle(parent_anchor))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.append(ListItem(p))
            self.body.append(plist)
        vtitle = Anchor('Variables',
                        href='edit.variables.%s' % self.family.current)
        self.body.append(SectionTitle(vtitle))
        if len(erows):
            self.body.append(PVarTable(erows, bgcolor='MistyRose2'))
        self.body.append(Ruler())
        del_anchor = Anchor('delete', href='delete.family.%s' % family)
        self.body.append(del_anchor)
示例#3
0
 def _make_footer_anchors(self, name, value):
     newanchor = Anchor('new', href='new.%s.foo' % name)
     deleteanchor = Anchor('delete', href='delete.%s.%s' % (name, value))
     self.body.append(Ruler())
     self.body.append(Break())
     self.body.append(deleteanchor)
     self.body.append(Break())
     self.body.append(newanchor)
示例#4
0
 def _make_trait_title(self, trait):
     title = TraitSectionTitle(self.cfg, 'Trait:  %s' % trait,
                               **self._sectitle_atts)
     title.cell.append(
         Anchor('(description)', href='edit.description.%s' % trait))
     show = '(show)'
     if self._show_description:
         show = '(hide)'
     title.cell.append(Anchor(show, href='show.description.%s' % trait))
     return title
示例#5
0
 def _add_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     durl = 'delete.%s.%s' % (table.context, row[fields[0]])
     eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
示例#6
0
 def _add_variables_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     ident = '%s||%s' % (row['trait'], row['name'])
     durl = 'delete.%s.%s' % (table.context, ident)
     eurl = 'edit.%s.%s' % (table.context, ident)
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
示例#7
0
 def _make_scripts_list(self, trait):
     rows = self.trait._scripts.scripts(trait=trait)
     if rows:
         slist = UnorderedList()
         for row in rows:
             script = row.script
             p = Paragraph()
             sa = Anchor(script, href='show.script.%s' % script)
             ea = Anchor('(edit)', href='edit.script.%s' % script)
             p.append(sa)
             p.append(ea)
             slist.append(ListItem(p))
         return slist
     else:
         return None
示例#8
0
 def _make_parent_list(self, trait):
     plist = UnorderedList()
     parents = self.trait.parents(trait=trait)
     for parent in parents:
         pp = Anchor(parent, href='show.parent.%s' % parent)
         plist.append(ListItem(pp))
     return plist
示例#9
0
 def _make_parent_section(self, trait):
     parent_section = TraitSectionTitle(self.cfg, 'Parents',
                                        **self._sectitle_atts)
     parent_section.create_rightside_table()
     parent_url = 'edit.parents.%s' % trait
     parent_section.append_rightside_anchor(Anchor('edit', href=parent_url))
     return parent_section
示例#10
0
 def set_diskconfig(self, diskconfig):
     row = self.diskconfig.get(diskconfig)
     self.clear_body()
     title = SectionTitle('DiskConfig: %s' % row.name)
     self.body.append(title)
     content = row.content
     if content is None:
         content = ''
     pre = Pre(content)
     self.body.append(pre)
     self.body.append(Ruler())
     editanchor = Anchor('edit', href='edit.diskconfig.%s' % row.name)
     self.body.append(editanchor)
     self.body.append(Ruler())
     deleteanchor = Anchor('delete', href='delete.diskconfig.%s' % row.name)
     self.body.append(deleteanchor)
示例#11
0
 def _make_scripts_table(self, trait):
     rows = self.trait._scripts.scripts(trait=trait)
     if rows:
         bgcolor = self.cfg.get('management_gui',
                                'traitdoc_variables_table_color')
         table = Table(bgcolor=bgcolor)
         for row in rows:
             script = row.script
             sa = Anchor(script, href='show.script.%s' % script)
             ea = Anchor('(edit)', href='edit.script.%s' % script)
             da = Anchor('(delete)', href='delete.script.%s' % script)
             trow = TableRow()
             trow.append(TableCell(sa))
             trow.append(TableCell(ea))
             trow.append(TableCell(da))
             table.append(trow)
         return table
示例#12
0
 def _setup_section(self, name, fields, rows):
     title = SectionTitle(name, bgcolor=self._bgcolor_section)
     title.set_font(color=self._other_section_font_color)
     anchor = Anchor('new', href='new.%s.machine' % name)
     title.row.append(TableCell(anchor))
     self.body.append(title)
     if len(rows):
         table = self._make_table(name, fields, rows, border=1, cellspacing=1)
         color_header(table, self._bgcolor_thead)
         self.body.append(table)
示例#13
0
 def set_machine(self, machine):
     self.machine.set_machine(machine)
     self.clear_body()
     title = SectionTitle('Machine:  %s' % machine)
     title['bgcolor'] = 'IndianRed'
     title['width'] = '100%'
     self.body.append(title)
     mtable = Table()
     for k, v in self.machine.current.items():
         tablerow = TableRow()
         tablerow.append(TableCell(Bold(k)))
         tablerow.append(TableCell(v))
         mtable.append(tablerow)
     self.body.append(mtable)
     newanchor = Anchor('new', href='new.machine.foo')
     editanchor = Anchor('edit', href='edit.machine.%s' % machine)
     self.body.append(Ruler())
     self.body.append(editanchor)
     self.body.append(Break())
     self.body.append(newanchor)
示例#14
0
 def _setup_main_attributes(self):
     machine = self.machine.current_machine
     attribute_table = Table(bgcolor=self._bgcolor_table, border=1)
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['Attribute', 'Value', 'Inherited From', 'Command']:
         headrow.append(TableHeader(col))
     attribute_table.append(headrow)
     for attribute in ['kernel', 'profile', 'diskconfig']:
         errormsg = ''
         try:
             value, inherited_from = self.machine.get_attribute(attribute)
         except AttributeUnsetInAncestryError:
             errormsg = "WARNING: not set anywhere"
             value, inherited_from = errormsg, errormsg
         tablerow = TableRow()
         href = 'select.attribute||%s.%s' % (attribute, machine)
         anchor = Anchor(attribute, href=href)
         cell = TableCell(Bold(anchor, ':'))
         tablerow.append(cell)
         cell = TableCell(value)
         tablerow.append(value)
         cell = TableCell()
         if inherited_from is not None:
             if errormsg:
                 anchor = Bold(errormsg)
             else:
                 anchor = Anchor(inherited_from,
                                 href='select.machine.%s' % inherited_from)
             cell.append(anchor)
         else:
             cell.append('(set here)')
         tablerow.append(cell)
         cell = TableCell()
         anchor = Anchor('clear',
                         href='delete.attribute||%s.%s' %
                         (attribute, machine))
         if inherited_from is None:
             cell.set(anchor)
         tablerow.append(cell)
         attribute_table.append(tablerow)
     self.body.append(attribute_table)
示例#15
0
 def set_rows(self, rows):
     for row in rows:
         tablerow = TableRow()
         show_anchor = Anchor(row.template,
                              href='show.template.%s' % row.template)
         tablerow.append(TableCell(show_anchor))
         template_data = '%s:%s (%s)' % (row.owner, row.grp_owner, row.mode)
         data_anchor = Anchor(template_data,
                              href='edit.templatedata.%s' % row.template)
         edit_anchor = Anchor('(edit)',
                              href='edit.template.%s' % row.template)
         del_anchor = Anchor('(delete)',
                             href='delete.template.%s' % row.template)
         tablerow.append(TableCell(data_anchor))
         cmdcell = TableCell()
         cmdcell.set(edit_anchor)
         cmdcell.append(del_anchor)
         tablerow.append(cmdcell)
         #tablerow.append(TableCell(edit_anchor))
         #tablerow.append(TableCell(del_anchor))
         self.append(tablerow)
示例#16
0
    def set_profile(self, profile):
        self.clear_body()
        self.profile.set_profile(profile)
        suite = self.profile.current.suite
        maintitle_text = 'Profile:  %s' % profile
        #ptitle.append('(suite ')
        #ptitle.append(Anchor(suite, href='change.suite.%s' % suite))
        #ptitle.append(')')
        #title = SectionTitle('Profile:  %s   (suite %s) ' % (profile, suite))
        title = SectionTitle(maintitle_text)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'
        title.cell.append('  (suite ')
        title.cell.append(Anchor(suite, href='change.suite.%s' % suite))
        title.cell.append(')')

        self.body.append(title)
        rows = self.profile.get_trait_rows()
        ptitle = Anchor('Traits',
                        href='edit.traits.%s' % self.profile.current.profile)
        self.body.append(SectionTitle(ptitle))
        if len(rows):
            self.body.append(TraitTable(rows, bgcolor='IndianRed1'))
        vtitle = Anchor('Variables',
                        href='edit.variables.%s' %
                        self.profile.current.profile)
        self.body.append(SectionTitle(vtitle))
        erows = self.profile._env.get_rows()
        if len(erows):
            self.body.append(PVarTable(erows, bgcolor='MistyRose2'))
        etitle = Anchor('Families',
                        href='edit.families.%s' % self.profile.current.profile)
        self.body.append(SectionTitle(etitle))
        families = self.profile.get_families()
        flist = UnorderedList()
        for f in families:
            flist.append(ListItem(f))
        self.body.append(flist)
示例#17
0
 def _setup_variables_section(self, rows):
     section = 'Variables'
     machine = self.machine.current_machine
     relation = self.machine.relation
     # make the section
     title = SectionTitle(section, bgcolor=self._bgcolor_section)
     title.set_font(color=self._other_section_font_color)
     anchor = Anchor('new', href='new.%s.machine' % section)
     title.row.append(TableCell(anchor))
     self.body.append(title)
     if len(rows):
         table = self._make_variables_table(rows, border=1, cellspacing=1)
         color_header(table, self._bgcolor_thead)
         self.body.append(table)
示例#18
0
 def _setup_section(self, name, fields, rows):
     title = SectionTitle(name)
     title.set_font(color='DarkViolet')
     anchor = Anchor('new', href='new.%s.mtype' % name)
     title.row.append(TableCell(anchor))
     self.body.append(title)
     if len(rows):
         table = self._make_table(name,
                                  fields,
                                  rows,
                                  border=1,
                                  cellspacing=1)
         color_header(table, 'MediumOrchid2')
         self.body.append(table)
示例#19
0
 def refresh_page(self):
     self.clear_body()
     title = SectionTitle('Kernels')
     self.body.append(title)
     kernels = self.kernels.get_kernels()
     table = Table()
     self.body.append(table)
     for kernel in kernels:
         tablerow = TableRow()
         cell = TableCell(kernel)
         tablerow.append(cell)
         del_anchor = Anchor('(delete)', href='delete||kernel||%s' % kernel)
         cell = TableCell(del_anchor)
         tablerow.append(cell)
         table.append(tablerow)
示例#20
0
 def _setup_parent_table(self):
     machine = self.machine.current_machine
     parent_table = Table(bgcolor=self._bgcolor_table, border=1)
     parent = self.machine.parent
     if parent is None:
         parent = '(No Parent Set)'
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['parent', 'command']:
         headrow.append(TableHeader(col))
     parent_table.append(headrow)
     mainrow = TableRow()
     parent_cell = TableCell(parent)
     mainrow.append(parent_cell)
     select_anchor = Anchor('select', href='select.parent.%s' % machine)
     delete_anchor = Anchor('delete', href='delete.parent.%s' % machine)
     command_cell = TableCell()
     command_cell.append(select_anchor)
     if self.machine.parent is not None:
         #command_cell.append(Break())
         command_cell.append('|=====|')
         command_cell.append(delete_anchor)
     mainrow.append(command_cell)
     parent_table.append(mainrow)
     self.body.append(parent_table)
示例#21
0
 def __init__(self, rows, **atts):
     Table.__init__(self, **atts)
     packages = []
     package_actions = {}
     for row in rows:
         if row.package not in packages:
             packages.append(row.package)
             package_actions[row.package] = [row.action]
         else:
             package_actions[row.package].append(row.action)
     for package in packages:
         tablerow = TableRow()
         tablerow.append(TableCell(package))
         tablerow.append(TableCell(', '.join(package_actions[package])))
         anchor = Anchor('delete', href='delete.package.%s' % package)
         tablerow.append(anchor)
         self.append(tablerow)
示例#22
0
 def _setup_script_section(self):
     machine = self.machine.current_machine
     relation = self.machine.relation
     scriptnames = relation.scripts.scriptnames
     scripts = []
     for scriptname in scriptnames:
         result = relation.get_script(scriptname, show_inheritance=True)
         if result is not None:
             # if result is not None, then result is a tuple
             # that is (fileobj, parent)
             # but we need scriptname, parent
             scripts.append((scriptname, result[1]))
     # make the section
     title = SectionTitle('Scripts', bgcolor=self._bgcolor_section)
     title.set_font(color=self._other_section_font_color)
     anchor = Anchor('new', href='new.%s.machine' % 'Scripts')
     title.row.append(TableCell(anchor))
     self.body.append(title)
     if len(scripts):
         table = self._make_script_table(scripts, border=1, cellspacing=1)
         color_header(table, self._bgcolor_thead)
         self.body.append(table)
示例#23
0
 def _make_packages_section(self, trait):
     ptitle = TraitSectionTitle(self.cfg, 'Packages', **self._sectitle_atts)
     ptitle_anchor = Anchor('(new)', href='new.package.%s' % trait)
     cell = TableCell(ptitle_anchor)
     ptitle.row.append(cell)
     return ptitle
示例#24
0
 def _make_templates_section(self, trait):
     ttitle = Anchor('Templates', href='edit.templates.%s' % trait)
     return TraitSectionTitle(self.cfg, ttitle, **self._sectitle_atts)
示例#25
0
 def _make_variables_section(self, trait):
     vtitle = Anchor('Variables', href='edit.variables.%s' % trait)
     return TraitSectionTitle(self.cfg, vtitle, **self._sectitle_atts)
示例#26
0
 def _make_scripts_section(self, trait):
     stitle = TraitSectionTitle(self.cfg, 'Scripts', **self._sectitle_atts)
     stitle.create_rightside_table()
     stitle.append_rightside_anchor(
         Anchor('new', href='new.script.%s' % trait))
     return stitle