コード例 #1
0
ファイル: main.py プロジェクト: vlara/ajenti
    def get_ui(self):
        ui = self.app.inflate('dashboard:main')
        self._mgr.refresh()

        self.fill('l', self._mgr.list_left(), ui, 'cleft')
        self.fill('r', self._mgr.list_right(), ui, 'cright')

        ui.insertText('host', platform.node())
        ui.insertText('distro', detect_distro())
        ui.find('icon').set('src', '/dl/dashboard/distributor-logo-%s.png'%detect_platform(mapping=False))

        if self._adding_widget == True:
            dlg = self.app.inflate('dashboard:add-widget')
            idx = 0
            for prov in sorted(self.app.grab_plugins(apis.dashboard.IWidget)):
                if hasattr(prov, 'hidden'):
                    continue
                dlg.append('list', UI.ListItem(
                    UI.HContainer(
                        UI.Image(file=prov.icon),
                        UI.Label(text=prov.name),
                    ),
                    id=prov.plugin_id,
                ))
                idx += 1
            ui.append('main', dlg)

        elif self._adding_widget != None:
            ui.append('main', self._mgr.get_by_name(self._adding_widget).get_config_dialog())

        return ui
コード例 #2
0
def format_exception(app, err):
    print '\n%s\n' % err
    templ = app.get_template('error.xml')
    templ.append('trace', UI.TextInputArea(value=err, width=550))
    templ.append('report',
                 UI.TextInputArea(value=make_report(app, err), width=550))
    return templ.render()
コード例 #3
0
 def get_ui_bool(self, param):
     v = getattr(self, param)
     return UI.HContainer(UI.SelectInput(
         UI.SelectOption(text='Ign.', value='ign', selected=v[1] is None),
         UI.SelectOption(text='Yes', value='nrm', selected=v[1] == True),
         UI.SelectOption(text='No', value='inv', selected=v[1] == False),
         design='mini',
         name='%s-mode' % param),
                          spacing=5)
コード例 #4
0
ファイル: api.py プロジェクト: vlara/ajenti
        def get_ui_hosts(self, gui):
            ui = self.app.inflate('webserver_common:hosts')
            tbl = ui.find('list') 
               
            hosts = self._backend.get_hosts()
            for x in sorted(hosts.keys()):
                tbl.append(UI.DTR(
                            UI.Image(file='/dl/core/ui/stock/status-%sabled.png'%(
                                'en' if hosts[x].enabled else 'dis')),
                            UI.Label(text=x),
                            UI.DTD(
                                UI.HContainer(
                                    UI.TipIcon(
                                        icon='/dl/core/ui/stock/edit.png',
                                        id='edithost/'+x, 
                                        text='Edit'
                                    ),
                                    UI.TipIcon(
                                        icon='/dl/core/ui/stock/'+ ('dis' if hosts[x].enabled else 'en') + 'able.png',
                                        id='togglehost/'+x, 
                                        text='Disable' if hosts[x].enabled else 'Enable'
                                    ),
                                    UI.TipIcon(
                                        icon='/dl/core/ui/stock/delete.png',
                                        id='deletehost/'+x, 
                                        text='Delete',
                                        warning='Delete host %s'%x
                                    ),
                                    spacing=0
                                ),
                                hidden=True
                            )
                          ))
                            
            if self._creating_host:
                gui.append(
                    'main',
                    UI.InputBox(
                        text='Host config name', 
                        id='dlgCreateHost'
                    )
                )

            if self._editing_host is not None:
                gui.append(
                    'main',
                    UI.InputBox(
                        extra='code',
                        text='Host config', 
                        value=self._backend.get_hosts()[self._editing_host].config,
                        id='dlgEditHost'
                    )
                )
                
            return ui
