def mask_password_from_url(url):
 split = urlparse.urlsplit(url)
 if split.password:
  if (url.count(split.password) == 1):
   url = url.replace(split.password, '********')
  else:
   split = split._replace(netloc=split.netloc.replace(('%s:%s' % (split.username, split.password)), ('%s:********' % split.username)))
   url = urlparse.urlunsplit(split)
 return url

def mask_password_from_url ( url ) : split = urlparse . urlsplit ( url ) if split . password : if ( url . count ( split . password ) == 1 ) : url = url . replace ( split . password , '********' ) else : split = split . _replace ( netloc = split . netloc . replace ( ( '%s:%s' % ( split . username , split . password ) ) , ( '%s:********' % split . username ) ) ) url = urlparse . urlunsplit ( split ) return url
masks out passwords from connection urls like the database connection in galaxy .