def get()

in pygenie/adapter/genie_3.py [0:0]


    def get(self, job_id, path=None, if_not_found=None, **kwargs):
        """
        Get information for a job.

        Args:
            job_id (str): The job id.
            path (str, optional): Path to more job information (cluster, requests,
                etc)
            if_not_found (optional): If the job id is to a job that cannot be
                found, if if_not_found is not None will return if_not_found
                instead of raising error.

        Returns:
            json: JSON response data.
        """

        url = self.__url_for_job(job_id)
        if path:
            url = '{}/{}'.format(url, path.lstrip('/'))

        if self.disable_timeout and 'timeout' in kwargs:
            del kwargs['timeout']

        try:
            # make HTTP request, do not retry 404s (retry everything else)
            return self.call(method='get',
                             url=url,
                             auth_handler=self.auth_handler,
                             failure_codes=404,
                             **kwargs) \
                       .json()
        except GenieHTTPError as err:
            if err.response.status_code in {404, 500}:
                msg = "job not found at {}".format(url) \
                    if err.response.status_code == 404 \
                    else 'issues getting job at {}'.format(url)
                if if_not_found is not None:
                    return if_not_found
                raise GenieJobNotFoundError(msg)
            raise