コード例 #5
0
ファイル: root.py プロジェクト: Ozerich/ajenti
    def process(self, req, start_response):
        self.do_init()

        templ = self.app.get_template('index.xml')

        cat = None
        v = UI.VContainer(spacing=0)

        # Sort plugins by name
        cats = self.categories
        cats = sorted(cats, key=lambda p: p.text)

        for fld in self.folder_ids:
            cat_vc = UI.VContainer(spacing=0)
            if self.folders[fld] == '':
                cat_folder = cat_vc  # Omit wrapper for special folders
            else:
                cat_folder = UI.CategoryFolder(
                    cat_vc,
                    text=self.folders[fld],
                    icon='/dl/core/ui/catfolders/' + fld +
                    '.png' if self.folders[fld] != '' else '',
                    id=fld)
            # cat_vc will be VContainer or CategoryFolder

            exp = False
            empty = True
            for c in cats:
                if c.folder == fld:  # Put corresponding plugins in this folder
                    empty = False
                    if c == self.selected_category:
                        cat_vc.append(
                            UI.Category(icon=c.icon,
                                        name=c.text,
                                        id=c.get_name(),
                                        selected='true'))
                        exp = True
                    else:
                        cat_vc.append(
                            UI.Category(icon=c.icon,
                                        name=c.text,
                                        id=c.get_name()))

            if not empty: v.append(cat_folder)
            cat_folder['expanded'] = exp

        templ.appendChildInto('leftplaceholder', v)
        templ.appendChildInto('rightplaceholder', self.main_ui().elements())
        templ.appendChildInto('version',
                              UI.Label(text='Ajenti ' + version, size=2))
        templ.appendChildInto(
            'links',
            UI.HContainer(
                UI.LinkLabel(text='About', id='about'),
                UI.OutLinkLabel(text='License',
                                url='http://www.gnu.org/licenses/lgpl.html')))

        return templ.render()
コード例 #6
0
def format_error(app, ex):
    templ = app.get_template('disabled.xml')
    tool = None
    if isinstance(ex, BackendRequirementError):
        reason = 'Required backend is unavailable.'
        hint = 'You need a plugin that provides <b>%s</b> interface support for <b>%s</b> platform.<br/>' % (
            ex.interface, app.platform)
    elif isinstance(ex, ConfigurationError):
        reason = 'The plugin was unable to start with current configuration.<br/>Consider using configuration dialog for this plugin.'
        hint = ex.hint
    else:
        return format_exception(app, traceback.format_exc())

    templ.append('reason', UI.CustomHTML(html=reason))
    templ.append('hint', UI.CustomHTML(html=hint))
    return templ.render()
コード例 #7
0
        def get_main_ui(self):
            panel = UI.ServicePluginPanel(title=self.ws_title,
                                          icon=self.ws_icon,
                                          status=self.service_status,
                                          servicename=self.service_name)

            if not self._backend.is_installed():
                panel.append(
                    UI.VContainer(
                        UI.ErrorBox(title='Error',
                                    text='%s is not installed' %
                                    self.ws_name)))
            else:
                panel.append(self.get_default_ui())

            return panel
コード例 #8
0
 def get_default_ui(self):
     tc = UI.TabControl(active=self._tab)
     if self.ws_vhosts:
         tc.add('Hosts', self.get_ui_hosts())
     if self.ws_mods:
         tc.add('Modules', self.get_ui_mods())
     return tc
コード例 #9
0
ファイル: api.py プロジェクト: vlara/ajenti
        def get_ui(self):
            mgr = self.app.get_backend(apis.services.IServiceManager)

            st = 'failed'
            st = mgr.get_status(self.service_name)
            try:
                st = mgr.get_status(self.service_name)
                if self.service_expected_status:
                    if self.service_expected_status != st:
                        st = 'failed'
            except:
                st = 'failed'

            self.service_status = st
            self.service_expected_status = None

            panel = UI.ServicePluginPanel(status=self.service_status,
                                          servicename=self.service_name)
            return UI.Container(panel, self.get_main_ui())
コード例 #10
0
ファイル: inflater.py プロジェクト: xuemy/ajenti
 def precache(self):
     from ajenti.ui import UI
     temp_ui = UI.new()
     for plugin in manager.get_order():
         layout_dir = os.path.join(manager.resolve_path(plugin), 'layout')
         if os.path.exists(layout_dir):
             for layout in os.listdir(layout_dir):
                 layout = '%s:%s' % (plugin, layout.split('.')[0])
                 logging.debug('Precaching layout %s' % layout)
                 self.inflate(temp_ui, layout)
