def _GetOpener(self):
    """Returns an OpenerDirector that supports cookies and ignores redirects.

    Returns:
      A urllib2.OpenerDirector object.
    """
    opener = urllib2.OpenerDirector()
    opener.add_handler(fancy_urllib.FancyProxyHandler())
    opener.add_handler(urllib2.UnknownHandler())
    opener.add_handler(urllib2.HTTPHandler())
    opener.add_handler(urllib2.HTTPDefaultErrorHandler())
    opener.add_handler(urllib2.HTTPSHandler())
    opener.add_handler(urllib2.HTTPErrorProcessor())

    auth_domain = ''
    if os.environ in 'AUTH_DOMAIN':
      auth_domain = os.environ['AUTH_DOMAIN'].lower()

    if self.save_cookies:
      if auth_domain == 'appscale':
        cookies_dir = os.path.expanduser(HttpRpcServer.APPSCALE_COOKIE_DIR)
        if not os.path.exists(cookies_dir):
          os.mkdir(cookies_dir)
      else:
        self.cookie_jar.filename = os.path.expanduser(
          HttpRpcServer.DEFAULT_COOKIE_FILE_PATH)

        if os.path.exists(self.cookie_jar.filename):
          try:
            self.cookie_jar.load()
            self.authenticated = True
            logger.info("Loaded authentication cookies from %s",
                        self.cookie_jar.filename)
          except (OSError, IOError, cookielib.LoadError), e:
            logger.debug("Could not load authentication cookies; %s: %s",
                         e.__class__.__name__, e)
            self.cookie_jar.filename = None
          else:
            try:
              fd = os.open(self.cookie_jar.filename, os.O_CREAT, 0600)
              os.close(fd)
            except (OSError, IOError), e:
              logger.debug("Could not create authentication cookies file " + \
                           "; %s: %s" % (e.__class__.__name__, e))
              self.cookie_jar.filename = None

    opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))
    return opener
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/appengine_rpc.py/HttpRpcServer._GetOpener/swapped operands of `in`