示例#1
0
文件: main.py 项目: arcxxi/genesis
 def order(self, op, name, ptype='program', args=[]):
     if op == 'new':
         SVClient(self.app).set(ptype, name, args)
     elif op == 'del':
         SVClient(self.app).remove(name, restart=True)
     elif op == 'rel':
         SVClient(self.app).restart(name)
示例#2
0
文件: widget.py 项目: IsSuEat/genesis
 def get_config_dialog(self):
     mgr = SVClient(self.app)
     dlg = self.app.inflate('supervisor:widget-config')
     for s in mgr.list():
         dlg.append('list', UI.SelectOption(
             value=s['name'],
             text=s['name'],
         ))
     return dlg
示例#3
0
 def get_config_dialog(self):
     mgr = SVClient(self.app)
     dlg = self.app.inflate('supervisor:widget-config')
     for s in mgr.status():
         dlg.append('list', UI.SelectOption(
             value=s['name'],
             text=s['name'],
         ))
     return dlg
示例#4
0
class SVPlugin(apis.services.ServiceControlPlugin):
    text = "Supervisor"
    icon = "/dl/supervisor/icon.png"
    folder = "apps"
    service_name = "supervisor"

    def on_session_start(self):
        self._client = SVClient(self.app)
        self._tail = None

    def get_main_ui(self):
        ui = self.app.inflate("supervisor:main")

        if not self._client.test():
            raise ConfigurationError("Please check supervisorctl configuration")

        for x in self._client.status():
            ui.append(
                "list",
                UI.DTR(
                    UI.Label(text=x["name"]),
                    UI.Label(text=x["status"]),
                    UI.Label(text=x["info"]),
                    UI.HContainer(
                        UI.TipIcon(id="start/" + x["name"], text="Iniciar", icon="/dl/core/ui/stock/service-start.png")
                        if x["status"] != "RUNNING"
                        else None,
                        UI.TipIcon(
                            id="restart/" + x["name"], text="Reiniciar", icon="/dl/core/ui/stock/service-restart.png"
                        )
                        if x["status"] == "RUNNING"
                        else None,
                        UI.TipIcon(id="stop/" + x["name"], text="Parar", icon="/dl/core/ui/stock/service-stop.png")
                        if x["status"] == "RUNNING"
                        else None,
                        UI.TipIcon(id="tail/" + x["name"], text="Log final", icon="/dl/core/ui/stock/paste.png"),
                    ),
                ),
            )

        if self._tail is not None:
            ui.append("main", UI.InputBox(value=self._client.tail(self._tail), hidecancel=True, extra="code"))

        return ui

    @event("button/click")
    def on_button(self, event, params, vars=None):
        if params[0] == "start":
            self._client.start(params[1])
        if params[0] == "restart":
            self._client.restart(params[1])
        if params[0] == "stop":
            self._client.stop(params[1])
        if params[0] == "tail":
            self._tail = params[1]

    @event("dialog/submit")
    def on_submit(self, event, params, vars=None):
        self._tail = None
示例#5
0
 def handle(self, event, params, cfg, vars=None):
     mgr = SVClient(self.app)
     if params[0] == 'start':
         mgr.start(cfg)
     if params[0] == 'stop':
         mgr.stop(cfg)
     if params[0] == 'restart':
         mgr.restart(cfg)
示例#6
0
文件: widget.py 项目: IsSuEat/genesis
 def handle(self, event, params, cfg, vars=None):
     mgr = SVClient(self.app)
     if params[0] == 'start':
         mgr.start(cfg)
     if params[0] == 'stop':
         mgr.stop(cfg)
     if params[0] == 'restart':
         mgr.restart(cfg)
示例#7
0
文件: widget.py 项目: IsSuEat/genesis
    def get_ui(self, cfg, id=None):
        mgr = SVClient(self.app)
        running = False

        for x in mgr.list():
            if x['name'] == cfg and x['status'] == 'RUNNING':
                running = True

        self.title = cfg
        self.iconfont = 'gen-' + ('play-2' if running else 'stop')

        ui = self.app.inflate('supervisor:widget')
        if running:
            ui.remove('start')
            ui.find('stop').set('id', id+'/stop')
            ui.find('restart').set('id', id+'/restart')
        else:
            ui.remove('stop')
            ui.remove('restart')
            ui.find('start').set('id', id+'/start')
        return ui