コード例 #11
0
ファイル: inflater.py プロジェクト: Carolusian/ajenti
 def precache(self):
     from ajenti.ui import UI
     temp_ui = UI.new()
     for plugin in manager.get_order():
         layout_dir = os.path.join(manager.resolve_path(plugin), 'layout')
         if os.path.exists(layout_dir):
             for layout in os.listdir(layout_dir):
                 layout = '%s:%s' % (plugin, layout.split('.')[0])
                 logging.debug('Precaching layout %s' % layout)
                 self.inflate(temp_ui, layout)
コード例 #12
0
ファイル: api.py プロジェクト: vlara/ajenti
 def get_main_ui(self):
     ui = self.app.inflate('webserver_common:main')
     tc = UI.TabControl(active=self._tab)
     if self.ws_vhosts:
         tc.add('Hosts', self.get_ui_hosts(ui))
     else:
         ui.remove('addhost')
     if self.ws_mods:
         tc.add('Modules', self.get_ui_mods(ui))
     ui.append('main', tc)
     return ui
コード例 #13
0
    def precache(self):
        from ajenti.ui import UI

        temp_ui = UI.new()
        for plugin in manager.get_order():
            layout_dir = os.path.join(manager.resolve_path(plugin), "layout")
            if os.path.exists(layout_dir):
                for layout in os.listdir(layout_dir):
                    layout_name = os.path.splitext(layout)[0]
                    if layout_name:
                        layout = "%s:%s" % (plugin, layout_name)
                        logging.debug("Precaching layout %s" % layout)
                        self.inflate(temp_ui, layout)
コード例 #14
0
ファイル: backend.py プロジェクト: Ozerich/ajenti
 def get_ui_states(self, desc):
     v = self.state
     return UI.LayoutTableRow(
         UI.Label(text=desc),
         UI.Select(UI.SelectOption(text='Ignore',
                                   value='ign',
                                   selected=v[1] is None),
                   UI.SelectOption(text='Is',
                                   value='nrm',
                                   selected=not v[0] and v[1] is not None),
                   UI.SelectOption(text='Isn\'t',
                                   value='inv',
                                   selected=v[0] and v[1] is not None),
                   name='state-mode'),
         UI.LayoutTableCell(UI.LayoutTable(
             UI.LayoutTableRow(*[
                 UI.Checkbox(text=x,
                             name='state[]',
                             value=x,
                             checked=v[1] and x in v[1])
                 for x in self.states
             ])),
                            colspan=2))
コード例 #15
0
ファイル: root.py プロジェクト: Ozerich/ajenti
 def main_ui(self):
     templ = self.app.get_template('main.xml')
     templ.appendChildInto('main-content', self.selected_category.get_ui())
     if self._about_visible:
         templ.appendChildInto('main-content', self.get_ui_about())
     for p in self.app.grab_plugins(IProgressBoxProvider):
         if p.has_progress():
             templ.appendChildInto(
                 'progressbox-placeholder',
                 UI.TopProgressBox(text=p.get_progress(),
                                   icon=p.icon,
                                   title=p.title,
                                   can_abort=p.can_abort))
             break
     return templ
コード例 #16
0
ファイル: backend.py プロジェクト: Ozerich/ajenti
 def get_ui_text(self, param, desc, help=''):
     v = getattr(self, param)
     return UI.LayoutTableRow(
         UI.Label(text=desc),
         UI.Select(UI.SelectOption(text='Ignore',
                                   value='ign',
                                   selected=v[1] is None),
                   UI.SelectOption(text='Is',
                                   value='nrm',
                                   selected=not v[0] and v[1] is not None),
                   UI.SelectOption(text='Isn\'t',
                                   value='inv',
                                   selected=v[0] and v[1] is not None),
                   name='%s-mode' % param),
         UI.TextInput(name=param, value=v[1] or '', help=help))
コード例 #17
0
ファイル: main.py プロジェクト: vlara/ajenti
 def fill(self, side, lst, ui, tgt):
     for x in lst:
         try:
             w = self._mgr.get_widget_object(x)
             if not w:
                 continue
             ui.append(tgt,
                 UI.Widget(
                     w.get_ui(self._mgr.get_widget_config(x), id=str(x)),
                     pos=side,
                     icon=w.icon,
                     style=w.style,
                     title=w.title,
                     id=str(x),
                 )
             )
         except:
             raise
