def auth_admin_url():
 global url, username, password
 logging.debug(((('HTTP basic authentication with username=' + username) + ', password=') + password))
 if (username and password):
  try:
   password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
   password_mgr.add_password(None, url, username, password)
   handler = urllib2.HTTPBasicAuthHandler(password_mgr)
   opener = urllib2.build_opener(handler)
   opener.open(url)
   urllib2.install_opener(opener)
  except urllib2.HTTPError as e1:
   logging.error(((('HTTPError: ' + str(e1.reason)) + ' ') + str(e1.code)))
  except urllib2.URLError as e2:
   logging.error(('URLError: ' + str(e2.reason)))
  except Exception as e3:
   logging.error(('Error: ' + str(e3.message)))

def auth_admin_url ( ) : global url , username , password logging . debug ( ( ( ( 'HTTP basic authentication with username=' + username ) + ', password=' ) + password ) ) if ( username and password ) : try : password_mgr = urllib2 . HTTPPasswordMgrWithDefaultRealm ( ) password_mgr . add_password ( None , url , username , password ) handler = urllib2 . HTTPBasicAuthHandler ( password_mgr ) opener = urllib2 . build_opener ( handler ) opener . open ( url ) urllib2 . install_opener ( opener ) except urllib2 . HTTPError as e1 : logging . error ( ( ( ( 'HTTPError: ' + str ( e1 . reason ) ) + ' ' ) + str ( e1 . code ) ) ) except urllib2 . URLError as e2 : logging . error ( ( 'URLError: ' + str ( e2 . reason ) ) ) except Exception as e3 : logging . error ( ( 'Error: ' + str ( e3 . message ) ) )
returns fetched url .