예제 #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)