コード例 #18
0
ファイル: backend.py プロジェクト: Ozerich/ajenti
 def get_ui_bool(self, param, desc):
     v = getattr(self, param)
     return UI.LayoutTableRow(
         UI.Label(text=desc),
         UI.Select(UI.SelectOption(text='Ignore',
                                   value='ign',
                                   selected=v[1] is None),
                   UI.SelectOption(text='Yes',
                                   value='nrm',
                                   selected=v[1] == True),
                   UI.SelectOption(text='No',
                                   value='inv',
                                   selected=v[1] == False),
                   name='%s-mode' % param))
コード例 #19
0
ファイル: api.py プロジェクト: vlara/ajenti
 def get_ui_mods(self, gui):
     ui = self.app.inflate('webserver_common:mods')
     tbl = ui.find('list') 
     
     mods = self._backend.get_mods()
     for x in sorted(mods.keys()):
         tbl.append(UI.DTR(
                     UI.Image(file='/dl/core/ui/stock/status-%sabled.png'%(
                         'en' if mods[x].enabled else 'dis')),
                     UI.Label(text=x),
                     UI.DTD(
                         UI.HContainer(
                             UI.TipIcon(
                                 icon='/dl/core/ui/stock/edit.png',
                                 id='editmod/'+x, 
                                 text='Edit'
                             ) if mods[x].has_config else None,
                             UI.TipIcon(
                                 icon='/dl/core/ui/stock/'+ ('dis' if mods[x].enabled else 'en') + 'able.png',
                                 id='togglemod/'+x, 
                                 text='Disable' if mods[x].enabled else 'Enable'
                             ),
                             spacing=0
                         ),
                         hidden=True
                     )
                   ))
     
     if self._editing_mod is not None:
         gui.append(
             'main',
             UI.InputBox(
                 extra='code',
                 text='Module config:', 
                 value=self._backend.get_mods()[self._editing_mod].config,
                 id='dlgEditMod'
             )
         )
         
     return ui
コード例 #20
0
ファイル: backend.py プロジェクト: Ozerich/ajenti
    def get_ui_select(self, param, desc, opts, size=10):
        # opts == [['Desc', 'value'], ['Desc #2', 'value2']]
        v = getattr(self, param)

        return UI.LayoutTableRow(
            UI.Label(text=desc),
            UI.Select(UI.SelectOption(text='Ignore',
                                      value='ign',
                                      selected=v[1] is None),
                      UI.SelectOption(text='Is',
                                      value='nrm',
                                      selected=not v[0] and v[1] is not None),
                      UI.SelectOption(text='Isn\'t',
                                      value='inv',
                                      selected=v[0] and v[1] is not None),
                      name='%s-mode' % param),
            UI.SelectTextInput(*[
                UI.SelectOption(text=x[0], value=x[1], selected=v[1] == x[1])
                for x in opts
            ],
                               name=param,
                               value=v[1] or '',
                               size=size))
コード例 #21
0
 def get_ui_text(self, param, help=''):
     v = getattr(self, param)
     return UI.HContainer(UI.SelectInput(
         UI.SelectOption(text='Ign.', value='ign', selected=v[1] is None),
         UI.SelectOption(text='Is',
                         value='nrm',
                         selected=not v[0] and v[1] is not None),
         UI.SelectOption(text='Isn\'t',
                         value='inv',
                         selected=v[0] and v[1] is not None),
         design='mini',
         name='%s-mode' % param),
                          UI.TextInput(name=param,
                                       value=v[1] or '',
                                       help=help),
                          spacing=5)
コード例 #22
0
ファイル: root.py プロジェクト: vlara/ajenti
    def main_ui(self):
        self.selected_category.on_init()
        templ = self.app.inflate('core:main')

        if self.app.config.get('ajenti', 'nofx', '') != '1':
            templ.remove('fx-disable')

        if self._about_visible:
            templ.append('main-content', self.get_ui_about())

        templ.append('main-content', self.selected_category.get_ui())

        if self.app.session.has_key('messages'):
            for msg in self.app.session['messages']:
                templ.append(
                    'system-messages',
                    UI.SystemMessage(
                        cls=msg[0],
                        text=msg[1],
                    )
                )
            del self.app.session['messages']
        return templ
