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)
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)
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()))
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
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"
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()))
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"