def _file_is_executable(exe_name):
  """Platform-independent check if file is executable.

  Args:
    exe_name: file name to test.

  Returns:
    bool, True if exe_name is executable.
  """
  if os.path.isfile(exe_name) and os.access(exe_name, os.X_OK):
    if not sys.platform.startswith('win'):
      # This is sufficient for Linux and Mac OS X, but not for Windows.
      return True
    # More information about the PE File Structure and MS-DOS Header can be
    # found here: https://msdn.microsoft.com/en-us/magazine/cc301805.aspx
    # and here: https://msdn.microsoft.com/en-us/library/ms809762.aspx
    # TODO: Get rid of this when a better solution is found.
    try:
      with open(exe_name, 'rb') as f:
        s = f.read(2)
      return s == 'MZ'
    except __HOLE__:
      pass
  return False
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/devappserver2/go_managedvm.py/_file_is_executable