def _load_credentials_file(credentials_file):
 try:
  credentials_file.seek(0)
  data = json.load(credentials_file)
 except Exception:
  logger.warning('Credentials file could not be loaded, will ignore and overwrite.')
  return {}
 if (data.get('file_version') != 2):
  logger.warning('Credentials file is not version 2, will ignore and overwrite.')
  return {}
 credentials = {}
 for (key, encoded_credential) in iteritems(data.get('credentials', {})):
  try:
   credential_json = base64.b64decode(encoded_credential)
   credential = client.Credentials.new_from_json(credential_json)
   credentials[key] = credential
  except:
   logger.warning('Invalid credential {0} in file, ignoring.'.format(key))
 return credentials

def _load_credentials_file ( credentials_file ) : try : credentials_file . seek ( 0 ) data = json . load ( credentials_file ) except Exception : logger . warning ( 'Credentials file could not be loaded, will ignore and overwrite.' ) return { } if ( data . get ( 'file_version' ) != 2 ) : logger . warning ( 'Credentials file is not version 2, will ignore and overwrite.' ) return { } credentials = { } for ( key , encoded_credential ) in iteritems ( data . get ( 'credentials' , { } ) ) : try : credential_json = base64 . b64decode ( encoded_credential ) credential = client . Credentials . new_from_json ( credential_json ) credentials [ key ] = credential except : logger . warning ( 'Invalid credential {0} in file, ignoring.' . format ( key ) ) return credentials
load credentials from the given file handle .