コード例 #23
0
 def get_ui_states(self):
     v = self.state
     return UI.HContainer(
         UI.SelectInput(
             UI.SelectOption(text='Ign.',
                             value='ign',
                             selected=v[1] is None),
             UI.SelectOption(text='Is',
                             value='nrm',
                             selected=not v[0] and v[1] is not None),
             UI.SelectOption(text='Isn\'t',
                             value='inv',
                             selected=v[0] and v[1] is not None),
             design='mini',
             name='state-mode',
         ),
         UI.HContainer(*[
             UI.Checkbox(text=x,
                         name='state[]',
                         value=x,
                         checked=v[1] and x in v[1]) for x in self.states
         ]))
コード例 #24
0
    def get_ui_select(self, param, opts):
        # opts == [['Desc', 'value'], ['Desc #2', 'value2']]
        v = getattr(self, param)

        return UI.HContainer(UI.SelectInput(
            UI.SelectOption(text='Ign.', value='ign', selected=v[1] is None),
            UI.SelectOption(text='Is',
                            value='nrm',
                            selected=not v[0] and v[1] is not None),
            UI.SelectOption(text='Isn\'t',
                            value='inv',
                            selected=v[0] and v[1] is not None),
            design='mini',
            name='%s-mode' % param),
                             UI.SelectTextInput(*[
                                 UI.SelectOption(text=x[0],
                                                 value=x[1],
                                                 selected=v[1] == x[1])
                                 for x in opts
                             ],
                                                name=param,
                                                value=v[1] or '',
                                                design='mini'),
                             spacing=5)
コード例 #25
0
ファイル: backend.py プロジェクト: Ozerich/ajenti
    def get_ui_flags(self, desc):
        v = self.tcp_flags

        return UI.LayoutTableRow(
            UI.Label(text=desc),
            UI.Select(UI.SelectOption(text='Ignore',
                                      value='ign',
                                      selected=v[1] is None),
                      UI.SelectOption(text='Are',
                                      value='nrm',
                                      selected=not v[0] and v[1] is not None),
                      UI.SelectOption(text='Are not',
                                      value='inv',
                                      selected=v[0] and v[1] is not None),
                      name='tcpflags-mode'),
            UI.LayoutTableCell(UI.LayoutTable(
                UI.LayoutTableRow(
                    UI.Label(text='Check:'), *[
                        UI.Checkbox(text=x,
                                    name='tcpflags-vals[]',
                                    value=x,
                                    checked=x in v[2] if v[2] else False)
                        for x in self.flags
                    ]),
                UI.LayoutTableRow(
                    UI.Label(text='Mask:'), *[
                        UI.Checkbox(text=x,
                                    name='tcpflags-mask[]',
                                    value=x,
                                    checked=x in v[1] if v[1] else False)
                        for x in self.flags
                    ])),
                               colspan=2))
コード例 #26
0
        def get_ui_mods(self):
            tbl = UI.DataTable(
                UI.DataTableRow(UI.DataTableCell(UI.Label(), width='20px'),
                                UI.DataTableCell(UI.Label(text='Name'),
                                                 width='200px'),
                                UI.DataTableCell(UI.Label(text='')),
                                header=True))

            mods = self._backend.get_mods()
            for x in sorted(mods.keys()):
                tbl.append(
                    UI.DataTableRow(
                        UI.Image(file='/dl/core/ui/stock/status-%sabled.png' %
                                 ('en' if mods[x].enabled else 'dis')),
                        UI.Label(text=x),
                        UI.DataTableCell(UI.HContainer(
                            UI.MiniButton(id='editmod/' + x, text='Edit')
                            if mods[x].has_config else None,
                            UI.MiniButton(id='togglemod/' + x,
                                          text='Disable'
                                          if mods[x].enabled else 'Enable'),
                            spacing=0),
                                         hidden=True)))

            ui = UI.Container(tbl)
            if self._editing_mod is not None:
                ui.append(
                    UI.AreaInputBox(text='Module config:',
                                    value=self._backend.get_mods()[
                                        self._editing_mod].config,
                                    id='dlgEditMod'))

            return ui
