• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(341)  |  Call(107)  |  Derive(22)  |  Import(212)
Raised when HTTP error occurs, but also acts like non-error return

src/w/o/worldcat-HEAD/examples/holdingsmap/holdingsmap.py   worldcat(Download)
to run: python holdingsmap.py
point your web browser at http://localhost:8080/
"""
from urllib2 import urlopen, HTTPError
try:
    import json as simplejson
except ImportError:

src/m/e/mechanize-HEAD/examples/hack21.py   mechanize(Download)
# but I've left those in for the sake of a direct port.
 
import sys, os, re
from urllib2 import HTTPError
 
import mechanize
assert mechanize.__version__ >= (0, 0, 6, "a")

src/p/y/pyitc-HEAD/mechanize/examples/hack21.py   pyitc(Download)
# but I've left those in for the sake of a direct port.
 
import sys, os, re
from urllib2 import HTTPError
 
import mechanize
assert mechanize.__version__ >= (0, 0, 6, "a")

src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_http.py   keeprunning(Download)
 
import copy, time, tempfile, htmlentitydefs, re, logging, socket, \
       urllib2, urllib, httplib, sgmllib
from urllib2 import URLError, HTTPError, BaseHandler
from cStringIO import StringIO
 
from _request import Request
            new._origin_req = getattr(req, "_origin_req", req)
            return new
        else:
            raise HTTPError(req.get_full_url(), code, msg, headers, fp)
 
    def http_error_302(self, req, fp, code, msg, headers):
        # Some servers (incorrectly) return multiple Location headers
            visited = new.redirect_dict = req.redirect_dict
            if (visited.get(newurl, 0) >= self.max_repeats or
                len(visited) >= self.max_redirections):
                raise HTTPError(req.get_full_url(), code,
                                self.inf_msg + msg, headers, fp)
        else:
            visited = new.redirect_dict = req.redirect_dict = {}
    class RobotExclusionError(urllib2.HTTPError):
        def __init__(self, request, *args):
            apply(urllib2.HTTPError.__init__, (self,)+args)
            self.request = request
 
    class HTTPRobotRulesProcessor(BaseHandler):
        # before redirections, after everything else
            response = fp
        else:
            response = urllib2.HTTPError(
                req.get_full_url(), code, msg, hdrs, fp)
        assert code == response.code
        assert msg == response.msg
        assert hdrs == response.hdrs

src/u/r/urlimport-0.86c-dev/urlimport/urlimport.py   urlimport(Download)
from base64 import encodestring
from urlparse import urlsplit, urlunsplit
from httplib import HTTPSConnection
from urllib2 import HTTPDefaultErrorHandler, HTTPSHandler, HTTPError, \
    HTTPRedirectHandler, build_opener, urlopen, Request
 
 
    def http_error_304(self, req, fp, code, msg, headers):
        response = HTTPError(req.get_full_url(), code, msg, headers, fp)
        response.status = code
        return response
 
# use this to open https urls with client certificates.
# taken from http://www.osmonov.com/2009/04/client-certificates-with-urllib2.html

src/m/e/mechanize-0.2.2/examples/hack21.py   mechanize(Download)
# but I've left those in for the sake of a direct port.
 
import sys, os, re
from urllib2 import HTTPError
 
import mechanize
assert mechanize.__version__ >= (0, 0, 6, "a")

src/c/m/cmislib-0.3/src/cmislib/net.py   cmislib(Download)
'''
 
from urllib import urlencode
from urllib2 import HTTPBasicAuthHandler, \
                    HTTPPasswordMgrWithDefaultRealm, \
                    HTTPRedirectHandler, \
                    HTTPDefaultErrorHandler, \
    def http_error_default(self, req, fp, code, msg, headers):
        """Provide an implementation for the default handler"""
        result = HTTPError(
            req.get_full_url(), code, msg, headers, fp)
        result.status = code
        return result
 

src/w/s/wsat-HEAD/trunk/src/crawling/ClientCookie/_urllib2_support.py   wsat(Download)
    import sgmllib
    # monkeypatch to fix http://www.python.org/sf/803422 :-(
    sgmllib.charref = re.compile("&#(x?[0-9a-fA-F]+)[^0-9a-fA-F]")
    from urllib2 import URLError, HTTPError
    import types, string, socket
    from cStringIO import StringIO
    try:
                               origin_req_host=req.get_origin_req_host(),
                               unverifiable=True)
            else:
                raise HTTPError(req.get_full_url(), code, msg, headers, fp)
 
        def http_error_302(self, req, fp, code, msg, headers):
            # Some servers (incorrectly) return multiple Location headers
                visited = new.redirect_dict = req.redirect_dict
                if (visited.get(newurl, 0) >= self.max_repeats or
                    len(visited) >= self.max_redirections):
                    raise HTTPError(req.get_full_url(), code,
                                    self.inf_msg + msg, headers, fp)
            else:
                visited = new.redirect_dict = req.redirect_dict = {}
        class RobotExclusionError(urllib2.HTTPError):
            def __init__(self, request, *args):
                apply(urllib2.HTTPError.__init__, (self,)+args)
                self.request = request
 
        class HTTPRobotRulesProcessor(BaseHandler):
            # before redirections and response debugging, after everything else

src/w/s/wsat-HEAD/src/crawling/ClientCookie/_urllib2_support.py   wsat(Download)
    import sgmllib
    # monkeypatch to fix http://www.python.org/sf/803422 :-(
    sgmllib.charref = re.compile("&#(x?[0-9a-fA-F]+)[^0-9a-fA-F]")
    from urllib2 import URLError, HTTPError
    import types, string, socket
    from cStringIO import StringIO
    try:
                               origin_req_host=req.get_origin_req_host(),
                               unverifiable=True)
            else:
                raise HTTPError(req.get_full_url(), code, msg, headers, fp)
 
        def http_error_302(self, req, fp, code, msg, headers):
            # Some servers (incorrectly) return multiple Location headers
                visited = new.redirect_dict = req.redirect_dict
                if (visited.get(newurl, 0) >= self.max_repeats or
                    len(visited) >= self.max_redirections):
                    raise HTTPError(req.get_full_url(), code,
                                    self.inf_msg + msg, headers, fp)
            else:
                visited = new.redirect_dict = req.redirect_dict = {}
        class RobotExclusionError(urllib2.HTTPError):
            def __init__(self, request, *args):
                apply(urllib2.HTTPError.__init__, (self,)+args)
                self.request = request
 
        class HTTPRobotRulesProcessor(BaseHandler):
            # before redirections and response debugging, after everything else

src/k/a/kamaelia-HEAD/trunk/Sketches/RJL/bittorrent/BitTorrent/BitTorrent/NatTraversal.py   kamaelia(Download)
from BitTorrent.platform import os_version
from BitTorrent.RawServer_magic import RawServer, Handler
from BitTorrent.BeautifulSupe import BeautifulSupe, Tag
from urllib2 import URLError, HTTPError, Request
 
#bleh
from urllib import urlopen, FancyURLopener, addinfourl
def VerifySOAPResponse(request, response):
    if response.code != 200:
        raise HTTPError(request.get_full_url(),
                        response.code, str(response.msg) + " (unexpected SOAP response code)",
                        response.info(), response)
 
    data = response.read()
    bs = BeautifulSupe(data)
    soap_response = bs.scour("m:", "Response")
    if not soap_response:
        # maybe I should read the SOAP spec.
        soap_response = bs.scour("u:", "Response")
        if not soap_response:
            raise HTTPError(request.get_full_url(),

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next