示例#1
0
    def delete_instance(self, parts, pid=0, app=None):
        lp = [unquote_plus(p) for p in parts]
        qp = [quote_plus(p) for p in lp]
        _key = app.assigned_ports.make_key(*lp)

        if pid:
            kill_process(pid)
            del app.running_processes[_key]

        os.unlink(os.path.join(self.entpath, *qp))
        # Remove issuer if out of tags
        if not os.listdir(os.path.join(self.entpath, qp[0])):
            os.rmdir(os.path.join(self.entpath, qp[0]))

        del app.assigned_ports[_key]

        resp = Response(mako_template='message.mako',
                        template_lookup=self.lookup,
                        headers=[])

        args = {
            'title':
            "Action performed",
            'base':
            self.baseurl,
            'note':
            'Your test tool instance <em>{} {}</em> has been '
            'removed'.format(*lp)
        }
        return resp(self.environ, self.start_response, **args)
示例#2
0
文件: app_conf.py 项目: rohe/oidctest
    def delete_instance(self, parts, pid=0, app=None):
        lp = [unquote_plus(p) for p in parts]
        qp = [quote_plus(p) for p in lp]
        _key = app.assigned_ports.make_key(*lp)

        if pid:
            kill_process(pid)
            del app.running_processes[_key]

        os.unlink(os.path.join(self.entpath, *qp))
        # Remove issuer if out of tags
        if not os.listdir(os.path.join(self.entpath, qp[0])):
            os.rmdir(os.path.join(self.entpath, qp[0]))

        del app.assigned_ports[_key]

        resp = Response(mako_template='message.mako',
                        template_lookup=self.lookup,
                        headers=[])

        args = {'title': "Action performed", 'base': self.baseurl,
                'note':
                    'Your test tool instance <em>{} {}</em> has been '
                    'removed'.format(*lp)}
        return resp(self.environ, self.start_response, **args)
示例#3
0
    def kill(self, iss, tag, ev):
        uqp, qp = unquote_quote(iss, tag)
        _key = self.app.assigned_ports.make_key(*uqp)

        try:
            pid = isrunning(unquote_plus(iss), unquote_plus(tag))
        except KeyError:
            pass
        else:
            if pid:
                # logger.info('kill {}'.format(pid))
                # subprocess.call(['kill', str(pid)])
                kill_process(pid)
                try:
                    del self.app.running_processes[_key]
                except KeyError:
                    pass
示例#4
0
文件: action.py 项目: rohe/oidctest
    def kill(self, iss, tag, ev):
        uqp, qp = unquote_quote(iss, tag)
        _key = self.app.assigned_ports.make_key(*uqp)

        try:
            pid = isrunning(unquote_plus(iss), unquote_plus(tag))
        except KeyError:
            pass
        else:
            if pid:
                # logger.info('kill {}'.format(pid))
                # subprocess.call(['kill', str(pid)])
                kill_process(pid)
                try:
                    del self.app.running_processes[_key]
                except KeyError:
                    pass
示例#5
0
    def delete(self, iss, tag, ev, pid=0):
        logger.info('delete test tool configuration')
        uqp, qp = unquote_quote(iss, tag)
        _key = self.app.assigned_ports.make_key(*uqp)

        if pid:
            kill_process(pid)
            del self.app.running_processes[_key]

        os.unlink(os.path.join(self.entpath, *qp))
        # Remove issuer if out of tags
        if not os.listdir(os.path.join(self.entpath, qp[0])):
            os.rmdir(os.path.join(self.entpath, qp[0]))

        try:
            del self.app.assigned_ports[_key]
        except KeyError:  # How could it already have gone ? Ah, well
            pass

        # redirect back to entity page
        loc = '{}entity/{}'.format(self.rest.base_url, qp[0])
        raise cherrypy.HTTPRedirect(loc)
示例#6
0
    def stop(self, iss, tag, ev):
        logger.info('stop test tool')

        uqp, qp = unquote_quote(iss, tag)
        _key = self.app.assigned_ports.make_key(*uqp)

        # If already running - kill
        try:
            pid = isrunning(unquote_plus(iss), unquote_plus(tag))
        except KeyError:
            pass
        else:
            if pid:
                #logger.info('kill {}'.format(pid))
                #subprocess.call(['kill', str(pid)])
                kill_process(pid)
                try:
                    del self.app.running_processes[_key]
                except KeyError:
                    pass

        # redirect back to entity page
        loc = '{}entity/{}'.format(self.rest.base_url, qp[0])
        raise cherrypy.HTTPRedirect(loc)