Exemplo n.º 1
0
	def request(self, query, postdata=None) :
		body = None
		headers = {}
		if postdata is not None :
			content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(postdata)
			headers['Content-Type'] = content_type
		req=urllib2.Request('http://myhost:80/'+query, body, headers)
		return urllib2.urlopen(req)
Exemplo n.º 2
0
 def request(self, query, postdata=None):
     body = None
     headers = {}
     if postdata is not None:
         content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(
             postdata)
         headers['Content-Type'] = content_type
     req = urllib2.Request('http://myhost:80/' + query, body, headers)
     return urllib2.urlopen(req)
Exemplo n.º 3
0
	def remoteCall(self, serviceName, **fields):
		opener = urllib2.build_opener( self.proxy_support )
		urllib2.install_opener(opener)

		try:
			content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(fields)
			headers = {
				'User-Agent': useragent,
				'Content-Type': content_type,
				}
			req=urllib2.Request(
				self.serviceUrl+"/"+serviceName, body, headers)
			result= urllib2.urlopen(req).read()
			return result
		except Exception, msg:
			raise Exception( "ERROR GETTING DATA FROM SERVICE: %s\n%s" % (msg,sys.exc_info()))
Exemplo n.º 4
0
	def callRemotely(self, serviceName, **fields) :
		fields = dict(((k,repr(v)) for k,v in fields.iteritems()))
		content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(fields)
		headers = {
			'Content-Type': content_type,
			'User-Agent': 'python-service-proxy/1.0',
		}
		req=urllib2.Request(
			self.baseUrl+"/"+serviceName, body, headers)
		try :
			result = urllib2.urlopen(req).read()
		except urllib2.HTTPError as e :
			if e.getcode() == 500 :
				message = e.read()
				raise RemoteError(message)
			raise
		return result
Exemplo n.º 5
0
	def remoteCall(self, serviceName, **fields):
		if urlparse.urlparse (self.serviceUrl)[1] in NoProxiesFor:
			proxy_support = urllib2.ProxyHandler( {} )
		else:
			proxy_support = urllib2.ProxyHandler( Proxies )

		opener = urllib2.build_opener( proxy_support )
		urllib2.install_opener(opener)

		try:
			content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(fields)
			headers = { 'User-Agent': useragent, 'Content-Type': content_type }
			req=urllib2.Request(self.serviceUrl+"/"+serviceName, body, headers)
			result= urllib2.urlopen(req).read()
			return result
		except:
			raise "ERROR GETTING DATA FROM SERVICE"
Exemplo n.º 6
0
    def remoteCall(self, serviceName, **fields):
        opener = urllib2.build_opener(self.proxy_support)
        urllib2.install_opener(opener)

        try:
            content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(
                fields)
            headers = {
                'User-Agent': useragent,
                'Content-Type': content_type,
            }
            req = urllib2.Request(self.serviceUrl + "/" + serviceName, body,
                                  headers)
            result = urllib2.urlopen(req).read()
            return result
        except Exception, msg:
            raise Exception("ERROR GETTING DATA FROM SERVICE: %s\n%s" %
                            (msg, sys.exc_info()))
Exemplo n.º 7
0
    def remoteCall(self, serviceName, **fields):
        if urlparse.urlparse(self.serviceUrl)[1] in NoProxiesFor:
            proxy_support = urllib2.ProxyHandler({})
        else:
            proxy_support = urllib2.ProxyHandler(Proxies)

        opener = urllib2.build_opener(proxy_support)
        urllib2.install_opener(opener)

        try:
            content_type, body = HttpFormPost.encode_multipart_formdata_dictionary(
                fields)
            headers = {'User-Agent': useragent, 'Content-Type': content_type}
            req = urllib2.Request(self.serviceUrl + "/" + serviceName, body,
                                  headers)
            result = urllib2.urlopen(req).read()
            return result
        except:
            raise "ERROR GETTING DATA FROM SERVICE"