Exemplo n.º 1
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()
Exemplo n.º 2
0
    def get_ui(self):
        ui = self.app.inflate('sysmon:main')
        self._mgr = apis.dashboard.WidgetManager(self.app)
        self._mgr.refresh()
        self._failed = []

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

        if self._failed != []:
            ui.find('ui-dashboard-buttons').append(UI.Btn(id='btnCleanUp', text='Clean Up', iconfont='gen-remove'))

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

        if self._adding_widget == True:
            dlg = self.app.inflate('sysmon: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.Label(text=prov.name),
                    iconfont=prov.iconfont,
                    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
Exemplo n.º 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)
Exemplo n.º 4
0
        def get_ui_hosts(self, gui):
            ui = self.app.inflate('nginx:hosts')
            tbl = ui.find('list') 
               
            hosts = self._backend.get_hosts()
            for x in sorted(hosts.keys()):
                tbl.append(UI.DTR(
                            UI.TipIcon(iconfont='gen-%s'%(
                                'checkmark-circle' if hosts[x].enabled else 'minus-circle'),
                                text=('Enabled' if hosts[x].enabled else 'Disabled')
                            ),
                            UI.Label(text=x),
                            UI.DTD(
                                UI.HContainer(
                                    UI.TipIcon(
                                        iconfont='gen-pencil-2',
                                        id='edithost/'+x, 
                                        text='Edit'
                                    ),
                                    UI.TipIcon(
                                        iconfont='gen-'+ ('minus-circle' if hosts[x].enabled else 'checkmark-circle'),
                                        id='togglehost/'+x, 
                                        text='Disable' if hosts[x].enabled else 'Enable'
                                    ),
                                    UI.TipIcon(
                                        iconfont='gen-close',
                                        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
Exemplo n.º 5
0
Arquivo: main.py Projeto: tewe/genesis
    def get_ui(self):
        ui = self.app.inflate('sysmon:main')
        self._mgr = apis.dashboard.WidgetManager(self.app)
        self._mgr.refresh()
        self._failed = []

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

        if self._failed != []:
            ui.find('ui-dashboard-buttons').append(
                UI.Button(id='btnCleanUp',
                          text='Clean Up',
                          iconfont='gen-remove'))

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

        if self._adding_widget == True:
            dlg = self.app.inflate('sysmon: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.IconFont(iconfont=prov.iconfont),
                            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())

        if UpdateCheck.get().get_status()[0] == True:
            self.put_message(
                'info',
                'An update for Genesis is available. See the Settings pane for details.'
            )

        return ui
Exemplo n.º 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()
Exemplo n.º 7
0
 def get_ui_help(self):
     ui = self.app.inflate('core:help')
     ui.find('dlgHelp').set('title', 'Help: %s' % self.selected_category.text)
     try:
         ui.find('help-container').append(self.app.inflate('%s:help'%self.selected_category.pid))
     except:
         ui.find('help-container').append(UI.Label(size=1, text='No help found for this plugin'))
     return ui
Exemplo n.º 8
0
 def get_main_ui(self):
     ui = self.app.inflate('nginx:main')
     tc = UI.TabControl(active=self._tab)
     if self.ws_vhosts:
         tc.add('Hosts', self.get_ui_hosts(ui))
     else:
         ui.remove('addhost')
     ui.append('main', tc)
     return ui
Exemplo n.º 9
0
        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())
Exemplo n.º 10
0
    def main_ui(self):
        self.selected_category.on_init()
        templ = self.app.inflate('core:main')

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

        ta = self.app.config.get('genesis', 'timedalert', '')
        templ.find('timed-alerts').append(UI.JS(code='var timedAlerts = %s;'%ta if ta else '0'))

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

        if self._help_visible:
            templ.append('main-content', self.get_ui_help())

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

        if self.is_firstrun() and self.app.session.has_key('messages'):
            del self.app.session['messages']
        if self.app.session.has_key('messages'):
            for msg in self.app.session['messages']:
                if 'info' in msg[0]:
                    msgcls, ift = 'info', 'gen-info'
                elif 'warn' in msg[0]:
                    msgcls, ift = 'warning', 'gen-warning'
                elif 'success' in msg[0]:
                    msgcls, ift = 'success', 'gen-checkmark'
                else:
                    msgcls, ift = 'danger', 'gen-close'
                templ.append(
                    'message-box',
                    UI.SystemMessage(
                        cls=msgcls,
                        iconfont=ift,
                        text=msg[1],
                    )
                )
            del self.app.session['messages']
        return templ
Exemplo n.º 11
0
    def goto_embed(self, req, start_response):
        path = req['PATH_INFO'].split('/')
        host = req['HTTP_HOST']
        bhost = req['HTTP_HOST'].split(':')[0]
        ssl = False

        try:
            if path[3] == 'ssl':
                ssl = True
        except IndexError:
            pass

        content = self.app.inflate('core:embapp')
        content.insertText('ea-port', ':' + path[2])
        content.find('ea-link').set('href', req['wsgi.url_scheme']+'://'+host)
        content.append('ea-frame-container', UI.IFrame(id='ea-frame', 
            src=('https://' if ssl else 'http://')+bhost+':'+path[2]))
        self._cat_selected = 'dashboard'
        return content.render()
Exemplo n.º 12
0
 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,
                     iconfont=w.iconfont,
                     style=w.style,
                     title=w.title,
                     id=str(x),
                 )
             )
         except Exception, e:
             self.put_message('err', 'One or more widgets failed to load. Check the logs for info, or click Clean Up to remove the offending widget(s).')
             self._failed.append(x)
             self.app.log.error('System Monitor Widget failed to load '+w.title+': '+str(e))
Exemplo n.º 13
0
Arquivo: root.py Projeto: ajvb/genesis
    def main_ui(self):
        self.selected_category.on_init()
        templ = self.app.inflate('core:main')

        if self.app.config.get('genesis', '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
Exemplo n.º 14
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)
Exemplo n.º 15
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
         ]))