コード例 #27
0
ファイル: root.py プロジェクト: vlara/ajenti
    def process(self, req, start_response):
        self.do_init()

        templ = self.app.get_template('index.xml')

        cat = None
        v = UI.VContainer(spacing=0)

        # Sort plugins by name
        cats = self.app.grab_plugins(ICategoryProvider)
        cats = sorted(cats, key=lambda p: p.text)

        for fld in self.folder_ids:
            cat_vc = UI.VContainer(spacing=0)
            if self.folders[fld] == '':
                cat_folder = cat_vc # Omit wrapper for special folders
            else:
                cat_folder = UI.CategoryFolder(
                                cat_vc,
                                text=self.folders[fld],
                                icon='/dl/core/ui/catfolders/'+ fld + '.png'
                                    if self.folders[fld] != '' else '',
                                id=fld
                             )
            # cat_vc will be VContainer or CategoryFolder

            exp = False
            empty = True
            for c in cats:
                if c.folder == fld: # Put corresponding plugins in this folder
                    empty = False
                    if c == self.selected_category:
                        exp = True
                    cat_vc.append(UI.Category(
                        icon=c.icon,
                        name=c.text,
                        id=c.plugin_id,
                        counter=c.get_counter(),
                        selected=c == self.selected_category
                    ))

            if not empty: v.append(cat_folder)
            cat_folder['expanded'] = exp

        for c in cats:
            if c.folder in ['top', 'bottom']:
                templ.append(
                    'topplaceholder-'+c.folder,
                    UI.TopCategory(
                        text=c.text,
                        id=c.plugin_id,
                        icon=c.icon,
                        counter=c.get_counter(),
                        selected=c==self.selected_category
                    )
                )

        templ.append('_head', UI.HeadTitle(text='Ajenti @ %s'%platform.node()))
        templ.append('leftplaceholder', v)
        templ.append('version', UI.Label(text='Ajenti '+version(), size=2))
        templ.insertText('cat-username', self.app.auth.user)
        templ.appendAll('links', 
                UI.LinkLabel(text='About', id='about'),
                UI.OutLinkLabel(text='License', url='http://www.gnu.org/licenses/lgpl.html')
            )

        return templ.render()
コード例 #28
0
        def get_ui_hosts(self):
            tbl = UI.DataTable(
                UI.DataTableRow(UI.Label(),
                                UI.Label(text='Name'),
                                UI.Label(),
                                header=True))

            hosts = self._backend.get_hosts()
            for x in sorted(hosts.keys()):
                tbl.append(
                    UI.DataTableRow(
                        UI.Image(file='/dl/core/ui/stock/status-%sabled.png' %
                                 ('en' if hosts[x].enabled else 'dis')),
                        UI.Label(text=x),
                        UI.DataTableCell(UI.HContainer(
                            UI.MiniButton(id='edithost/' + x, text='Edit'),
                            UI.MiniButton(id='togglehost/' + x,
                                          text='Disable'
                                          if hosts[x].enabled else 'Enable'),
                            UI.WarningMiniButton(id='deletehost/' + x,
                                                 text='Delete',
                                                 msg='Delete host %s' % x),
                            spacing=0),
                                         hidden=True)))

            ui = UI.VContainer(tbl, UI.Button(text='Add host', id='addhost'))

            if self._creating_host:
                ui.append(
                    UI.InputBox(text='Host config name:', id='dlgCreateHost'))

            if self._editing_host is not None:
                ui.append(
                    UI.AreaInputBox(text='Host config:',
                                    value=self._backend.get_hosts()[
                                        self._editing_host].config,
                                    id='dlgEditHost'))

            return ui
コード例 #29
0
ファイル: main.py プロジェクト: vlara/ajenti
                                "Clients: {0}".format(stats["nclients"]))
        ui.find("bytesin").set(
            "text", "Bytes in: {0}".format(str_fsize(float(stats["bytesin"]))))
        ui.find("bytesout").set(
            "text",
            "Bytes out: {0}".format(str_fsize(float(stats["bytesout"]))))

        map(
            lambda c: ui.append(
                "clients",
                UI.DTR(
                    UI.Icon(icon="/dl/core/ui/stock/user.png"),
                    UI.Label(text=c["cn"]), UI.Label(text=c["raddress"]),
                    UI.Label(text=c["vaddress"]),
                    UI.Label(text=str_fsize(float(c["brecv"]))),
                    UI.Label(text=str_fsize(float(c["bsent"]))),
                    UI.Label(text=c["connsince"]),
                    UI.TipIcon(icon="/dl/core/ui/stock/delete.png",
                               text="Disconnect",
                               warning="Disconnect {0} ({1})?".format(
                                   c["cn"], c["raddress"]),
                               id="disconnect/{0}".format(c["raddress"])))),
            status["clients"])

        map(
            lambda m: ui.append(
                "messages",
                UI.DTR(UI.Label(text=ctime(float(m[0]))), UI.Label(text=m[1]),
                       UI.Label(text=m[2]))), messages)

        return ui