示例#8
0
    def get_ui(self, cfg, id=None):
        mgr = SVClient(self.app)
        running = False

        for x in mgr.status():
            if x['name'] == cfg and x['status'] == 'RUNNING':
                running = True

        self.title = cfg
        self.icon = '/dl/core/ui/stock/service-' + ('run.png' if running else 'stop.png')

        ui = self.app.inflate('supervisor:widget')
        if running:
            ui.remove('start')
            ui.find('stop').set('id', id+'/stop')
            ui.find('restart').set('id', id+'/restart')
        else:
            ui.remove('stop')
            ui.remove('restart')
            ui.find('start').set('id', id+'/start')
        return ui
示例#9
0
文件: widget.py 项目: tewe/genesis
    def get_ui(self, cfg, id=None):
        mgr = SVClient(self.app)
        running = False

        for x in mgr.list():
            if x['name'] == cfg and x['status'] == 'RUNNING':
                running = True

        self.title = cfg
        self.iconfont = 'gen-' + ('play-2' if running else 'stop')

        ui = self.app.inflate('supervisor:widget')
        if running:
            ui.remove('start')
            ui.find('stop').set('id', id + '/stop')
            ui.find('restart').set('id', id + '/restart')
        else:
            ui.remove('stop')
            ui.remove('restart')
            ui.find('start').set('id', id + '/start')
        return ui
示例#10
0
文件: main.py 项目: IsSuEat/genesis
class SVPlugin(apis.services.ServiceControlPlugin):
    text = 'Supervisor'
    iconfont = 'gen-bullhorn'
    folder = 'system'

    def on_session_start(self):
        self._client = SVClient(self.app)
        self._tail = None
        self._set = None

    def get_main_ui(self):
        ui = self.app.inflate('supervisor:main')

        if not self._client.test():
            self.put_message('err', 'Supervisor is not running. '
                'Please start it via the Status button to see your tasks.')

        for x in self._client.list():
            ui.append('list', UI.DTR(
                UI.Label(text=x['name']),
                UI.Label(text=x['ptype']),
                UI.Label(text=x['status']),
                UI.Label(text=x['info']),
                UI.HContainer(
                    UI.TipIcon(
                        id='start/'+x['name'],
                        text='Start',
                        iconfont='gen-play-2',
                    ) if x['status'] != 'RUNNING' else None,
                    UI.TipIcon(
                        id='restart/'+x['name'],
                        text='Restart',
                        iconfont='gen-loop-2',
                    ) if x['status'] == 'RUNNING' else None,
                    UI.TipIcon(
                        id='stop/'+x['name'],
                        text='Stop',
                        iconfont='gen-stop',
                    ) if x['status'] == 'RUNNING' else None,
                    UI.TipIcon(
                        id='set/'+x['ptype']+'/'+x['name'],
                        text='Edit',
                        iconfont='gen-pencil',
                    ),
                    UI.TipIcon(
                        id='remove/'+x['name'],
                        text='Remove',
                        iconfont='gen-cancel-circle',
                        warning='Are you sure you want to remove the process %s?'%x['name']
                    ),
                    UI.TipIcon(
                        id='tail/'+x['name'],
                        text='Show logs',
                        iconfont='gen-paste',
                    )
                ),
            ))

        if self._tail:
            ui.append('main', UI.InputBox(
                value=self._client.tail(self._tail),
                hidecancel=True,
                extra='code', id='dlgTail'
            ))

        if self._set and self._set != True:
            ui.find('p%s'%self._set[0]).set('selected', True)
            ui.find('name').set('value', self._set[1])
            ui.find('config').set('value', '\n'.join(['%s = %s' % (x[0], x[1]) for x in self._client.get(self._set[1])]))
        elif not self._set:
            ui.remove('dlgSet')

        return ui

    @event('button/click')
    def on_button(self, event, params, vars=None):
        if params[0] == 'start':
            self._client.start(params[1])
        if params[0] == 'restart':
            self._client.restart(params[1])
        if params[0] == 'stop':
            self._client.stop(params[1])
        if params[0] == 'set':
            if len(params) >= 2:
                self._set = (params[1], params[2])
            else:
                self._set = True
        if params[0] == 'remove':
            self._client.remove(params[1])
        if params[0] == 'tail':
            self._tail = params[1]
        if params[0] == 'reload':
            self._client.run('reload')

    @event('dialog/submit')
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgTail':
            self._tail = None
        elif params[0] == 'dlgSet':
            if vars.getvalue('action', '') == 'OK':
                name = vars.getvalue('name', '')
                ptype = vars.getvalue('ptype', '')
                cfg = vars.getvalue('config', '')
                self._client.set(ptype, name, [x.split(' = ') for x in cfg.split('\n')])
                if self._set and self._set != True and name != self._set[1]:
                    self._client.remove(self._set[1])
            self._set = None
