コード例 #1
0
    def get_testjob_suites_list_csv(self, job_id):
        """
        Name
        ----
        `get_testjob_suites_list_csv` (`job_id`)

        Description
        -----------
        Get the test suites list from job results of given job id in CSV format.

        Arguments
        ---------
        `job_id`: string
            Job id for which the test suites are required.

        Return value
        ------------
        This function returns an XML-RPC structures of test suites list from
        job results in CSV format, provided the user is authenticated with an
        username and token.
        """

        self._authenticate()
        if not job_id:
            raise xmlrpc.client.Fault(
                400, "Bad request: TestJob id was not specified.")
        try:
            job = TestJob.get_by_job_number(job_id)
            if not job.can_view(self.user):
                raise xmlrpc.client.Fault(
                    401, "Permission denied for user to job %s" % job_id)
            output = io.StringIO()
            writer = csv.DictWriter(
                output,
                quoting=csv.QUOTE_ALL,
                extrasaction="ignore",
                fieldnames=testsuite_export_fields(),
            )
            writer.writeheader()
            for test_suite in job.testsuite_set.all():
                writer.writerow(export_testsuite(test_suite))

        except TestJob.DoesNotExist:
            raise xmlrpc.client.Fault(404, "Specified job not found.")

        return output.getvalue()
コード例 #2
0
ファイル: api.py プロジェクト: Linaro/lava-server
    def get_testjob_suites_list_csv(self, job_id):
        """
        Name
        ----
        `get_testjob_suites_list_csv` (`job_id`)

        Description
        -----------
        Get the test suites list from job results of given job id in CSV format.

        Arguments
        ---------
        `job_id`: string
            Job id for which the test suites are required.

        Return value
        ------------
        This function returns an XML-RPC structures of test suites list from
        job results in CSV format, provided the user is authenticated with an
        username and token.
        """

        self._authenticate()
        if not job_id:
            raise xmlrpclib.Fault(400, "Bad request: TestJob id was not "
                                  "specified.")
        try:
            job = TestJob.get_by_job_number(job_id)
            if not job.can_view(self.user):
                raise xmlrpclib.Fault(
                    401, "Permission denied for user to job %s" % job_id)
            output = io.BytesIO()
            writer = csv.DictWriter(
                output,
                quoting=csv.QUOTE_ALL,
                extrasaction='ignore',
                fieldnames=testsuite_export_fields())
            writer.writeheader()
            for test_suite in job.testsuite_set.all():
                writer.writerow(export_testsuite(test_suite))

        except TestJob.DoesNotExist:
            raise xmlrpclib.Fault(404, "Specified job not found.")

        return output.getvalue()