human
Complete this python program:
def GetAdminOpener(host, user=None, pwd=None, otp_entry=None, cookiejar_path=None):
assistant
#Here is the Python code you requested.

    """Returns an OpenerDirector for retrieving administrative URLs.
    Uses stored admin cookies if available, or prompts for authentication
    credentials and authenticates with server otherwise.
    Based on reitveld codereview script.
    """
    opener = urllib2.OpenerDirector()
    opener.add_handler(urllib2.HTTPDefaultErrorHandler())
    opener.add_handler(urllib2.HTTPSHandler())
    opener.add_handler(urllib2.HTTPErrorProcessor())
    opener.add_handler(urllib2.HTTPHandler())
    if (cookiejar_path is None):
        cookiejar_path = expanduser('~/.viewfinder_admin_cookie')
    cookie_jar = cookielib.MozillaCookieJar(cookiejar_path)
    if os.path.exists(cookiejar_path):
        try:
            cookie_jar.load()
            logging.info(('loaded    admin    authentication    cookies    from    %s' % cookiejar_path))
        except:
            os.unlink(cookiejar_path)
    if (not os.path.exists(cookiejar_path)):
        fd = os.open(cookiejar_path, os.O_CREAT, 384)
        os.close(fd)
    os.chmod(cookiejar_path, 384)
    opener.add_handler(urllib2.HTTPCookieProcessor(cookie_jar))
    class TornadoXSRFProcessor(urllib2.BaseHandler, ):
        "Add    tornado's    xsrf    headers    to    outgoing    requests."
        handler_order = (urllib2.HTTPCookieProcessor.handler_order + 1)
        def http_request(self, request):
            cookie_header = request.get_header('Cookie')
            if ((cookie_header is not None) and ('_xsrf=' in cookie_header)):
                request.add_unredirected_header('X-Xsrftoken', re.match('_xsrf=([^;]+)', cookie_header).group(1))
            else:
                request.add_unredirected_header('X-Xsrftoken', 'fake_xsrf')
                if cookie_header:
                    request.add_unredirected_header('Cookie', ('_xsrf="fake_xsrf";    ' + cookie_header))
                else:
                    request.add_unredirected_header('Cookie', '_xsrf="fake_xsrf"')
            return request
        https_request = http_request
    opener.add_handler(TornadoXSRFProcessor())
    if ((len(cookie_jar) == 0) or any([c.is_expired() for c in cookie_jar if (c.domain == host)])):
        if ((user is None) or (pwd is None) or (otp_entry is None)):
            (user, pwd, otp_entry) = _PromptForAdminCookie(user, pwd,...