Exemplo n.º 16
0
    def process(self, req, start_response):
        self.do_init()

        if self.is_firstrun():
            templ = self.app.get_template('firstrun.xml')
        else:
            templ = self.app.get_template('index.xml')
            if self.app.platform == 'arkos':
                templ.remove('navbar-brand')
                templ.append('navbar-brand-div', UI.Image(cls='navbar-brand', file='/dl/core/ui/arkos.png'))

        # Sort plugins into menus where necessary
        cats = self.app.grab_plugins(ICategoryProvider)
        cats = sorted(cats, key=lambda p: p.text)

        if not self.is_firstrun():
            for c in cats:
                if c.folder in ['top', 'bottom']:
                    templ.append(
                        'topplaceholder-'+c.folder,
                        UI.TopCategory(
                            text=c.text,
                            id=c.plugin_id,
                            iconfont=c.iconfont,
                            counter=c.get_counter(),
                            selected=c==self.selected_category
                        )
                    )
                elif c.folder == 'tools':
                    templ.append(
                        'tools-placeholder',
                        UI.PopoverLink(iconfont=c.iconfont, text=c.text,
                            onclick="Genesis.selectCategory('"+c.plugin_id+"');", 
                        )
                    )
            templ.append('_head', UI.HeadTitle(text='Genesis @ %s'%platform.node()))
            templ.append('version', UI.Label(text='Genesis '+version(), size=2))
            templ.insertText('cat-username', self.app.auth.user)
            templ.appendAll('links', 
                    UI.LinkLabel(iconfont='gen-info', text='About', id='about'),
                )

        return templ.render()
Exemplo n.º 17
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)
Exemplo n.º 18
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
                    ])),
        )
Exemplo n.º 19
0
                                "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