示例#11
0
文件: main.py 项目: IsSuEat/genesis
 def on_session_start(self):
     self._client = SVClient(self.app)
     self._tail = None
     self._set = None
示例#12
0
文件: main.py 项目: arcxxi/genesis
class SVPlugin(apis.services.ServiceControlPlugin):
    text = 'Supervisor'
    iconfont = 'gen-bullhorn'
    folder = 'system'

    def on_session_start(self):
        self._client = SVClient(self.app)
        self._tail = None
        self._set = None

    def get_main_ui(self):
        ui = self.app.inflate('supervisor:main')

        if not self._client.test():
            self.put_message(
                'err', 'Supervisor is not running. '
                'Please start it via the Status button to see your tasks.')

        for x in self._client.list():
            ui.append(
                'list',
                UI.DTR(
                    UI.Label(text=x['name']),
                    UI.Label(text=x['ptype']),
                    UI.Label(text=x['status']),
                    UI.Label(text=x['info']),
                    UI.HContainer(
                        UI.TipIcon(
                            id='start/' + x['name'],
                            text='Start',
                            iconfont='gen-play-2',
                        ) if x['status'] != 'RUNNING' else None,
                        UI.TipIcon(
                            id='restart/' + x['name'],
                            text='Restart',
                            iconfont='gen-loop-2',
                        ) if x['status'] == 'RUNNING' else None,
                        UI.TipIcon(
                            id='stop/' + x['name'],
                            text='Stop',
                            iconfont='gen-stop',
                        ) if x['status'] == 'RUNNING' else None,
                        UI.TipIcon(
                            id='set/' + x['ptype'] + '/' + x['name'],
                            text='Edit',
                            iconfont='gen-pencil',
                        ),
                        UI.TipIcon(
                            id='remove/' + x['name'],
                            text='Remove',
                            iconfont='gen-cancel-circle',
                            warning=
                            'Are you sure you want to remove the process %s?' %
                            x['name']),
                        UI.TipIcon(
                            id='tail/' + x['name'],
                            text='Show logs',
                            iconfont='gen-paste',
                        )),
                ))

        if self._tail:
            ui.append(
                'main',
                UI.InputBox(value=self._client.tail(self._tail),
                            hidecancel=True,
                            extra='code',
                            id='dlgTail'))

        if self._set and self._set != True:
            ui.find('p%s' % self._set[0]).set('selected', True)
            ui.find('name').set('value', self._set[1])
            ui.find('config').set(
                'value', '\n'.join([
                    '%s = %s' % (x[0], x[1])
                    for x in self._client.get(self._set[1])
                ]))
        elif not self._set:
            ui.remove('dlgSet')

        return ui

    @event('button/click')
    def on_button(self, event, params, vars=None):
        if params[0] == 'start':
            self._client.start(params[1])
        if params[0] == 'restart':
            self._client.restart(params[1])
        if params[0] == 'stop':
            self._client.stop(params[1])
        if params[0] == 'set':
            if len(params) >= 2:
                self._set = (params[1], params[2])
            else:
                self._set = True
        if params[0] == 'remove':
            self._client.remove(params[1])
        if params[0] == 'tail':
            self._tail = params[1]
        if params[0] == 'reload':
            self._client.run('reload')

    @event('dialog/submit')
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgTail':
            self._tail = None
        elif params[0] == 'dlgSet':
            if vars.getvalue('action', '') == 'OK':
                name = vars.getvalue('name', '')
                ptype = vars.getvalue('ptype', '')
                cfg = vars.getvalue('config', '')
                self._client.set(ptype, name,
                                 [x.split(' = ') for x in cfg.split('\n')])
                if self._set and self._set != True and name != self._set[1]:
                    self._client.remove(self._set[1])
            self._set = None
