def get_filtered_list(filter_id=constants.errata_default_filter, limit=5): """return a list of Advisory() objects from results using the provided filter_id :param filter_id: The ID number of the pre-defined filter :param int limit: How many erratum to list :return: A list of Advisory objects :raises exceptions.ErrataToolUnauthenticatedException: If the user is not authenticated to make the request :raises exceptions.ErrataToolError: If the given filter does not exist, and, any other unexpected error Note: Errata filters are defined in the ET web interface """ filter_endpoint = constants.errata_filter_list_url.format(id=filter_id) res = requests.get(filter_endpoint, verify=ssl.get_default_verify_paths().openssl_cafile, auth=HTTPKerberosAuth()) if res.status_code == 200: # When asked for an advisory list which does not exist # normally you would expect a code like '404' (not # found). However, the Errata Tool sadistically returns a 200 # response code. That leaves us with one option: Decide that # successfully parsing the response as a JSONinfo object indicates # a successful API call. try: return [Advisory(errata_id=advs['id']) for advs in res.json()][:limit] except Exception: raise exceptions.ErrataToolError( "Could not locate the given advisory filter: {fid}".format( fid=filter_id)) elif res.status_code == 401: raise exceptions.ErrataToolUnauthenticatedException(res.text) else: raise exceptions.ErrataToolError( "Other error (status_code={code}): {msg}".format( code=res.status_code, msg=res.text))
def build_signed(build): """return boolean: is the build signed or not :param string build: The build nvr or id """ filter_endpoint = constants.errata_get_build_url.format(id=build) res = requests.get(filter_endpoint, verify=ssl.get_default_verify_paths().openssl_cafile, auth=HTTPKerberosAuth()) if res.status_code == 200: return res.json()['rpms_signed'] elif res.status_code == 401: raise exceptions.ErrataToolUnauthenticatedException(res.text) else: raise exceptions.ErrataToolError( "Other error (status_code={code}): {msg}".format( code=res.status_code, msg=res.text))