コード例 #30
0
    def get_ui(self):
        ui = self.app.inflate('cron:main')
        ui.find('tabs').set('active', self._tab)
        ui.find('title').set('text', 'Scheduled tasks for %s' % self._user)
        user_sel = [
            UI.SelectOption(text=x,
                            value=x,
                            selected=True if x == self._user else False)
            for x in backend.get_all_users()
        ]
        ui.appendAll('users_select', *user_sel)

        table_other = ui.find("table_other")
        table_task = ui.find("table_task")
        #Fill non-task strings table
        for i, oth_str in enumerate(self._others):
            table_other.append(
                UI.DTR(
                    UI.Label(text=oth_str),
                    UI.DTD(UI.HContainer(
                        UI.TipIcon(icon='/dl/core/ui/stock/edit.png',
                                   id='edit_oth/' + str(i),
                                   text='Edit'),
                        UI.TipIcon(icon='/dl/core/ui/stock/delete.png',
                                   id='del_oth/' + str(i),
                                   text='Delete',
                                   warning='Delete a string')),
                           hidden=True)))
        #Fill tasks table
        for i, t in enumerate(self._tasks):
            table_task.append(
                UI.DTR(
                    UI.Label(text=t.special if t.special else t.m),
                    UI.Label(text=t.h if not t.special else ''),
                    UI.Label(text=t.dom if not t.special else ''),
                    UI.Label(text=t.mon if not t.special else ''),
                    UI.Label(text=t.dow if not t.special else ''),
                    UI.Label(text=t.command),
                    UI.DTD(
                        UI.HContainer(
                            UI.TipIcon(icon='/dl/core/ui/stock/edit.png',
                                       id='edit_task/' + str(i),
                                       text='Edit'),
                            UI.TipIcon(icon='/dl/core/ui/stock/delete.png',
                                       id='del_task/' + str(i),
                                       text='Delete',
                                       warning='Delete a task')), )))
        #if crontab return error
        part = self._error.partition(':')[2]
        self._error = 'Error:' + part if part else self._error
        if self._error:
            self.put_message('err', self._error)

        #For tabs name
        REGULARTAB = 11
        ADVANCEDTAB = 12
        SPECIALTAB = 13
        #special values
        avaible_values = ('@reboot', '@hourly', '@daily', '@weekly',
                          '@monthly', '@yearly')
        #edit or new task
        if self._editing_task != -1:
            try:
                task = self._tasks[self._editing_task]
            except IndexError:
                task = backend.Task()
            #edit task
            if not self._newtask:
                ui.remove(str(REGULARTAB))
                if task.special:
                    ui.remove(str(ADVANCEDTAB))
                    ui.find('tabsEdit').set('active', SPECIALTAB)
                    #select special values
                    if task.special and task.special in avaible_values:
                        ui.find('r' + task.special[1:]).\
                            set('checked', 'True')
                    else:
                        ui.find('rreboot').set('checked', 'True')
                    ui.find('s_command').set("value", task.command)
                else:
                    #fill advanced view task
                    ui.find('tabsEdit').set('active', ADVANCEDTAB)
                    ui.remove(str(SPECIALTAB))
                    ui.find('m').set("value", task.m)
                    ui.find('h').set("value", task.h)
                    ui.find('dom').set("value", task.dom)
                    ui.find('mon').set("value", task.mon)
                    ui.find('dow').set("value", task.dow)
                    ui.find('a_command').set("value", task.command)
            #new task
            else:
                ui.find('tabsEdit').set('active', REGULARTAB)
                ui.find('rreboot').set('checked', 'True')
                ui.find('m').set("value", task.m)
                ui.find('h').set("value", task.h)
                ui.find('dom').set("value", task.dom)
                ui.find('mon').set("value", task.mon)
                ui.find('dow').set("value", task.dow)
                #For templates
                ui.find('tabsRegular').set('active', 15)
                SelectOptionNumbs = lambda r: [
                    UI.SelectOption(text=str(m), value=str(m))
                    for m in xrange(r)
                ]
                #generate similar selectOptions lists for xml.
                minute_select_h = SelectOptionNumbs(60)
                minute_select_d = SelectOptionNumbs(60)
                minute_select_w = SelectOptionNumbs(60)
                minute_select_m = SelectOptionNumbs(60)
                hour_select_d = SelectOptionNumbs(24)
                hour_select_w = SelectOptionNumbs(24)
                hour_select_m = SelectOptionNumbs(24)

                weekday = ('Monday', 'Tuesday', 'Wednesday', 'Thursday',
                           'Friday', 'Saturday', 'Sunday')
                weekday_select = [
                    UI.SelectOption(text=str(w), value=str(v + 1))
                    for v, w in enumerate(weekday)
                ]
                day_select = [
                    UI.SelectOption(text=str(d), value=str(d))
                    for d in range(1, 32)
                ]
                #Fill selects
                ui.appendAll("minute_select_h", *minute_select_h)
                ui.appendAll("minute_select_d", *minute_select_d)
                ui.appendAll("minute_select_w", *minute_select_w)
                ui.appendAll("minute_select_m", *minute_select_m)
                ui.appendAll("hour_select_d", *hour_select_d)
                ui.appendAll("hour_select_w", *hour_select_w)
                ui.appendAll("hour_select_m", *hour_select_m)
                ui.appendAll("weekday_select", *weekday_select)
                ui.appendAll("day_select", *day_select)
        #Nothing happens with task
        else:
            ui.remove('dlgEditTask')
        #edit non-task string
        if self._editing_other != -1 and self._show_dialog:
            other_value = self._others[self._editing_other]\
                if self._editing_other < len(self._others) else ''
            ui.find("other_str").set("value", other_value)
        #Nothing happens with non-task string
        else:
            ui.remove('dlgEditOther')
        return ui
