Exemple #1
0
    def get_workspace(self, environ, start_response, job_id, build_id):
        """ Get workspace archive """
        if validators.validate_job_id(job_id) == None:
            self.log.error("Job_id validation failure, '%s'", job_id)
            return response.send_error(start_response, 400,
                                       constants.ERROR_JOB_INVALID_ID)
        if validators.validate_build_id(build_id) != build_id:
            self.log.error("Build_id validation failure, '%s'", build_id)
            return response.send_error(start_response, 400,
                                       constants.ERROR_BUILD_INVALID_ID)
        if not os.path.isfile(self._build_workspace_file(job_id, build_id)):
            return response.send_error(start_response, 404,
                                       constants.ERROR_BUILD_NOT_FOUND)

        try:
            ifh = open(self._build_workspace_file(job_id, build_id))
        except IOError:
            return response.send_error(start_response, 500,
                                       constants.ERROR_BUILD_READ_FAILED)

        file_len = os.path.getsize(self._build_workspace_file(
            job_id, build_id))

        return response.send_response_file(environ, start_response, 200, ifh,
                                           file_len)
    def get_artifact(self, environ, start_response, job_id, build_id, artifact_id):
        """ Get artifact data """
        if validators.validate_artifact_id(artifact_id) != artifact_id:
            return response.send_error(start_response, 400, constants.ERROR_ARTIFACT_INVALID_ID)
        if not os.path.isfile(self._build_artifact_file(job_id, build_id, artifact_id)):
            return response.send_error(start_response, 404, constants.ERROR_ARTIFACT_NOT_FOUND)
        try:
            ifh = open(self._build_artifact_file(job_id, build_id, artifact_id))
        except IOError:
            return response.send_error(start_response, 400, constants.ERROR_ARTIFACT_READ_FAILED)

        file_len = os.path.getsize(self._build_artifact_file(job_id, build_id, artifact_id))

        return response.send_response_file(environ, start_response, 200, ifh, file_len)
Exemple #3
0
    def get_workspace(self, environ, start_response, job_id, build_id):
        """ Get workspace archive """
        if validators.validate_job_id(job_id) == None:
            self.log.error("Job_id validation failure, '%s'", job_id)
            return response.send_error(start_response, 400, constants.ERROR_JOB_INVALID_ID)
        if validators.validate_build_id(build_id) != build_id:
            self.log.error("Build_id validation failure, '%s'", build_id)
            return response.send_error(start_response, 400, constants.ERROR_BUILD_INVALID_ID)
        if not os.path.isfile(self._build_workspace_file(job_id, build_id)):
            return response.send_error(start_response, 404, constants.ERROR_BUILD_NOT_FOUND)

        try:
            ifh = open(self._build_workspace_file(job_id, build_id))
        except IOError:
            return response.send_error(start_response, 500, constants.ERROR_BUILD_READ_FAILED)

        file_len = os.path.getsize(self._build_workspace_file(job_id, build_id))

        return response.send_response_file(environ, start_response, 200, ifh, file_len)
    def get_artifact(self, environ, start_response, job_id, build_id,
                     artifact_id):
        """ Get artifact data """
        if validators.validate_artifact_id(artifact_id) != artifact_id:
            return response.send_error(start_response, 400,
                                       constants.ERROR_ARTIFACT_INVALID_ID)
        if not os.path.isfile(
                self._build_artifact_file(job_id, build_id, artifact_id)):
            return response.send_error(start_response, 404,
                                       constants.ERROR_ARTIFACT_NOT_FOUND)
        try:
            ifh = open(self._build_artifact_file(job_id, build_id,
                                                 artifact_id))
        except IOError:
            return response.send_error(start_response, 400,
                                       constants.ERROR_ARTIFACT_READ_FAILED)

        file_len = os.path.getsize(
            self._build_artifact_file(job_id, build_id, artifact_id))

        return response.send_response_file(environ, start_response, 200, ifh,
                                           file_len)