示例#13
0
文件: main.py 项目: arcxxi/genesis
 def on_session_start(self):
     self._client = SVClient(self.app)
     self._tail = None
     self._set = None
示例#14
0
文件: main.py 项目: Bryukh/ajenti
class SVPlugin(apis.services.ServiceControlPlugin):
    text = 'Supervisor'
    icon = '/dl/supervisor/icon.png'
    folder = 'apps'
    service_name = 'supervisor'

    def on_session_start(self):
        self._client = SVClient(self.app)
        self._tail = None

    def get_main_ui(self):
        ui = self.app.inflate('supervisor:main')

        if not self._client.test():
            raise ConfigurationError('Please check supervisorctl configuration')

        for x in self._client.status():
            ui.append('list', UI.DTR(
                UI.Label(text=x['name']),
                UI.Label(text=x['status']),
                UI.Label(text=x['info']),
                UI.HContainer(
                    UI.TipIcon(
                        id='start/'+x['name'],
                        text='Start',
                        icon='/dl/core/ui/stock/service-start.png',
                    ) if x['status'] != 'RUNNING' else None,
                    UI.TipIcon(
                        id='restart/'+x['name'],
                        text='Restart',
                        icon='/dl/core/ui/stock/service-restart.png',
                    ) if x['status'] == 'RUNNING' else None,
                    UI.TipIcon(
                        id='stop/'+x['name'],
                        text='Stop',
                        icon='/dl/core/ui/stock/service-stop.png',
                    ) if x['status'] == 'RUNNING' else None,
                    UI.TipIcon(
                        id='tail/'+x['name'],
                        text='Log tail',
                        icon='/dl/core/ui/stock/paste.png',
                    )
                ),
            ))

        if self._tail is not None:
            ui.append('main', UI.InputBox(
                value=self._client.tail(self._tail),
                hidecancel=True,
                extra='code',
            ))


        return ui

    @event('button/click')
    def on_button(self, event, params, vars=None):
        if params[0] == 'start':
            self._client.start(params[1])
        if params[0] == 'restart':
            self._client.restart(params[1])
        if params[0] == 'stop':
            self._client.stop(params[1])
        if params[0] == 'tail':
            self._tail = params[1]

    @event('dialog/submit')
    def on_submit(self, event, params, vars=None):
        self._tail = None
示例#15
0
class SVPlugin(apis.services.ServiceControlPlugin):
    text = 'Supervisor'
    icon = '/dl/supervisor/icon.png'
    folder = 'apps'
    service_name = 'supervisor'

    def on_session_start(self):
        self._client = SVClient(self.app)
        self._tail = None

    def get_main_ui(self):
        ui = self.app.inflate('supervisor:main')

        if not self._client.test():
            raise ConfigurationError(
                'Please check supervisorctl configuration')

        for x in self._client.status():
            ui.append(
                'list',
                UI.DTR(
                    UI.Label(text=x['name']),
                    UI.Label(text=x['status']),
                    UI.Label(text=x['info']),
                    UI.HContainer(
                        UI.TipIcon(
                            id='start/' + x['name'],
                            text='Start',
                            icon='/dl/core/ui/stock/service-start.png',
                        ) if x['status'] != 'RUNNING' else None,
                        UI.TipIcon(
                            id='restart/' + x['name'],
                            text='Restart',
                            icon='/dl/core/ui/stock/service-restart.png',
                        ) if x['status'] == 'RUNNING' else None,
                        UI.TipIcon(
                            id='stop/' + x['name'],
                            text='Stop',
                            icon='/dl/core/ui/stock/service-stop.png',
                        ) if x['status'] == 'RUNNING' else None,
                        UI.TipIcon(
                            id='tail/' + x['name'],
                            text='Log tail',
                            icon='/dl/core/ui/stock/paste.png',
                        )),
                ))

        if self._tail is not None:
            ui.append(
                'main',
                UI.InputBox(
                    value=self._client.tail(self._tail),
                    hidecancel=True,
                    extra='code',
                ))

        return ui

    @event('button/click')
    def on_button(self, event, params, vars=None):
        if params[0] == 'start':
            self._client.start(params[1])
        if params[0] == 'restart':
            self._client.restart(params[1])
        if params[0] == 'stop':
            self._client.stop(params[1])
        if params[0] == 'tail':
            self._tail = params[1]

    @event('dialog/submit')
    def on_submit(self, event, params, vars=None):
        self._tail = None