def check_key_path_and_mode(provider, key_path):
 if (not os.path.exists(key_path)):
  log.error("The key file '{0}' used in the '{1}' provider configuration does not exist.\n".format(key_path, provider))
  return False
 key_mode = str(oct(stat.S_IMODE(os.stat(key_path).st_mode)))
 if (key_mode not in ('0400', '0600')):
  log.error("The key file '{0}' used in the '{1}' provider configuration needs to be set to mode 0400 or 0600.\n".format(key_path, provider))
  return False
 return True

def check_key_path_and_mode ( provider , key_path ) : if ( not os . path . exists ( key_path ) ) : log . error ( "The key file '{0}' used in the '{1}' provider configuration does not exist.\n" . format ( key_path , provider ) ) return False key_mode = str ( oct ( stat . S_IMODE ( os . stat ( key_path ) . st_mode ) ) ) if ( key_mode not in ( '0400' , '0600' ) ) : log . error ( "The key file '{0}' used in the '{1}' provider configuration needs to be set to mode 0400 or 0600.\n" . format ( key_path , provider ) ) return False return True
checks that the key_path exists and the key_mode is either 0400 or 0600 .