예제 #1
0
 def __init__(self, config):
     self.dbs = config.get('dbsinst')
     self.global_url = config.get('dbs')
     self.phedex_url = config.get('phedex')
     self.params = config.get('dbsparams')
     self.dbslist = dbsinstances()
     self.known_lfns = {}
     self.dbsver = {}
     ckey, cert = get_key_cert()
     handler = HTTPSClientAuthHandler(ckey, cert)
     self.opener  = urllib2.build_opener(handler)
     urllib2.install_opener(self.opener)
예제 #2
0
파일: HttpUtils.py 프로젝트: dmwm/FileMover
def get_data(url, headers={"Accept": "*/*"}):
    "Context Manager to read data from given URL"
    ckey, cert = get_key_cert()
    req = urllib2.Request(url)
    if headers:
        for key, val in headers.items():
            req.add_header(key, val)

    handler = HTTPSClientAuthHandler(ckey, cert)
    opener = urllib2.build_opener(handler)
    urllib2.install_opener(opener)
    data = urllib2.urlopen(req)
    try:
        yield data
    finally:
        data.close()