コード例 #31
0
    def get_ui_flags(self):
        v = self.tcp_flags

        return UI.HContainer(
            UI.SelectInput(UI.SelectOption(text='Ign.',
                                           value='ign',
                                           selected=v[1] is None),
                           UI.SelectOption(text='Are',
                                           value='nrm',
                                           selected=not v[0]
                                           and v[1] is not None),
                           UI.SelectOption(text='Are not',
                                           value='inv',
                                           selected=v[0] and v[1] is not None),
                           design='mini',
                           name='tcpflags-mode'),
            UI.LT(
                UI.LTR(
                    UI.Label(text='Check:'), *[
                        UI.Checkbox(text=x,
                                    name='tcpflags-vals[]',
                                    value=x,
                                    checked=x in v[2] if v[2] else False)
                        for x in self.flags
                    ]),
                UI.LTR(
                    UI.Label(text='Mask:'), *[
                        UI.Checkbox(text=x,
                                    name='tcpflags-mask[]',
                                    value=x,
                                    checked=x in v[1] if v[1] else False)
                        for x in self.flags
                    ])),
        )
コード例 #32
0
ファイル: root.py プロジェクト: Ozerich/ajenti
 def get_ui_about(self):
     ui = UI.Centerer(
         UI.VContainer(
             UI.Image(file='/dl/core/ui/logo_big.png'), UI.Spacer(height=6),
             UI.Label(text='Ajenti ' + version, size=4),
             UI.Label(text='Your personal server affairs agent'),
             UI.Spacer(height=10),
             UI.HContainer(
                 UI.OutLinkLabel(
                     url
                     ='http://www.assembla.com/spaces/ajenti/wiki?id=aLa8XiGfWr36nLeJe5cbLA',
                     text='Wiki'),
                 UI.OutLinkLabel(
                     url=
                     'http://www.assembla.com/spaces/ajenti/wiki?id=ajenti&wiki_id=Developers',
                     text='Credits'),
                 UI.OutLinkLabel(
                     text='License',
                     url='http://www.gnu.org/licenses/lgpl.html'),
                 UI.OutLinkLabel(
                     text='Bugs',
                     url=
                     'http://www.assembla.com/spaces/ajenti/support/tickets'
                 ),
                 spacing=6), UI.Spacer(height=10),
             UI.Button(text='Close', id='closeabout')))
     return UI.DialogBox(ui, hideok=True, hidecancel=True)