Ejemplo n.º 1
0
    def rebuild_request(self, branch):
        """
        Rebuild  `request_id`, which must be passed in as a POST parameter.

        `priority` is also accepted as an optional parameter."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            request_id = IntValidator.to_python(request.POST.get('request_id'))
        except:
            return self._failed('Bad request_id', 400)

        try:
            priority = validators.Int(if_empty=0).to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" % (request_id, branch), 404)

        access_log.info("%s rebuild_request %s %s %s", who, branch, request_id, priority)
        retval = g.mq.rebuildRequest(who, request_id, priority)
        # TODO: invalidate cache for branch
        return self._format_mq_response(retval)
Ejemplo n.º 2
0
    def rebuild_request(self, branch):
        """
        Rebuild  `request_id`, which must be passed in as a POST parameter.

        `priority` and `count` are also accepted as optional parameters.
        `count` defaults to 1, and represents the number of times this build
        will be rebuilt."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            request_id = IntValidator.to_python(request.POST.get('request_id'))
        except:
            return self._failed('Bad request_id', 400)

        try:
            priority = validators.Int(if_empty=0).to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        try:
            count = validators.Int(if_empty=1).to_python(request.POST.get('count'))
        except formencode.Invalid:
            return self._failed('Bad count', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" % (request_id, branch), 404)

        access_log.info("%s rebuild_request %s %s %s %s", who, branch, request_id, priority, count)
        retval = g.mq.rebuildRequest(who, request_id, priority, count)
        # TODO: invalidate cache for branch
        return self._format_mq_response(retval)
Ejemplo n.º 3
0
    def request(self, branch, request_id):
        """Return information about a request"""
        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        return self._ok(retval)
Ejemplo n.º 4
0
    def request(self, branch, request_id):
        """Return information about a request"""
        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        return self._ok(retval)
Ejemplo n.º 5
0
    def reprioritize(self, branch, request_id):
        """
        Reprioritize the given request.

        Requires `priority` in the POST parameters.

        Higher priority values get handled first, and the default priority for
        jobs is 0.

        Returns a job status message."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            priority = IntValidator.to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        try:
            request_id = IntValidator.to_python(request_id)
        except ValueError:
            return self._failed('Non-integer request id', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        if retval['complete'] != 0:
            return self._failed("Request already complete", 400)
        elif retval['claimed_at'] != 0:
            return self._failed("Request is already running", 400)
        else:
            access_log.info("%s reprioritize %s %s to %s", who, branch,
                    request_id, priority)
            return self._format_mq_response(g.mq.reprioritizeRequest(who,
                request_id, priority))

        # TODO: invalidate cache for branch
        return self._format(retval)
Ejemplo n.º 6
0
    def reprioritize(self, branch, request_id):
        """
        Reprioritize the given request.

        Requires `priority` in the POST parameters.

        Higher priority values get handled first, and the default priority for
        jobs is 0.

        Returns a job status message."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            priority = IntValidator.to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        try:
            request_id = IntValidator.to_python(request_id)
        except ValueError:
            return self._failed('Non-integer request id', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        if retval['complete'] != 0:
            return self._failed("Request already complete", 400)
        elif retval['claimed_at'] != 0:
            return self._failed("Request is already running", 400)
        else:
            access_log.info("%s reprioritize %s %s to %s", who, branch,
                    request_id, priority)
            return self._format_mq_response(g.mq.reprioritizeRequest(who,
                request_id, priority))

        # TODO: invalidate cache for branch
        return self._format(retval)
Ejemplo n.º 7
0
    def cancel_request(self, branch, request_id):
        """Cancel the given request"""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            request_id = int(request_id)
        except ValueError:
            return self._failed('Non-integer request_id', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        # TODO: invalidate cache for branch
        access_log.info("%s cancel_request %s %s", who, branch, request_id)
        return self._format_mq_response(g.mq.cancelRequest(who, request_id))
Ejemplo n.º 8
0
    def cancel_request(self, branch, request_id):
        """Cancel the given request"""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        try:
            request_id = int(request_id)
        except ValueError:
            return self._failed('Non-integer request_id', 400)

        retval = getRequest(branch, request_id)
        if not retval:
            return self._failed("Request %s not found on branch %s" %
                    (request_id, branch), 404)

        # TODO: invalidate cache for branch
        access_log.info("%s cancel_request %s %s", who, branch, request_id)
        return self._format_mq_response(g.mq.cancelRequest(who, request_id))