Exemplo n.º 20
0
        def get_ui(self):
            from genesis.plugins.security.firewall import RuleManager, FWMonitor

            mgr = self.app.get_backend(apis.services.IServiceManager)
            rum = RuleManager(self.app)
            self._rules_list = rum.get_by_plugin(self.plugin_id)
            fwm = FWMonitor(self.app)

            res = UI.DT(UI.DTR(UI.DTH(width=20),
                               UI.DTH(UI.Label(text='Service')),
                               UI.DTH(width=20),
                               header=True),
                        width='100%',
                        noborder=True)

            alert = False

            services = self.plugin_info.services if hasattr(
                self.plugin_info, 'services') else self.services
            for s in services:
                ctl = UI.HContainer()

                try:
                    st = mgr.get_status(s['binary'])
                except:
                    st = 'failed'
                    alert = True
                try:
                    en = mgr.get_enabled(s['binary'])
                except:
                    en = 'failed'

                if st == 'running':
                    ctl.append(
                        UI.TipIcon(text='Stop',
                                   cls='servicecontrol',
                                   iconfont='gen-stop',
                                   id='stop/' + s['binary']))
                    ctl.append(
                        UI.TipIcon(text='Restart',
                                   cls='servicecontrol',
                                   iconfont='gen-loop-2',
                                   id='restart/' + s['binary']))
                else:
                    ctl.append(
                        UI.TipIcon(text='Start',
                                   cls='servicecontrol',
                                   iconfont='gen-play-2',
                                   id='start/' + s['binary']))
                    alert = True
                if en == 'enabled':
                    ctl.append(
                        UI.TipIcon(text='Disable',
                                   cls='servicecontrol',
                                   iconfont='gen-minus-circle',
                                   id='disable/' + s['binary']))
                else:
                    ctl.append(
                        UI.TipIcon(text='Enable',
                                   cls='servicecontrol',
                                   iconfont='gen-plus-circle',
                                   id='enable/' + s['binary']))

                t = UI.DTR(
                    UI.HContainer(
                        UI.IconFont(iconfont='gen-' +
                                    ('play-2' if st == 'running' else 'stop')),
                        UI.IconFont(
                            iconfont='gen-' +
                            ('checkmark' if en == 'enabled' else 'close-2')),
                    ), UI.Label(text='%s (%s)' % (s['name'], s['binary'])),
                    ctl)
                res.append(t)

            ptalert = False

            if self._rules_list != []:
                pts = UI.DT(UI.DTR(UI.DTH(width=20),
                                   UI.DTH(UI.Label(text='Application')),
                                   UI.DTH(UI.Label(text='Ports')),
                                   UI.DTH(UI.Label(text='Authorization')),
                                   UI.DTH(width=20),
                                   header=True),
                            width='100%',
                            noborder=True)
                for p in self._rules_list:
                    if p[1] == 1:
                        perm, ic, show = 'Local', 'gen-home', [2, 0]
                    elif p[1] == 2:
                        perm, ic, show = 'All', 'gen-earth', [1, 0]
                    else:
                        perm, ic, show = 'None', 'gen-close', [2, 1]
                        ptalert = True
                    pts.append(
                        UI.DTR(
                            UI.IconFont(iconfont=p[0].icon),
                            UI.Label(text=p[0].name),
                            UI.Label(text=', '.join(
                                str(x[1]) for x in p[0].ports)),
                            UI.HContainer(
                                UI.IconFont(iconfont=ic),
                                UI.Label(text=' '),
                                UI.Label(text=perm),
                            ),
                            UI.HContainer(
                                (UI.TipIcon(iconfont='gen-earth',
                                            text='Allow All',
                                            cls='servicecontrol',
                                            id='2/' +
                                            str(self._rules_list.index(p)))
                                 if 2 in show else None),
                                (UI.TipIcon(iconfont='gen-home',
                                            text='Local Only',
                                            cls='servicecontrol',
                                            id='1/' +
                                            str(self._rules_list.index(p)))
                                 if 1 in show else None),
                                (UI.TipIcon(
                                    iconfont='gen-close',
                                    text='Deny All',
                                    cls='servicecontrol',
                                    id='0/' + str(self._rules_list.index(p)),
                                    warning=
                                    'Are you sure you wish to deny all access to %s? '
                                    'This will prevent anyone (including you) from connecting to it.'
                                    % p[0].name) if 0 in show else None),
                            ),
                        ))

            panel = UI.ServicePluginPanel(
                alert=('True' if alert else 'False'),
                ports=('True' if self._rules_list != [] else 'False'),
                ptalert=('True' if ptalert else 'False'),
            )

            if self.display:
                dlg = UI.DialogBox(UI.ScrollContainer(res,
                                                      width=300,
                                                      height=300),
                                   id='dlgServices',
                                   hidecancel='True')
                return UI.Container(panel, dlg, self.get_main_ui())
            elif self.disports:
                dlg = UI.DialogBox(UI.ScrollContainer(pts,
                                                      width=300,
                                                      height=300),
                                   id='dlgPorts',
                                   hidecancel='True')
                return UI.Container(panel, dlg, self.get_main_ui())
            else:
                return UI.Container(panel, self.get_main_ui())
Exemplo n.º 21
0
    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(
                        iconfont=c.iconfont,
                        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,
                        iconfont=c.iconfont,
                        counter=c.get_counter(),
                        selected=c==self.selected_category
                    )
                )

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

        return templ.render()
Exemplo n.º 22
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(iconfont='gen-pencil-2',
                                   id='edit_oth/' + str(i),
                                   text='Edit'),
                        UI.TipIcon(iconfont='gen-cancel-circle',
                                   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(iconfont='gen-pencil-2',
                                       id='edit_task/' + str(i),
                                       text='Edit'),
                            UI.TipIcon(iconfont='gen-cancel-circle',
                                       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