@ -62,7 +62,6 @@ EXAMPLES = '''
'''
'''
import re
import re
import os . path
import os . path
import urllib2
import tempfile
import tempfile
def is_pubkey ( string ) :
def is_pubkey ( string ) :
@ -115,8 +114,10 @@ class RpmKey:
def fetch_key ( self , url ) :
def fetch_key ( self , url ) :
""" Downloads a key from url, returns a valid path to a gpg key """
""" Downloads a key from url, returns a valid path to a gpg key """
try :
rsp , info = fetch_url ( self . module , url )
rsp , info = fetch_url ( self . module , url )
if info [ ' status ' ] != 200 :
self . module . fail_json ( msg = " failed to fetch key at %s , error was: %s " % ( url , info [ ' msg ' ] ) )
key = rsp . read ( )
key = rsp . read ( )
if not is_pubkey ( key ) :
if not is_pubkey ( key ) :
self . module . fail_json ( msg = " Not a public key: %s " % url )
self . module . fail_json ( msg = " Not a public key: %s " % url )
@ -125,8 +126,6 @@ class RpmKey:
tmpfile . write ( key )
tmpfile . write ( key )
tmpfile . close ( )
tmpfile . close ( )
return tmpname
return tmpname
except urllib2 . URLError , e :
self . module . fail_json ( msg = str ( e ) )
def normalize_keyid ( self , keyid ) :
def normalize_keyid ( self , keyid ) :
""" Ensure a keyid doesn ' t have a leading 0x, has leading or trailing whitespace, and make sure is lowercase """
""" Ensure a keyid doesn ' t have a leading 0x, has leading or trailing whitespace, and make sure is lowercase """