| @@ -18,9 +18,9 @@ def usage (error = None): | |||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| if error != None: | if error != None: | ||||
| print error | |||||
| print(error) | |||||
| print """usage: %s [options] [server ...] | |||||
| print("""usage: %s [options] [server ...] | |||||
| If a long option shows an argument is mandatory, it's mandatory for the | If a long option shows an argument is mandatory, it's mandatory for the | ||||
| equivalent short option also. | equivalent short option also. | ||||
| @@ -38,7 +38,7 @@ def usage (error = None): | |||||
| -t, --stacktrace print a stack trace on each unexpected failure | -t, --stacktrace print a stack trace on each unexpected failure | ||||
| -T, --always-stacktrace | -T, --always-stacktrace | ||||
| print a stack trace on any failure | print a stack trace on any failure | ||||
| """ % (sys.argv[0], DEFAULT_SERVERS_FILE), | |||||
| """ % (sys.argv[0], DEFAULT_SERVERS_FILE), end=' ') | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -46,18 +46,18 @@ def usage (error = None): | |||||
| def methodUsage (): | def methodUsage (): | ||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| print "Methods are specified by number. Multiple methods can be " \ | |||||
| print("Methods are specified by number. Multiple methods can be " \ | |||||
| "specified using a\ncomma-separated list of numbers or ranges. " \ | "specified using a\ncomma-separated list of numbers or ranges. " \ | ||||
| "For example 1,4-6,8 specifies\nmethods 1, 4, 5, 6, and 8.\n" | |||||
| "For example 1,4-6,8 specifies\nmethods 1, 4, 5, 6, and 8.\n") | |||||
| print "The available methods are:\n" | |||||
| print("The available methods are:\n") | |||||
| half = (len (DEFAULT_METHODS) + 1) / 2 | half = (len (DEFAULT_METHODS) + 1) / 2 | ||||
| for i in range (half): | for i in range (half): | ||||
| print "%4d. %-25s" % (i + 1, DEFAULT_METHODS[i]), | |||||
| print("%4d. %-25s" % (i + 1, DEFAULT_METHODS[i]), end=' ') | |||||
| if i + half < len (DEFAULT_METHODS): | if i + half < len (DEFAULT_METHODS): | ||||
| print "%4d. %-25s" % (i + 1 + half, DEFAULT_METHODS[i + half]), | |||||
| print("%4d. %-25s" % (i + 1 + half, DEFAULT_METHODS[i + half]), end=' ') | |||||
| print() | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -121,7 +121,7 @@ def str2list (s): | |||||
| else: | else: | ||||
| l[int (i)] = 1 | l[int (i)] = 1 | ||||
| l = l.keys () | |||||
| l = list(l.keys ()) | |||||
| l.sort () | l.sort () | ||||
| return l | return l | ||||
| @@ -144,7 +144,7 @@ def Buy(serv, sa, epname): | |||||
| shipTo_d = {"name":"Buyer One ", "address":"1 1st Street ", | shipTo_d = {"name":"Buyer One ", "address":"1 1st Street ", | ||||
| "city":"New York ", "state":"NY ", "zipCode":"10000 "} | "city":"New York ", "state":"NY ", "zipCode":"10000 "} | ||||
| for k,v in shipTo_d.items(): | |||||
| for k,v in list(shipTo_d.items()): | |||||
| shipTo_d[k] = v[:-1] | shipTo_d[k] = v[:-1] | ||||
| itemd1 = SOAP.structType( {"name":"widg1","quantity":200,"price":SOAP.decimalType(45.99), "_typename":"LineItem"}) | itemd1 = SOAP.structType( {"name":"widg1","quantity":200,"price":SOAP.decimalType(45.99), "_typename":"LineItem"}) | ||||
| @@ -200,8 +200,7 @@ def main(): | |||||
| elif opt in ('-s', '--servers'): | elif opt in ('-s', '--servers'): | ||||
| servers = arg | servers = arg | ||||
| else: | else: | ||||
| raise AttributeError, \ | |||||
| "Recognized but unimplemented option `%s'" % opt | |||||
| raise AttributeError("Recognized but unimplemented option `%s'" % opt) | |||||
| except SystemExit: | except SystemExit: | ||||
| raise | raise | ||||
| except: | except: | ||||
| @@ -213,7 +212,7 @@ def main(): | |||||
| servers = readServers(servers) | servers = readServers(servers) | ||||
| if methodnums == None: | if methodnums == None: | ||||
| methodnums = range (1, len (DEFAULT_METHODS) + 1) | |||||
| methodnums = list(range(1, len (DEFAULT_METHODS) + 1)) | |||||
| limitre = re.compile ('|'.join (args), re.IGNORECASE) | limitre = re.compile ('|'.join (args), re.IGNORECASE) | ||||
| @@ -239,48 +238,48 @@ def main(): | |||||
| raise | raise | ||||
| except: | except: | ||||
| if 'n' in output: | if 'n' in output: | ||||
| print title, "test not yet implemented" | |||||
| print(title, "test not yet implemented") | |||||
| notimp += 1 | notimp += 1 | ||||
| continue | continue | ||||
| try: | try: | ||||
| res = fn (serv, s['soapaction'], s['name']) | res = fn (serv, s['soapaction'], s['name']) | ||||
| if s['nonfunctional'].has_key (name): | |||||
| print title, "succeeded despite marked nonfunctional" | |||||
| if name in s['nonfunctional']: | |||||
| print(title, "succeeded despite marked nonfunctional") | |||||
| elif 's' in output: | elif 's' in output: | ||||
| print title, "succeeded " | |||||
| print(title, "succeeded ") | |||||
| succeed += 1 | succeed += 1 | ||||
| except KeyboardInterrupt: | except KeyboardInterrupt: | ||||
| print "fail" | |||||
| print("fail") | |||||
| raise | raise | ||||
| except: | except: | ||||
| if s['nonfunctional'].has_key (name): | |||||
| if name in s['nonfunctional']: | |||||
| if 'F' in output: | if 'F' in output: | ||||
| t = 'as expected' | t = 'as expected' | ||||
| if s['nonfunctional'][name] != '': | if s['nonfunctional'][name] != '': | ||||
| t += ', ' + s['nonfunctional'][name] | t += ', ' + s['nonfunctional'][name] | ||||
| print title, "failed (%s) -" %t, sys.exc_info()[1] | |||||
| print(title, "failed (%s) -" %t, sys.exc_info()[1]) | |||||
| failok += 1 | failok += 1 | ||||
| else: | else: | ||||
| if 'f' in output: | if 'f' in output: | ||||
| print title, "failed -", str (sys.exc_info()[1]) | |||||
| print(title, "failed -", str (sys.exc_info()[1])) | |||||
| fail += 1 | fail += 1 | ||||
| if stats: | if stats: | ||||
| print " Tests ended at:", time.ctime (time.time()) | |||||
| print(" Tests ended at:", time.ctime (time.time())) | |||||
| if stats > 0: | if stats > 0: | ||||
| print " Total tests: %d" % total | |||||
| print " Successes: %d (%3.2f%%)" % \ | |||||
| (succeed, 100.0 * succeed / total) | |||||
| print(" Total tests: %d" % total) | |||||
| print(" Successes: %d (%3.2f%%)" % \ | |||||
| (succeed, 100.0 * succeed / total)) | |||||
| if stats > 0 or fail > 0: | if stats > 0 or fail > 0: | ||||
| print "Failed unexpectedly: %d (%3.2f%%)" % \ | |||||
| (fail, 100.0 * fail / total) | |||||
| print("Failed unexpectedly: %d (%3.2f%%)" % \ | |||||
| (fail, 100.0 * fail / total)) | |||||
| if stats > 0: | if stats > 0: | ||||
| print " Failed as expected: %d (%3.2f%%)" % \ | |||||
| (failok, 100.0 * failok / total) | |||||
| print(" Failed as expected: %d (%3.2f%%)" % \ | |||||
| (failok, 100.0 * failok / total)) | |||||
| if stats > 0 or notimp > 0: | if stats > 0 or notimp > 0: | ||||
| print " Not implemented: %d (%3.2f%%)" % \ | |||||
| (notimp, 100.0 * notimp / total) | |||||
| print(" Not implemented: %d (%3.2f%%)" % \ | |||||
| (notimp, 100.0 * notimp / total)) | |||||
| return fail + notimp | return fail + notimp | ||||
| @@ -15,7 +15,7 @@ def SimpleBuy(Address, ProductName, Quantity): | |||||
| # the strings are of len > 0 | # the strings are of len > 0 | ||||
| global NUMSIMPLEBUYS | global NUMSIMPLEBUYS | ||||
| NUMSIMPLEBUYS += 1 | NUMSIMPLEBUYS += 1 | ||||
| if Quantity < 1: raise ValueError, "must order at least one" | |||||
| if Quantity < 1: raise ValueError("must order at least one") | |||||
| else: return "Receipt for %d %s(s) bought from %s" % (int(Quantity), ProductName, serverstring) | else: return "Receipt for %d %s(s) bought from %s" % (int(Quantity), ProductName, serverstring) | ||||
| @@ -23,7 +23,7 @@ def RequestForQuote(ProductName, Quantity): | |||||
| # type-checks and makes sure Quantity >= 1 | # type-checks and makes sure Quantity >= 1 | ||||
| global NUMREQUESTS | global NUMREQUESTS | ||||
| NUMREQUESTS += 1 | NUMREQUESTS += 1 | ||||
| if Quantity < 1: raise ValueError, "must order at least 1" | |||||
| if Quantity < 1: raise ValueError("must order at least 1") | |||||
| else: | else: | ||||
| import whrandom | import whrandom | ||||
| mult = whrandom.random() | mult = whrandom.random() | ||||
| @@ -33,7 +33,7 @@ def RequestForQuote(ProductName, Quantity): | |||||
| times += 1 | times += 1 | ||||
| mult += 0.5 | mult += 0.5 | ||||
| mult = round(mult, 3) | mult = round(mult, 3) | ||||
| print mult, times | |||||
| print(mult, times) | |||||
| return SOAP.doubleType(round(mult*int(Quantity),2)) | return SOAP.doubleType(round(mult*int(Quantity),2)) | ||||
| @@ -51,9 +51,9 @@ def Buy(**kw): | |||||
| POkeys_expected = ["shipTo","billTo","items","poID","createDate"] | POkeys_expected = ["shipTo","billTo","items","poID","createDate"] | ||||
| POkeys_expected.sort() | POkeys_expected.sort() | ||||
| if POkeys != POkeys_expected: | if POkeys != POkeys_expected: | ||||
| raise ValueError, "struct 'PurchaseOrder' needs %s, %s, %s, %s, and %s" % tuple(POkeys_expected) | |||||
| raise ValueError("struct 'PurchaseOrder' needs %s, %s, %s, %s, and %s" % tuple(POkeys_expected)) | |||||
| except: | except: | ||||
| raise TypeError, "'PurchaseOrder' missing one or more element(s)" | |||||
| raise TypeError("'PurchaseOrder' missing one or more element(s)") | |||||
| try: | try: | ||||
| btkeys = PurchaseOrder["billTo"]["_keyord"] | btkeys = PurchaseOrder["billTo"]["_keyord"] | ||||
| @@ -61,7 +61,7 @@ def Buy(**kw): | |||||
| btkeys_expected = ["address","zipCode","name","state","city"] | btkeys_expected = ["address","zipCode","name","state","city"] | ||||
| btkeys_expected.sort() | btkeys_expected.sort() | ||||
| except: | except: | ||||
| raise TypeError, "'billTo' missing one or more elements" | |||||
| raise TypeError("'billTo' missing one or more elements") | |||||
| try: | try: | ||||
| stkeys = PurchaseOrder["shipTo"]["_keyord"] | stkeys = PurchaseOrder["shipTo"]["_keyord"] | ||||
| @@ -69,7 +69,7 @@ def Buy(**kw): | |||||
| stkeys_expected = ["address","zipCode","name","state","city"] | stkeys_expected = ["address","zipCode","name","state","city"] | ||||
| stkeys_expected.sort() | stkeys_expected.sort() | ||||
| except: | except: | ||||
| raise TypeError, "'shipTo' missing one or more elements" | |||||
| raise TypeError("'shipTo' missing one or more elements") | |||||
| try: | try: | ||||
| @@ -90,7 +90,7 @@ def Buy(**kw): | |||||
| return retstring | return retstring | ||||
| except: | except: | ||||
| raise TypeError, "items must be an array of 'item' structs" | |||||
| raise TypeError("items must be an array of 'item' structs") | |||||
| def Ping(): | def Ping(): | ||||
| global NUMPINGS | global NUMPINGS | ||||
| @@ -106,7 +106,7 @@ def Monitor(str): | |||||
| return "(Buys, RequestForQuote(s),SimpleBuy(s), Ping(s)) = " + \ | return "(Buys, RequestForQuote(s),SimpleBuy(s), Ping(s)) = " + \ | ||||
| repr( (NUMBUYS,NUMREQUESTS,NUMSIMPLEBUYS, NUMPINGS) ) | repr( (NUMBUYS,NUMREQUESTS,NUMSIMPLEBUYS, NUMPINGS) ) | ||||
| else: | else: | ||||
| raise ValueError, "not the right string" | |||||
| raise ValueError("not the right string") | |||||
| def Clear(str): | def Clear(str): | ||||
| if str=="actzero": | if str=="actzero": | ||||
| @@ -121,16 +121,16 @@ def Clear(str): | |||||
| return "(Buys, RequestForQuote(s),SimpleBuy(s), Ping(s)) = " + \ | return "(Buys, RequestForQuote(s),SimpleBuy(s), Ping(s)) = " + \ | ||||
| repr( (NUMBUYS,NUMREQUESTS,NUMSIMPLEBUYS, NUMPINGS) ) | repr( (NUMBUYS,NUMREQUESTS,NUMSIMPLEBUYS, NUMPINGS) ) | ||||
| else: | else: | ||||
| raise ValueError, "not the right string" | |||||
| raise ValueError("not the right string") | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| if len(sys.argv) > 1: | if len(sys.argv) > 1: | ||||
| try: | try: | ||||
| port = int(sys.argv[1]) | port = int(sys.argv[1]) | ||||
| if port not in range(2000,15000): raise ValueError | |||||
| if port not in list(range(2000,15000)): raise ValueError | |||||
| except: | except: | ||||
| print "port must be a number between 2000 and 15000" | |||||
| print("port must be a number between 2000 and 15000") | |||||
| sys.exit(1) | sys.exit(1) | ||||
| else: port = 9000 | else: port = 9000 | ||||
| namespace = "http://www.soapinterop.org/Bid" | namespace = "http://www.soapinterop.org/Bid" | ||||
| @@ -4,15 +4,15 @@ import getopt | |||||
| def usage(): | def usage(): | ||||
| print """usage: %s [options] | |||||
| print("""usage: %s [options] | |||||
| -m, --method=METHOD#[,METHOD#...] specify METHOD# of ? for the list | -m, --method=METHOD#[,METHOD#...] specify METHOD# of ? for the list | ||||
| -p, --port=PORT# allows to specify PORT# of server | -p, --port=PORT# allows to specify PORT# of server | ||||
| """ | |||||
| """) | |||||
| sys.exit(1) | sys.exit(1) | ||||
| def methodUsage(): | def methodUsage(): | ||||
| print "The available methods are:" | |||||
| print "1. Monitor \t\t2. Clear" | |||||
| print("The available methods are:") | |||||
| print("1. Monitor \t\t2. Clear") | |||||
| sys.exit(0) | sys.exit(0) | ||||
| @@ -29,7 +29,7 @@ try: | |||||
| elif opt in ('-p', '--port'): | elif opt in ('-p', '--port'): | ||||
| port = int(arg) | port = int(arg) | ||||
| else: | else: | ||||
| raise AttributeError, "Recognized but unimpl option '%s'" % opt | |||||
| raise AttributeError("Recognized but unimpl option '%s'" % opt) | |||||
| except SystemExit: | except SystemExit: | ||||
| raise | raise | ||||
| except: | except: | ||||
| @@ -41,10 +41,10 @@ ns = "http://www.soapinterop.org/Bid" | |||||
| serv = SOAP.SOAPProxy(ep, namespace =ns, soapaction = sa) | serv = SOAP.SOAPProxy(ep, namespace =ns, soapaction = sa) | ||||
| if methodnum == 1: | if methodnum == 1: | ||||
| print serv.Monitor(str="actzero") | |||||
| print(serv.Monitor(str="actzero")) | |||||
| elif methodnum == 2: | elif methodnum == 2: | ||||
| print serv.Clear(str="actzero") | |||||
| print(serv.Clear(str="actzero")) | |||||
| else: | else: | ||||
| print "invalid methodnum" | |||||
| print("invalid methodnum") | |||||
| methodUsage() | methodUsage() | ||||
| @@ -8,12 +8,12 @@ srv = SOAP.SOAPProxy('http://localhost:10080/') | |||||
| for p in ('good param', 'ok param'): | for p in ('good param', 'ok param'): | ||||
| ret = srv.badparam(p) | ret = srv.badparam(p) | ||||
| if isinstance(ret, SOAP.faultType): | if isinstance(ret, SOAP.faultType): | ||||
| print ret | |||||
| print(ret) | |||||
| else: | else: | ||||
| print 'ok' | |||||
| print('ok') | |||||
| dt = SOAP.dateTimeType(time.localtime(time.time())) | dt = SOAP.dateTimeType(time.localtime(time.time())) | ||||
| print srv.dt(dt) | |||||
| print(srv.dt(dt)) | |||||
| @@ -27,7 +27,7 @@ class soap_handler: | |||||
| def continue_request(self, data, request): | def continue_request(self, data, request): | ||||
| # Everthing that follows is cripped from do_POST(). | # Everthing that follows is cripped from do_POST(). | ||||
| if self.config.debug: | if self.config.debug: | ||||
| print "\n***RECEIVING***\n", data, "*" * 13 + "\n" | |||||
| print("\n***RECEIVING***\n", data, "*" * 13 + "\n") | |||||
| sys.stdout.flush() | sys.stdout.flush() | ||||
| try: | try: | ||||
| @@ -47,8 +47,8 @@ class soap_handler: | |||||
| try: | try: | ||||
| # First look for registered functions | # First look for registered functions | ||||
| if self.funcmap.has_key(ns) and \ | |||||
| self.funcmap[ns].has_key(method): | |||||
| if ns in self.funcmap and \ | |||||
| method in self.funcmap[ns]: | |||||
| f = self.funcmap[ns][method] | f = self.funcmap[ns][method] | ||||
| else: # Now look at registered objects | else: # Now look at registered objects | ||||
| # Check for nested attributes | # Check for nested attributes | ||||
| @@ -86,18 +86,18 @@ class soap_handler: | |||||
| if f.keywords: | if f.keywords: | ||||
| tkw = {} | tkw = {} | ||||
| # This is lame, but have to de-unicode keywords | # This is lame, but have to de-unicode keywords | ||||
| for (k,v) in kw.items(): | |||||
| for (k,v) in list(kw.items()): | |||||
| tkw[str(k)] = v | tkw[str(k)] = v | ||||
| if c: | if c: | ||||
| tkw["_SOAPContext"] = c | tkw["_SOAPContext"] = c | ||||
| fr = apply(f,(),tkw) | |||||
| fr = f(*(), **tkw) | |||||
| else: | else: | ||||
| if c: | if c: | ||||
| fr = apply(f,args,{'_SOAPContext':c}) | |||||
| fr = f(*args, **{'_SOAPContext':c}) | |||||
| else: | else: | ||||
| fr = apply(f,args,{}) | |||||
| fr = f(*args, **{}) | |||||
| else: | else: | ||||
| fr = apply(f,args,{}) | |||||
| fr = f(*args, **{}) | |||||
| if type(fr) == type(self) and isinstance(fr, voidType): | if type(fr) == type(self) and isinstance(fr, voidType): | ||||
| resp = buildSOAP(kw = {'%sResponse' % method:fr}, | resp = buildSOAP(kw = {'%sResponse' % method:fr}, | ||||
| encoding = self.encoding, | encoding = self.encoding, | ||||
| @@ -107,7 +107,7 @@ class soap_handler: | |||||
| {'%sResponse' % method:{'Result':fr}}, | {'%sResponse' % method:{'Result':fr}}, | ||||
| encoding = self.encoding, | encoding = self.encoding, | ||||
| config = self.config) | config = self.config) | ||||
| except Fault, e: | |||||
| except Fault as e: | |||||
| resp = buildSOAP(e, config = self.config) | resp = buildSOAP(e, config = self.config) | ||||
| status = 500 | status = 500 | ||||
| except: | except: | ||||
| @@ -123,7 +123,7 @@ class soap_handler: | |||||
| status = 500 | status = 500 | ||||
| else: | else: | ||||
| status = 200 | status = 200 | ||||
| except Fault,e: | |||||
| except Fault as e: | |||||
| resp = buildSOAP(e, encoding = self.encoding, | resp = buildSOAP(e, encoding = self.encoding, | ||||
| config = self.config) | config = self.config) | ||||
| status = 500 | status = 500 | ||||
| @@ -147,7 +147,7 @@ class soap_handler: | |||||
| #self.end_headers() | #self.end_headers() | ||||
| if self.config.debug: | if self.config.debug: | ||||
| print "\n***SENDING***\n", resp, "*" * 13 + "\n" | |||||
| print("\n***SENDING***\n", resp, "*" * 13 + "\n") | |||||
| sys.stdout.flush() | sys.stdout.flush() | ||||
| """ | """ | ||||
| @@ -171,7 +171,7 @@ class soap_handler: | |||||
| def registerFunction(self, function, namespace = '', funcName = None): | def registerFunction(self, function, namespace = '', funcName = None): | ||||
| if not funcName : funcName = function.__name__ | if not funcName : funcName = function.__name__ | ||||
| if namespace == '': namespace = self.namespace | if namespace == '': namespace = self.namespace | ||||
| if self.funcmap.has_key(namespace): | |||||
| if namespace in self.funcmap: | |||||
| self.funcmap[namespace][funcName] = function | self.funcmap[namespace][funcName] = function | ||||
| else: | else: | ||||
| self.funcmap[namespace] = {funcName : function} | self.funcmap[namespace] = {funcName : function} | ||||
| @@ -40,28 +40,29 @@ | |||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: Client.py 1496 2010-03-04 23:46:17Z pooryorick $' | ident = '$Id: Client.py 1496 2010-03-04 23:46:17Z pooryorick $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| #import xml.sax | #import xml.sax | ||||
| import urllib | |||||
| from types import * | |||||
| import urllib.request, urllib.parse, urllib.error | |||||
| from .types import * | |||||
| import re | import re | ||||
| import base64 | import base64 | ||||
| import socket, httplib | |||||
| from httplib import HTTPConnection, HTTP | |||||
| import Cookie | |||||
| import socket, http.client | |||||
| from http.client import HTTPConnection, HTTP | |||||
| import http.cookies | |||||
| # SOAPpy modules | # SOAPpy modules | ||||
| from Errors import * | |||||
| from Config import Config | |||||
| from Parser import parseSOAPRPC | |||||
| from SOAPBuilder import buildSOAP | |||||
| from Utilities import * | |||||
| from Types import faultType, simplify | |||||
| from .Errors import * | |||||
| from .Config import Config | |||||
| from .Parser import parseSOAPRPC | |||||
| from .SOAPBuilder import buildSOAP | |||||
| from .Utilities import * | |||||
| from .Types import faultType, simplify | |||||
| import collections | |||||
| ################################################################################ | ################################################################################ | ||||
| # Client | # Client | ||||
| @@ -74,7 +75,7 @@ def SOAPUserAgent(): | |||||
| class SOAPAddress: | class SOAPAddress: | ||||
| def __init__(self, url, config = Config): | def __init__(self, url, config = Config): | ||||
| proto, uri = urllib.splittype(url) | |||||
| proto, uri = urllib.parse.splittype(url) | |||||
| # apply some defaults | # apply some defaults | ||||
| if uri[0:2] != '//': | if uri[0:2] != '//': | ||||
| @@ -84,7 +85,7 @@ class SOAPAddress: | |||||
| uri = '//' + uri | uri = '//' + uri | ||||
| proto = 'http' | proto = 'http' | ||||
| host, path = urllib.splithost(uri) | |||||
| host, path = urllib.parse.splithost(uri) | |||||
| try: | try: | ||||
| int(host) | int(host) | ||||
| @@ -96,15 +97,13 @@ class SOAPAddress: | |||||
| path = '/' | path = '/' | ||||
| if proto not in ('http', 'https', 'httpg'): | if proto not in ('http', 'https', 'httpg'): | ||||
| raise IOError, "unsupported SOAP protocol" | |||||
| raise IOError("unsupported SOAP protocol") | |||||
| if proto == 'httpg' and not config.GSIclient: | if proto == 'httpg' and not config.GSIclient: | ||||
| raise AttributeError, \ | |||||
| "GSI client not supported by this Python installation" | |||||
| raise AttributeError("GSI client not supported by this Python installation") | |||||
| if proto == 'https' and not config.SSLclient: | if proto == 'https' and not config.SSLclient: | ||||
| raise AttributeError, \ | |||||
| "SSL client not supported by this Python installation" | |||||
| raise AttributeError("SSL client not supported by this Python installation") | |||||
| self.user,host = urllib.splituser(host) | |||||
| self.user,host = urllib.parse.splituser(host) | |||||
| self.proto = proto | self.proto = proto | ||||
| self.host = host | self.host = host | ||||
| self.path = path | self.path = path | ||||
| @@ -154,7 +153,7 @@ class HTTPTransport: | |||||
| def __init__(self): | def __init__(self): | ||||
| self.cookies = Cookie.SimpleCookie(); | |||||
| self.cookies = http.cookies.SimpleCookie(); | |||||
| def getNS(self, original_namespace, data): | def getNS(self, original_namespace, data): | ||||
| """Extract the (possibly extended) namespace from the returned | """Extract the (possibly extended) namespace from the returned | ||||
| @@ -173,7 +172,7 @@ class HTTPTransport: | |||||
| def __addcookies(self, r): | def __addcookies(self, r): | ||||
| '''Add cookies from self.cookies to request r | '''Add cookies from self.cookies to request r | ||||
| ''' | ''' | ||||
| for cname, morsel in self.cookies.items(): | |||||
| for cname, morsel in list(self.cookies.items()): | |||||
| attrs = [] | attrs = [] | ||||
| value = morsel.get('version', '') | value = morsel.get('version', '') | ||||
| if value != '' and value != '0': | if value != '' and value != '0': | ||||
| @@ -205,7 +204,7 @@ class HTTPTransport: | |||||
| from pyGlobus.io import GSIHTTP | from pyGlobus.io import GSIHTTP | ||||
| r = GSIHTTP(real_addr, tcpAttr = config.tcpAttr) | r = GSIHTTP(real_addr, tcpAttr = config.tcpAttr) | ||||
| elif addr.proto == 'https': | elif addr.proto == 'https': | ||||
| r = httplib.HTTPS(real_addr, key_file=config.SSL.key_file, cert_file=config.SSL.cert_file) | |||||
| r = http.client.HTTPS(real_addr, key_file=config.SSL.key_file, cert_file=config.SSL.cert_file) | |||||
| else: | else: | ||||
| r = HTTPWithTimeout(real_addr, timeout=timeout) | r = HTTPWithTimeout(real_addr, timeout=timeout) | ||||
| @@ -223,7 +222,7 @@ class HTTPTransport: | |||||
| # if user is not a user:passwd format | # if user is not a user:passwd format | ||||
| # we'll receive a failure from the server. . .I guess (??) | # we'll receive a failure from the server. . .I guess (??) | ||||
| if addr.user != None: | if addr.user != None: | ||||
| val = base64.encodestring(urllib.unquote_plus(addr.user)) | |||||
| val = base64.encodestring(urllib.parse.unquote_plus(addr.user)) | |||||
| r.putheader('Authorization','Basic ' + val.replace('\012','')) | r.putheader('Authorization','Basic ' + val.replace('\012','')) | ||||
| # This fixes sending either "" or "None" | # This fixes sending either "" or "None" | ||||
| @@ -235,12 +234,12 @@ class HTTPTransport: | |||||
| if config.dumpHeadersOut: | if config.dumpHeadersOut: | ||||
| s = 'Outgoing HTTP headers' | s = 'Outgoing HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print "POST %s %s" % (real_path, r._http_vsn_str) | |||||
| print "Host:", addr.host | |||||
| print "User-agent: SOAPpy " + __version__ + " (http://pywebsvcs.sf.net)" | |||||
| print "Content-type:", t | |||||
| print "Content-length:", len(data) | |||||
| print 'SOAPAction: "%s"' % soapaction | |||||
| print("POST %s %s" % (real_path, r._http_vsn_str)) | |||||
| print("Host:", addr.host) | |||||
| print("User-agent: SOAPpy " + __version__ + " (http://pywebsvcs.sf.net)") | |||||
| print("Content-type:", t) | |||||
| print("Content-length:", len(data)) | |||||
| print('SOAPAction: "%s"' % soapaction) | |||||
| debugFooter(s) | debugFooter(s) | ||||
| r.endheaders() | r.endheaders() | ||||
| @@ -248,9 +247,9 @@ class HTTPTransport: | |||||
| if config.dumpSOAPOut: | if config.dumpSOAPOut: | ||||
| s = 'Outgoing SOAP' | s = 'Outgoing SOAP' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print data, | |||||
| print(data, end=' ') | |||||
| if data[-1] != '\n': | if data[-1] != '\n': | ||||
| print() | |||||
| debugFooter(s) | debugFooter(s) | ||||
| # send the payload | # send the payload | ||||
| @@ -259,7 +258,7 @@ class HTTPTransport: | |||||
| # read response line | # read response line | ||||
| code, msg, headers = r.getreply() | code, msg, headers = r.getreply() | ||||
| self.cookies = Cookie.SimpleCookie(); | |||||
| self.cookies = http.cookies.SimpleCookie(); | |||||
| if headers: | if headers: | ||||
| content_type = headers.get("content-type","text/xml") | content_type = headers.get("content-type","text/xml") | ||||
| content_length = headers.get("Content-length") | content_length = headers.get("Content-length") | ||||
| @@ -296,20 +295,20 @@ class HTTPTransport: | |||||
| data = f.read(message_len) | data = f.read(message_len) | ||||
| if(config.debug): | if(config.debug): | ||||
| print "code=",code | |||||
| print "msg=", msg | |||||
| print "headers=", headers | |||||
| print "content-type=", content_type | |||||
| print "data=", data | |||||
| print("code=",code) | |||||
| print("msg=", msg) | |||||
| print("headers=", headers) | |||||
| print("content-type=", content_type) | |||||
| print("data=", data) | |||||
| if config.dumpHeadersIn: | if config.dumpHeadersIn: | ||||
| s = 'Incoming HTTP headers' | s = 'Incoming HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| if headers.headers: | if headers.headers: | ||||
| print "HTTP/1.? %d %s" % (code, msg) | |||||
| print "\n".join(map (lambda x: x.strip(), headers.headers)) | |||||
| print("HTTP/1.? %d %s" % (code, msg)) | |||||
| print("\n".join([x.strip() for x in headers.headers])) | |||||
| else: | else: | ||||
| print "HTTP/0.9 %d %s" % (code, msg) | |||||
| print("HTTP/0.9 %d %s" % (code, msg)) | |||||
| debugFooter(s) | debugFooter(s) | ||||
| def startswith(string, val): | def startswith(string, val): | ||||
| @@ -322,9 +321,9 @@ class HTTPTransport: | |||||
| if config.dumpSOAPIn: | if config.dumpSOAPIn: | ||||
| s = 'Incoming SOAP' | s = 'Incoming SOAP' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print data, | |||||
| print(data, end=' ') | |||||
| if (len(data)>0) and (data[-1] != '\n'): | if (len(data)>0) and (data[-1] != '\n'): | ||||
| print() | |||||
| debugFooter(s) | debugFooter(s) | ||||
| if code not in (200, 500): | if code not in (200, 500): | ||||
| @@ -434,7 +433,7 @@ class SOAPProxy: | |||||
| except socket.timeout: | except socket.timeout: | ||||
| raise SOAPTimeoutError | raise SOAPTimeoutError | ||||
| except Exception, ex: | |||||
| except Exception as ex: | |||||
| # | # | ||||
| # Call failed. | # Call failed. | ||||
| # | # | ||||
| @@ -448,7 +447,7 @@ class SOAPProxy: | |||||
| # | # | ||||
| if hasattr(self.config, "faultHandler"): | if hasattr(self.config, "faultHandler"): | ||||
| if callable(self.config.faultHandler): | |||||
| if isinstance(self.config.faultHandler, collections.Callable): | |||||
| call_retry = self.config.faultHandler(self.proxy, ex) | call_retry = self.config.faultHandler(self.proxy, ex) | ||||
| if not call_retry: | if not call_retry: | ||||
| raise | raise | ||||
| @@ -478,7 +477,7 @@ class SOAPProxy: | |||||
| if throw_struct: | if throw_struct: | ||||
| if self.config.debug: | if self.config.debug: | ||||
| print p | |||||
| print(p) | |||||
| raise p | raise p | ||||
| # If unwrap_results=1 and there is only element in the struct, | # If unwrap_results=1 and there is only element in the struct, | ||||
| @@ -489,7 +488,7 @@ class SOAPProxy: | |||||
| if self.unwrap_results: | if self.unwrap_results: | ||||
| try: | try: | ||||
| count = 0 | count = 0 | ||||
| for i in p.__dict__.keys(): | |||||
| for i in list(p.__dict__.keys()): | |||||
| if i[0] != "_": # don't count the private stuff | if i[0] != "_": # don't count the private stuff | ||||
| count += 1 | count += 1 | ||||
| t = getattr(p, i) | t = getattr(p, i) | ||||
| @@ -514,7 +513,7 @@ class SOAPProxy: | |||||
| def __getattr__(self, name): # hook to catch method calls | def __getattr__(self, name): # hook to catch method calls | ||||
| if name in ( '__del__', '__getinitargs__', '__getnewargs__', | if name in ( '__del__', '__getinitargs__', '__getnewargs__', | ||||
| '__getstate__', '__setstate__', '__reduce__', '__reduce_ex__'): | '__getstate__', '__setstate__', '__reduce__', '__reduce_ex__'): | ||||
| raise AttributeError, name | |||||
| raise AttributeError(name) | |||||
| return self.__Method(self.__call, name, config = self.config) | return self.__Method(self.__call, name, config = self.config) | ||||
| # To handle attribute weirdness | # To handle attribute weirdness | ||||
| @@ -548,7 +547,7 @@ class SOAPProxy: | |||||
| def __getattr__(self, name): | def __getattr__(self, name): | ||||
| if name == '__del__': | if name == '__del__': | ||||
| raise AttributeError, name | |||||
| raise AttributeError(name) | |||||
| if self.__name[0] == "_": | if self.__name[0] == "_": | ||||
| # Don't nest method if it is a directive | # Don't nest method if it is a directive | ||||
| return self.__class__(self.__call, name, self.__ns, | return self.__class__(self.__call, name, self.__ns, | ||||
| @@ -34,12 +34,12 @@ | |||||
| """ | """ | ||||
| ident = '$Id: Config.py 1298 2006-11-07 00:54:15Z sanxiyn $' | ident = '$Id: Config.py 1298 2006-11-07 00:54:15Z sanxiyn $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| import socket | import socket | ||||
| from types import * | |||||
| from .types import * | |||||
| from NS import NS | |||||
| from .NS import NS | |||||
| ################################################################################ | ################################################################################ | ||||
| # Configuration class | # Configuration class | ||||
| @@ -58,12 +58,11 @@ class SOAPConfig: | |||||
| if config: | if config: | ||||
| if not isinstance(config, SOAPConfig): | if not isinstance(config, SOAPConfig): | ||||
| raise AttributeError, \ | |||||
| "initializer must be SOAPConfig instance" | |||||
| raise AttributeError("initializer must be SOAPConfig instance") | |||||
| s = config.__dict__ | s = config.__dict__ | ||||
| for k, v in s.items(): | |||||
| for k, v in list(s.items()): | |||||
| if k[0] != '_': | if k[0] != '_': | ||||
| d[k] = v | d[k] = v | ||||
| else: | else: | ||||
| @@ -157,13 +156,13 @@ class SOAPConfig: | |||||
| raise TypeError("Config dumpmap parameter must be a tuple") | raise TypeError("Config dumpmap parameter must be a tuple") | ||||
| self.dumpmap = dumpmap + self.dumpmap | self.dumpmap = dumpmap + self.dumpmap | ||||
| for k, v in kw.items(): | |||||
| for k, v in list(kw.items()): | |||||
| if k[0] != '_': | if k[0] != '_': | ||||
| setattr(self, k, v) | setattr(self, k, v) | ||||
| def __setattr__(self, name, value): | def __setattr__(self, name, value): | ||||
| if name in self.__readonly: | if name in self.__readonly: | ||||
| raise AttributeError, "readonly configuration setting" | |||||
| raise AttributeError("readonly configuration setting") | |||||
| d = self.__dict__ | d = self.__dict__ | ||||
| @@ -176,19 +175,19 @@ class SOAPConfig: | |||||
| base, uri = name, 0 | base, uri = name, 0 | ||||
| if type(value) == StringType: | if type(value) == StringType: | ||||
| if NS.NSMAP.has_key(value): | |||||
| if value in NS.NSMAP: | |||||
| n = (value, NS.NSMAP[value]) | n = (value, NS.NSMAP[value]) | ||||
| elif NS.NSMAP_R.has_key(value): | |||||
| elif value in NS.NSMAP_R: | |||||
| n = (NS.NSMAP_R[value], value) | n = (NS.NSMAP_R[value], value) | ||||
| else: | else: | ||||
| raise AttributeError, "unknown namespace" | |||||
| raise AttributeError("unknown namespace") | |||||
| elif type(value) in (ListType, TupleType): | elif type(value) in (ListType, TupleType): | ||||
| if uri: | if uri: | ||||
| n = (value[1], value[0]) | n = (value[1], value[0]) | ||||
| else: | else: | ||||
| n = (value[0], value[1]) | n = (value[0], value[1]) | ||||
| else: | else: | ||||
| raise AttributeError, "unknown namespace type" | |||||
| raise AttributeError("unknown namespace type") | |||||
| d[base], d[base + 'URI'] = n | d[base], d[base + 'URI'] = n | ||||
| @@ -201,8 +200,8 @@ class SOAPConfig: | |||||
| elif name == 'namespaceStyle': | elif name == 'namespaceStyle': | ||||
| value = str(value) | value = str(value) | ||||
| if not NS.STMAP.has_key(value): | |||||
| raise AttributeError, "unknown namespace style" | |||||
| if value not in NS.STMAP: | |||||
| raise AttributeError("unknown namespace style") | |||||
| d[name] = value | d[name] = value | ||||
| n = d['typesNamespace'] = NS.STMAP[value][0] | n = d['typesNamespace'] = NS.STMAP[value][0] | ||||
| @@ -41,7 +41,7 @@ | |||||
| """ | """ | ||||
| ident = '$Id: Errors.py 921 2005-02-15 16:32:23Z warnes $' | ident = '$Id: Errors.py 921 2005-02-15 16:32:23Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| import exceptions | import exceptions | ||||
| @@ -43,33 +43,33 @@ GSIServer - Contributed by Ivan R. Judson <judson@mcs.anl.gov> | |||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: GSIServer.py 1468 2008-05-24 01:55:33Z warnes $' | ident = '$Id: GSIServer.py 1468 2008-05-24 01:55:33Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| #import xml.sax | #import xml.sax | ||||
| import re | import re | ||||
| import socket | import socket | ||||
| import sys | import sys | ||||
| import SocketServer | |||||
| from types import * | |||||
| import BaseHTTPServer | |||||
| import socketserver | |||||
| from .types import * | |||||
| import http.server | |||||
| # SOAPpy modules | # SOAPpy modules | ||||
| from Parser import parseSOAPRPC | |||||
| from Config import SOAPConfig | |||||
| from Types import faultType, voidType, simplify | |||||
| from NS import NS | |||||
| from SOAPBuilder import buildSOAP | |||||
| from Utilities import debugHeader, debugFooter | |||||
| from .Parser import parseSOAPRPC | |||||
| from .Config import SOAPConfig | |||||
| from .Types import faultType, voidType, simplify | |||||
| from .NS import NS | |||||
| from .SOAPBuilder import buildSOAP | |||||
| from .Utilities import debugHeader, debugFooter | |||||
| try: from M2Crypto import SSL | try: from M2Crypto import SSL | ||||
| except: pass | except: pass | ||||
| ##### | ##### | ||||
| from Server import * | |||||
| from .Server import * | |||||
| from pyGlobus.io import GSITCPSocketServer, ThreadingGSITCPSocketServer | from pyGlobus.io import GSITCPSocketServer, ThreadingGSITCPSocketServer | ||||
| from pyGlobus import ioc | from pyGlobus import ioc | ||||
| @@ -40,10 +40,10 @@ | |||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: NS.py 1468 2008-05-24 01:55:33Z warnes $' | ident = '$Id: NS.py 1468 2008-05-24 01:55:33Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| ############################################################################## | ############################################################################## | ||||
| # Namespace Class | # Namespace Class | ||||
| @@ -51,7 +51,7 @@ from version import __version__ | |||||
| def invertDict(dict): | def invertDict(dict): | ||||
| d = {} | d = {} | ||||
| for k, v in dict.items(): | |||||
| for k, v in list(dict.items()): | |||||
| d[v] = k | d[v] = k | ||||
| return d | return d | ||||
| @@ -98,7 +98,7 @@ class NS: | |||||
| STMAP_R = invertDict(STMAP) | STMAP_R = invertDict(STMAP) | ||||
| def __init__(self): | def __init__(self): | ||||
| raise Error, "Don't instantiate this" | |||||
| raise Error("Don't instantiate this") | |||||
| @@ -1,17 +1,18 @@ | |||||
| # SOAPpy modules | # SOAPpy modules | ||||
| import traceback | import traceback | ||||
| from Config import Config | |||||
| from Types import * | |||||
| from NS import NS | |||||
| from Utilities import * | |||||
| from .Config import Config | |||||
| from .Types import * | |||||
| from .NS import NS | |||||
| from .Utilities import * | |||||
| import string | import string | ||||
| import xml.sax | import xml.sax | ||||
| from wstools.XMLname import fromXMLname | from wstools.XMLname import fromXMLname | ||||
| import collections | |||||
| try: | try: | ||||
| from cStringIO import StringIO | |||||
| from io import StringIO | |||||
| except ImportError: | except ImportError: | ||||
| from StringIO import StringIO | |||||
| from io import StringIO | |||||
| try: from M2Crypto import SSL | try: from M2Crypto import SSL | ||||
| except: pass | except: pass | ||||
| @@ -21,7 +22,7 @@ from defusedxml.common import DefusedXmlException | |||||
| ident = '$Id: Parser.py 1497 2010-03-08 06:06:52Z pooryorick $' | ident = '$Id: Parser.py 1497 2010-03-08 06:06:52Z pooryorick $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| ################################################################################ | ################################################################################ | ||||
| @@ -63,7 +64,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| self.contents.append(data) | self.contents.append(data) | ||||
| self.subattrs.append(attrs) | self.subattrs.append(attrs) | ||||
| if self.namecounts.has_key(name): | |||||
| if name in self.namecounts: | |||||
| self.namecounts[name] += 1 | self.namecounts[name] += 1 | ||||
| else: | else: | ||||
| self.namecounts[name] = 1 | self.namecounts[name] = 1 | ||||
| @@ -102,7 +103,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| def toStr( name ): | def toStr( name ): | ||||
| prefix = name[0] | prefix = name[0] | ||||
| tag = name[1] | tag = name[1] | ||||
| if self._prem_r.has_key(prefix): | |||||
| if prefix in self._prem_r: | |||||
| tag = self._prem_r[name[0]] + ':' + name[1] | tag = self._prem_r[name[0]] + ':' + name[1] | ||||
| elif prefix: | elif prefix: | ||||
| tag = prefix + ":" + tag | tag = prefix + ":" + tag | ||||
| @@ -118,10 +119,10 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if self._next == "E": | if self._next == "E": | ||||
| if name[1] != 'Envelope': | if name[1] != 'Envelope': | ||||
| raise Error, "expected `SOAP-ENV:Envelope', " \ | |||||
| "got `%s'" % toStr( name ) | |||||
| raise Error("expected `SOAP-ENV:Envelope', " \ | |||||
| "got `%s'" % toStr( name )) | |||||
| if name[0] != NS.ENV: | if name[0] != NS.ENV: | ||||
| raise faultType, ("%s:VersionMismatch" % NS.ENV_T, | |||||
| raise faultType("%s:VersionMismatch" % NS.ENV_T, | |||||
| "Don't understand version `%s' Envelope" % name[0]) | "Don't understand version `%s' Envelope" % name[0]) | ||||
| else: | else: | ||||
| self._next = "HorB" | self._next = "HorB" | ||||
| @@ -129,18 +130,17 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if name[0] == NS.ENV and name[1] in ("Header", "Body"): | if name[0] == NS.ENV and name[1] in ("Header", "Body"): | ||||
| self._next = None | self._next = None | ||||
| else: | else: | ||||
| raise Error, \ | |||||
| "expected `SOAP-ENV:Header' or `SOAP-ENV:Body', " \ | |||||
| "got `%s'" % toStr( name ) | |||||
| raise Error("expected `SOAP-ENV:Header' or `SOAP-ENV:Body', " \ | |||||
| "got `%s'" % toStr( name )) | |||||
| elif self._next == "B": | elif self._next == "B": | ||||
| if name == (NS.ENV, "Body"): | if name == (NS.ENV, "Body"): | ||||
| self._next = None | self._next = None | ||||
| else: | else: | ||||
| raise Error, "expected `SOAP-ENV:Body', " \ | |||||
| "got `%s'" % toStr( name ) | |||||
| raise Error("expected `SOAP-ENV:Body', " \ | |||||
| "got `%s'" % toStr( name )) | |||||
| elif self._next == "": | elif self._next == "": | ||||
| raise Error, "expected nothing, " \ | |||||
| "got `%s'" % toStr( name ) | |||||
| raise Error("expected nothing, " \ | |||||
| "got `%s'" % toStr( name )) | |||||
| if len(self._stack) == 2: | if len(self._stack) == 2: | ||||
| @@ -188,27 +188,27 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| name = fromXMLname(name) # convert to SOAP 1.2 XML name encoding | name = fromXMLname(name) # convert to SOAP 1.2 XML name encoding | ||||
| if self._next == "E": | if self._next == "E": | ||||
| raise Error, "didn't get SOAP-ENV:Envelope" | |||||
| raise Error("didn't get SOAP-ENV:Envelope") | |||||
| if self._next in ("HorB", "B"): | if self._next in ("HorB", "B"): | ||||
| raise Error, "didn't get SOAP-ENV:Body" | |||||
| raise Error("didn't get SOAP-ENV:Body") | |||||
| cur = self.popFrame() | cur = self.popFrame() | ||||
| attrs = cur.attrs | attrs = cur.attrs | ||||
| idval = None | idval = None | ||||
| if attrs.has_key((None, 'id')): | |||||
| if (None, 'id') in attrs: | |||||
| idval = attrs[(None, 'id')] | idval = attrs[(None, 'id')] | ||||
| if self._ids.has_key(idval): | |||||
| raise Error, "duplicate id `%s'" % idval | |||||
| if idval in self._ids: | |||||
| raise Error("duplicate id `%s'" % idval) | |||||
| del attrs[(None, 'id')] | del attrs[(None, 'id')] | ||||
| root = 1 | root = 1 | ||||
| if len(self._stack) == 3: | if len(self._stack) == 3: | ||||
| if attrs.has_key((NS.ENC, 'root')): | |||||
| if (NS.ENC, 'root') in attrs: | |||||
| root = int(attrs[(NS.ENC, 'root')]) | root = int(attrs[(NS.ENC, 'root')]) | ||||
| # Do some preliminary checks. First, if root="0" is present, | # Do some preliminary checks. First, if root="0" is present, | ||||
| @@ -217,9 +217,9 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if root == 0: | if root == 0: | ||||
| if idval == None: | if idval == None: | ||||
| raise Error, "non-root element must have an id" | |||||
| raise Error("non-root element must have an id") | |||||
| elif root != 1: | elif root != 1: | ||||
| raise Error, "SOAP-ENC:root must be `0' or `1'" | |||||
| raise Error("SOAP-ENC:root must be `0' or `1'") | |||||
| del attrs[(NS.ENC, 'root')] | del attrs[(NS.ENC, 'root')] | ||||
| @@ -227,19 +227,19 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| href = attrs.get((None, 'href')) | href = attrs.get((None, 'href')) | ||||
| if href: | if href: | ||||
| if href[0] != '#': | if href[0] != '#': | ||||
| raise Error, "Non-local hrefs are not yet suppported." | |||||
| raise Error("Non-local hrefs are not yet suppported.") | |||||
| if self._data != None and \ | if self._data != None and \ | ||||
| string.join(self._data, "").strip() != '': | string.join(self._data, "").strip() != '': | ||||
| raise Error, "hrefs can't have data" | |||||
| raise Error("hrefs can't have data") | |||||
| href = href[1:] | href = href[1:] | ||||
| if self._ids.has_key(href): | |||||
| if href in self._ids: | |||||
| data = self._ids[href] | data = self._ids[href] | ||||
| else: | else: | ||||
| data = RefHolder(name, self._stack[-1]) | data = RefHolder(name, self._stack[-1]) | ||||
| if self._refs.has_key(href): | |||||
| if href in self._refs: | |||||
| self._refs[href].append(data) | self._refs[href].append(data) | ||||
| else: | else: | ||||
| self._refs[href] = [data] | self._refs[href] = [data] | ||||
| @@ -252,7 +252,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if attrs: | if attrs: | ||||
| for i in NS.XSI_L: | for i in NS.XSI_L: | ||||
| if attrs.has_key((i, 'type')): | |||||
| if (i, 'type') in attrs: | |||||
| kind = attrs[(i, 'type')] | kind = attrs[(i, 'type')] | ||||
| del attrs[(i, 'type')] | del attrs[(i, 'type')] | ||||
| @@ -272,11 +272,11 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if attrs: | if attrs: | ||||
| for i in (NS.XSI, NS.XSI2): | for i in (NS.XSI, NS.XSI2): | ||||
| if attrs.has_key((i, 'null')): | |||||
| if (i, 'null') in attrs: | |||||
| null = attrs[(i, 'null')] | null = attrs[(i, 'null')] | ||||
| del attrs[(i, 'null')] | del attrs[(i, 'null')] | ||||
| if attrs.has_key((NS.XSI3, 'nil')): | |||||
| if (NS.XSI3, 'nil') in attrs: | |||||
| null = attrs[(NS.XSI3, 'nil')] | null = attrs[(NS.XSI3, 'nil')] | ||||
| del attrs[(NS.XSI3, 'nil')] | del attrs[(NS.XSI3, 'nil')] | ||||
| @@ -291,7 +291,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| # check for nil=1, but watch out for string values | # check for nil=1, but watch out for string values | ||||
| try: | try: | ||||
| null = int(null) | null = int(null) | ||||
| except ValueError, e: | |||||
| except ValueError as e: | |||||
| if not e[0].startswith("invalid literal for int()"): | if not e[0].startswith("invalid literal for int()"): | ||||
| raise e | raise e | ||||
| null = 0 | null = 0 | ||||
| @@ -299,7 +299,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if null: | if null: | ||||
| if len(cur) or \ | if len(cur) or \ | ||||
| (self._data != None and string.join(self._data, "").strip() != ''): | (self._data != None and string.join(self._data, "").strip() != ''): | ||||
| raise Error, "nils can't have data" | |||||
| raise Error("nils can't have data") | |||||
| data = None | data = None | ||||
| @@ -341,7 +341,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| # XXX What if rule != kind? | # XXX What if rule != kind? | ||||
| if callable(rule): | |||||
| if isinstance(rule, collections.Callable): | |||||
| data = rule(string.join(self._data, "")) | data = rule(string.join(self._data, "")) | ||||
| elif type(rule) == DictType: | elif type(rule) == DictType: | ||||
| data = structType(name = (ns, name), attrs = attrs) | data = structType(name = (ns, name), attrs = attrs) | ||||
| @@ -444,7 +444,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if idval != None: | if idval != None: | ||||
| self._ids[idval] = data | self._ids[idval] = data | ||||
| if self._refs.has_key(idval): | |||||
| if idval in self._refs: | |||||
| for i in self._refs[idval]: | for i in self._refs[idval]: | ||||
| i.parent._placeItem(i.name, data, i.pos, i.subpos, attrs) | i.parent._placeItem(i.name, data, i.pos, i.subpos, attrs) | ||||
| @@ -459,11 +459,9 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| def endDocument(self): | def endDocument(self): | ||||
| if len(self._refs) == 1: | if len(self._refs) == 1: | ||||
| raise Error, \ | |||||
| "unresolved reference " + self._refs.keys()[0] | |||||
| raise Error("unresolved reference " + list(self._refs.keys())[0]) | |||||
| elif len(self._refs) > 1: | elif len(self._refs) > 1: | ||||
| raise Error, \ | |||||
| "unresolved references " + ', '.join(self._refs.keys()) | |||||
| raise Error("unresolved references " + ', '.join(list(self._refs.keys()))) | |||||
| def startPrefixMapping(self, prefix, uri): | def startPrefixMapping(self, prefix, uri): | ||||
| self._prem[prefix] = uri | self._prem[prefix] = uri | ||||
| @@ -502,7 +500,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| else: | else: | ||||
| raise Exception | raise Exception | ||||
| except: | except: | ||||
| raise AttributeError, "invalid Array offset" | |||||
| raise AttributeError("invalid Array offset") | |||||
| else: | else: | ||||
| offset = 0 | offset = 0 | ||||
| @@ -525,7 +523,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| return typedArrayType(None, name, (None, t), attrs, offset, | return typedArrayType(None, name, (None, t), attrs, offset, | ||||
| m.group('rank'), m.group('asize'), elemsname) | m.group('rank'), m.group('asize'), elemsname) | ||||
| except: | except: | ||||
| raise AttributeError, "invalid Array type `%s'" % kind | |||||
| raise AttributeError("invalid Array type `%s'" % kind) | |||||
| # Conversion | # Conversion | ||||
| @@ -696,7 +694,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| s = float(s) | s = float(s) | ||||
| else: | else: | ||||
| try: s = int(s) | try: s = int(s) | ||||
| except ValueError: s = long(s) | |||||
| except ValueError: s = int(s) | |||||
| if i < fn: fn = i | if i < fn: fn = i | ||||
| @@ -728,7 +726,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| try: | try: | ||||
| s = int(s) | s = int(s) | ||||
| except ValueError: | except ValueError: | ||||
| s = long(s) | |||||
| s = int(s) | |||||
| r.append(s) | r.append(s) | ||||
| @@ -761,7 +759,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| try: | try: | ||||
| s = int(s) | s = int(s) | ||||
| except ValueError: | except ValueError: | ||||
| s = long(s) | |||||
| s = int(s) | |||||
| if i < fn: | if i < fn: | ||||
| fn = i | fn = i | ||||
| @@ -794,14 +792,14 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| s = [] | s = [] | ||||
| for i in range(1, len(f)): | for i in range(1, len(f)): | ||||
| if d.has_key(f[i]): | |||||
| if f[i] in d: | |||||
| s.append(r[i - 1]) | s.append(r[i - 1]) | ||||
| if len(s) == 1: | if len(s) == 1: | ||||
| return s[0] | return s[0] | ||||
| return tuple(s) | return tuple(s) | ||||
| except Exception, e: | |||||
| raise Error, "invalid %s value `%s' - %s" % (kind, value, e) | |||||
| except Exception as e: | |||||
| raise Error("invalid %s value `%s' - %s" % (kind, value, e)) | |||||
| intlimits = \ | intlimits = \ | ||||
| { | { | ||||
| @@ -809,17 +807,17 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| 'non-positive-integer': (0, None, 0), | 'non-positive-integer': (0, None, 0), | ||||
| 'negativeInteger': (0, None, -1), | 'negativeInteger': (0, None, -1), | ||||
| 'negative-integer': (0, None, -1), | 'negative-integer': (0, None, -1), | ||||
| 'long': (1, -9223372036854775808L, | |||||
| 9223372036854775807L), | |||||
| 'int': (0, -2147483648L, 2147483647L), | |||||
| 'long': (1, -9223372036854775808, | |||||
| 9223372036854775807), | |||||
| 'int': (0, -2147483648, 2147483647), | |||||
| 'short': (0, -32768, 32767), | 'short': (0, -32768, 32767), | ||||
| 'byte': (0, -128, 127), | 'byte': (0, -128, 127), | ||||
| 'nonNegativeInteger': (0, 0, None), | 'nonNegativeInteger': (0, 0, None), | ||||
| 'non-negative-integer': (0, 0, None), | 'non-negative-integer': (0, 0, None), | ||||
| 'positiveInteger': (0, 1, None), | 'positiveInteger': (0, 1, None), | ||||
| 'positive-integer': (0, 1, None), | 'positive-integer': (0, 1, None), | ||||
| 'unsignedLong': (1, 0, 18446744073709551615L), | |||||
| 'unsignedInt': (0, 0, 4294967295L), | |||||
| 'unsignedLong': (1, 0, 18446744073709551615), | |||||
| 'unsignedInt': (0, 0, 4294967295), | |||||
| 'unsignedShort': (0, 0, 65535), | 'unsignedShort': (0, 0, 65535), | ||||
| 'unsignedByte': (0, 0, 255), | 'unsignedByte': (0, 0, 255), | ||||
| } | } | ||||
| @@ -845,12 +843,10 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if elemtype=="ur-type": | if elemtype=="ur-type": | ||||
| return(d) | return(d) | ||||
| else: | else: | ||||
| newarr = map( lambda(di): | |||||
| self.convertToBasicTypes(d=di, | |||||
| newarr = [self.convertToBasicTypes(d=di, | |||||
| t = ( NS.XSD, elemtype), | t = ( NS.XSD, elemtype), | ||||
| attrs=attrs, | attrs=attrs, | ||||
| config=config), | |||||
| d) | |||||
| config=config) for di in d] | |||||
| return newarr | return newarr | ||||
| else: | else: | ||||
| t = (NS.XSD, t[1]) | t = (NS.XSD, t[1]) | ||||
| @@ -885,26 +881,26 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| try: | try: | ||||
| d = int(d) | d = int(d) | ||||
| if len(attrs): | if len(attrs): | ||||
| d = long(d) | |||||
| d = int(d) | |||||
| except: | except: | ||||
| d = long(d) | |||||
| d = int(d) | |||||
| return d | return d | ||||
| if self.intlimits.has_key (t[1]): # range-bounded integer types | |||||
| if t[1] in self.intlimits: # range-bounded integer types | |||||
| l = self.intlimits[t[1]] | l = self.intlimits[t[1]] | ||||
| try: d = int(d) | try: d = int(d) | ||||
| except: d = long(d) | |||||
| except: d = int(d) | |||||
| if l[1] != None and d < l[1]: | if l[1] != None and d < l[1]: | ||||
| raise UnderflowError, "%s too small" % d | |||||
| raise UnderflowError("%s too small" % d) | |||||
| if l[2] != None and d > l[2]: | if l[2] != None and d > l[2]: | ||||
| raise OverflowError, "%s too large" % d | |||||
| raise OverflowError("%s too large" % d) | |||||
| if l[0] or len(attrs): | if l[0] or len(attrs): | ||||
| return long(d) | |||||
| return int(d) | |||||
| return d | return d | ||||
| if t[1] == "string": | if t[1] == "string": | ||||
| if len(attrs): | if len(attrs): | ||||
| return unicode(dnn) | |||||
| return str(dnn) | |||||
| try: | try: | ||||
| return str(dnn) | return str(dnn) | ||||
| except: | except: | ||||
| @@ -915,7 +911,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| return False | return False | ||||
| if d in ('1', 'true'): | if d in ('1', 'true'): | ||||
| return True | return True | ||||
| raise AttributeError, "invalid boolean value" | |||||
| raise AttributeError("invalid boolean value") | |||||
| if t[1] in ('double','float'): | if t[1] in ('double','float'): | ||||
| l = self.floatlimits[t[1]] | l = self.floatlimits[t[1]] | ||||
| s = d.strip().lower() | s = d.strip().lower() | ||||
| @@ -933,23 +929,23 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if config.strict_range: | if config.strict_range: | ||||
| if NaN == d: | if NaN == d: | ||||
| if s[0:2] != 'nan': | if s[0:2] != 'nan': | ||||
| raise ValueError, "invalid %s: %s" % (t[1], s) | |||||
| raise ValueError("invalid %s: %s" % (t[1], s)) | |||||
| elif NegInf == d: | elif NegInf == d: | ||||
| if s[0:3] != '-inf': | if s[0:3] != '-inf': | ||||
| raise UnderflowError, "%s too small: %s" % (t[1], s) | |||||
| raise UnderflowError("%s too small: %s" % (t[1], s)) | |||||
| elif PosInf == d: | elif PosInf == d: | ||||
| if s[0:2] != 'inf' and s[0:3] != '+inf': | if s[0:2] != 'inf' and s[0:3] != '+inf': | ||||
| raise OverflowError, "%s too large: %s" % (t[1], s) | |||||
| raise OverflowError("%s too large: %s" % (t[1], s)) | |||||
| elif d < 0 and d < l[1]: | elif d < 0 and d < l[1]: | ||||
| raise UnderflowError, "%s too small: %s" % (t[1], s) | |||||
| raise UnderflowError("%s too small: %s" % (t[1], s)) | |||||
| elif d > 0 and ( d < l[0] or d > l[2] ): | elif d > 0 and ( d < l[0] or d > l[2] ): | ||||
| raise OverflowError, "%s too large: %s" % (t[1], s) | |||||
| raise OverflowError("%s too large: %s" % (t[1], s)) | |||||
| elif d == 0: | elif d == 0: | ||||
| if type(self.zerofloatre) == StringType: | if type(self.zerofloatre) == StringType: | ||||
| self.zerofloatre = re.compile(self.zerofloatre) | self.zerofloatre = re.compile(self.zerofloatre) | ||||
| if self.zerofloatre.search(s): | if self.zerofloatre.search(s): | ||||
| raise UnderflowError, "invalid %s: %s" % (t[1], s) | |||||
| raise UnderflowError("invalid %s: %s" % (t[1], s)) | |||||
| return d | return d | ||||
| if t[1] in ("dateTime", "date", "timeInstant", "time"): | if t[1] in ("dateTime", "date", "timeInstant", "time"): | ||||
| @@ -974,7 +970,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| else: | else: | ||||
| return | return | ||||
| if t[1] == "anyURI": | if t[1] == "anyURI": | ||||
| return urllib.unquote(collapseWhiteSpace(d)) | |||||
| return urllib.parse.unquote(collapseWhiteSpace(d)) | |||||
| if t[1] in ("normalizedString", "token"): | if t[1] in ("normalizedString", "token"): | ||||
| return collapseWhiteSpace(d) | return collapseWhiteSpace(d) | ||||
| if t[0] == NS.ENC: | if t[0] == NS.ENC: | ||||
| @@ -998,14 +994,14 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| except: | except: | ||||
| pass | pass | ||||
| raise Error, "unknown or missing binary encoding" | |||||
| raise Error("unknown or missing binary encoding") | |||||
| if t[1] == "uri": | if t[1] == "uri": | ||||
| return urllib.unquote(collapseWhiteSpace(d)) | |||||
| return urllib.parse.unquote(collapseWhiteSpace(d)) | |||||
| if t[1] == "recurringInstant": | if t[1] == "recurringInstant": | ||||
| return self.convertDateTime(d, t[1]) | return self.convertDateTime(d, t[1]) | ||||
| if t[0] in (NS.XSD2, NS.ENC): | if t[0] in (NS.XSD2, NS.ENC): | ||||
| if t[1] == "uriReference": | if t[1] == "uriReference": | ||||
| return urllib.unquote(collapseWhiteSpace(d)) | |||||
| return urllib.parse.unquote(collapseWhiteSpace(d)) | |||||
| if t[1] == "timePeriod": | if t[1] == "timePeriod": | ||||
| return self.convertDateTime(d, t[1]) | return self.convertDateTime(d, t[1]) | ||||
| if t[1] in ("century", "year"): | if t[1] in ("century", "year"): | ||||
| @@ -1015,7 +1011,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| return self.convertDateTime(d, t[1]) | return self.convertDateTime(d, t[1]) | ||||
| if t[0] == NS.XSD3: | if t[0] == NS.XSD3: | ||||
| if t[1] == "anyURI": | if t[1] == "anyURI": | ||||
| return urllib.unquote(collapseWhiteSpace(d)) | |||||
| return urllib.parse.unquote(collapseWhiteSpace(d)) | |||||
| if t[1] in ("gYearMonth", "gMonthDay"): | if t[1] in ("gYearMonth", "gMonthDay"): | ||||
| return self.convertDateTime(d, t[1]) | return self.convertDateTime(d, t[1]) | ||||
| if t[1] == "gYear": | if t[1] == "gYear": | ||||
| @@ -1039,7 +1035,7 @@ class SOAPParser(xml.sax.handler.ContentHandler): | |||||
| if t[1] == "CDATA": | if t[1] == "CDATA": | ||||
| return collapseWhiteSpace(d) | return collapseWhiteSpace(d) | ||||
| raise UnknownTypeError, "unknown type `%s'" % (str(t[0]) + ':' + t[1]) | |||||
| raise UnknownTypeError("unknown type `%s'" % (str(t[0]) + ':' + t[1])) | |||||
| ################################################################################ | ################################################################################ | ||||
| @@ -1078,13 +1074,13 @@ def _parseSOAP(xml_str, rules = None, ignore_ext=None, | |||||
| try: | try: | ||||
| parser.parse(inpsrc) | parser.parse(inpsrc) | ||||
| except DefusedXmlException, e: | |||||
| except DefusedXmlException as e: | |||||
| parser._parser = None | parser._parser = None | ||||
| print traceback.format_exc() | |||||
| print(traceback.format_exc()) | |||||
| raise e | raise e | ||||
| except xml.sax.SAXParseException, e: | |||||
| except xml.sax.SAXParseException as e: | |||||
| parser._parser = None | parser._parser = None | ||||
| print traceback.format_exc() | |||||
| print(traceback.format_exc()) | |||||
| raise e | raise e | ||||
| return t | return t | ||||
| @@ -1106,9 +1102,9 @@ def parseSOAPRPC(xml_str, header = 0, body = 0, attrs = 0, rules = None, ignore_ | |||||
| p = t.body[0] | p = t.body[0] | ||||
| # Empty string, for RPC this translates into a void | # Empty string, for RPC this translates into a void | ||||
| if type(p) in (type(''), type(u'')) and p in ('', u''): | |||||
| if type(p) in (type(''), type('')) and p in ('', ''): | |||||
| name = "Response" | name = "Response" | ||||
| for k in t.body.__dict__.keys(): | |||||
| for k in list(t.body.__dict__.keys()): | |||||
| if k[0] != "_": | if k[0] != "_": | ||||
| name = k | name = k | ||||
| p = structType(name) | p = structType(name) | ||||
| @@ -4,19 +4,19 @@ Delete when 1.0.0 is released! | |||||
| """ | """ | ||||
| ident = '$Id: SOAP.py 541 2004-01-31 04:20:06Z warnes $' | ident = '$Id: SOAP.py 541 2004-01-31 04:20:06Z warnes $' | ||||
| from version import __version__ | |||||
| from Client import * | |||||
| from Config import * | |||||
| from Errors import * | |||||
| from NS import * | |||||
| from Parser import * | |||||
| from SOAPBuilder import * | |||||
| from Server import * | |||||
| from Types import * | |||||
| from Utilities import * | |||||
| from .version import __version__ | |||||
| from .Client import * | |||||
| from .Config import * | |||||
| from .Errors import * | |||||
| from .NS import * | |||||
| from .Parser import * | |||||
| from .SOAPBuilder import * | |||||
| from .Server import * | |||||
| from .Types import * | |||||
| from .Utilities import * | |||||
| import wstools | import wstools | ||||
| import WSDL | |||||
| from . import WSDL | |||||
| from warnings import warn | from warnings import warn | ||||
| @@ -34,15 +34,15 @@ | |||||
| """ | """ | ||||
| ident = '$Id: SOAPBuilder.py 1498 2010-03-12 02:13:19Z pooryorick $' | ident = '$Id: SOAPBuilder.py 1498 2010-03-12 02:13:19Z pooryorick $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| import cgi | import cgi | ||||
| from wstools.XMLname import toXMLname, fromXMLname | from wstools.XMLname import toXMLname, fromXMLname | ||||
| # SOAPpy modules | # SOAPpy modules | ||||
| from Config import Config | |||||
| from NS import NS | |||||
| from Types import * | |||||
| from .Config import Config | |||||
| from .NS import NS | |||||
| from .Types import * | |||||
| # Test whether this Python version has Types.BooleanType | # Test whether this Python version has Types.BooleanType | ||||
| # If it doesn't have it, then False and True are serialized as integers | # If it doesn't have it, then False and True are serialized as integers | ||||
| @@ -100,7 +100,7 @@ class SOAPBuilder: | |||||
| self.noroot = noroot | self.noroot = noroot | ||||
| def build(self): | def build(self): | ||||
| if self.config.debug: print "In build." | |||||
| if self.config.debug: print("In build.") | |||||
| ns_map = {} | ns_map = {} | ||||
| # Cache whether typing is on or not | # Cache whether typing is on or not | ||||
| @@ -124,7 +124,7 @@ class SOAPBuilder: | |||||
| self.depth += 1 | self.depth += 1 | ||||
| a = '' | a = '' | ||||
| if self.methodattrs: | if self.methodattrs: | ||||
| for (k, v) in self.methodattrs.items(): | |||||
| for (k, v) in list(self.methodattrs.items()): | |||||
| a += ' %s="%s"' % (k, v) | a += ' %s="%s"' % (k, v) | ||||
| if self.namespace: # Use the namespace info handed to us | if self.namespace: # Use the namespace info handed to us | ||||
| @@ -144,11 +144,11 @@ class SOAPBuilder: | |||||
| for i in args: | for i in args: | ||||
| self.dump(i, typed = typed, ns_map = ns_map) | self.dump(i, typed = typed, ns_map = ns_map) | ||||
| if hasattr(self.config, "argsOrdering") and self.config.argsOrdering.has_key(self.method): | |||||
| if hasattr(self.config, "argsOrdering") and self.method in self.config.argsOrdering: | |||||
| for k in self.config.argsOrdering.get(self.method): | for k in self.config.argsOrdering.get(self.method): | ||||
| self.dump(self.kw.get(k), k, typed = typed, ns_map = ns_map) | self.dump(self.kw.get(k), k, typed = typed, ns_map = ns_map) | ||||
| else: | else: | ||||
| for (k, v) in self.kw.items(): | |||||
| for (k, v) in list(self.kw.items()): | |||||
| self.dump(v, k, typed = typed, ns_map = ns_map) | self.dump(v, k, typed = typed, ns_map = ns_map) | ||||
| except RecursionError: | except RecursionError: | ||||
| @@ -182,8 +182,7 @@ class SOAPBuilder: | |||||
| self.depth -= 1 | self.depth -= 1 | ||||
| if self.envelope: | if self.envelope: | ||||
| e = map (lambda ns: ' xmlns:%s="%s"\n' % (ns[1], ns[0]), | |||||
| self.envns.items()) | |||||
| e = [' xmlns:%s="%s"\n' % (ns[1], ns[0]) for ns in list(self.envns.items())] | |||||
| self.out = ['<', self._env_top] + e + ['>\n'] + \ | self.out = ['<', self._env_top] + e + ['>\n'] + \ | ||||
| self.out + \ | self.out + \ | ||||
| @@ -197,7 +196,7 @@ class SOAPBuilder: | |||||
| return ''.join(self.out) | return ''.join(self.out) | ||||
| def gentag(self): | def gentag(self): | ||||
| if self.config.debug: print "In gentag." | |||||
| if self.config.debug: print("In gentag.") | |||||
| self.tcounter += 1 | self.tcounter += 1 | ||||
| return "v%d" % self.tcounter | return "v%d" % self.tcounter | ||||
| @@ -213,10 +212,10 @@ class SOAPBuilder: | |||||
| else: | else: | ||||
| ns = None | ns = None | ||||
| if ns_map.has_key(nsURI): | |||||
| if nsURI in ns_map: | |||||
| return (ns_map[nsURI] + ':', '') | return (ns_map[nsURI] + ':', '') | ||||
| if self._env_ns.has_key(nsURI): | |||||
| if nsURI in self._env_ns: | |||||
| ns = self.envns[nsURI] = ns_map[nsURI] = self._env_ns[nsURI] | ns = self.envns[nsURI] = ns_map[nsURI] = self._env_ns[nsURI] | ||||
| return (ns + ':', '') | return (ns + ':', '') | ||||
| @@ -252,7 +251,7 @@ class SOAPBuilder: | |||||
| if self.depth < 2: | if self.depth < 2: | ||||
| return '' | return '' | ||||
| if not self.ids.has_key(id(obj)): | |||||
| if id(obj) not in self.ids: | |||||
| n = self.ids[id(obj)] = self.icounter | n = self.ids[id(obj)] = self.icounter | ||||
| self.icounter = n + 1 | self.icounter = n + 1 | ||||
| @@ -265,7 +264,7 @@ class SOAPBuilder: | |||||
| self.multirefs.append((obj, tag)) | self.multirefs.append((obj, tag)) | ||||
| else: | else: | ||||
| if self.use_refs == 0: | if self.use_refs == 0: | ||||
| raise RecursionError, "Cannot serialize recursive object" | |||||
| raise RecursionError("Cannot serialize recursive object") | |||||
| n = self.ids[id(obj)] | n = self.ids[id(obj)] | ||||
| @@ -279,12 +278,12 @@ class SOAPBuilder: | |||||
| # dumpers | # dumpers | ||||
| def dump(self, obj, tag = None, typed = 1, ns_map = {}): | def dump(self, obj, tag = None, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump.", "obj=", obj | |||||
| if self.config.debug: print("In dump.", "obj=", obj) | |||||
| ns_map = ns_map.copy() | ns_map = ns_map.copy() | ||||
| self.depth += 1 | self.depth += 1 | ||||
| if type(tag) not in (NoneType, StringType, UnicodeType): | if type(tag) not in (NoneType, StringType, UnicodeType): | ||||
| raise KeyError, "tag must be a string or None" | |||||
| raise KeyError("tag must be a string or None") | |||||
| self.dump_dispatch(obj, tag, typed, ns_map) | self.dump_dispatch(obj, tag, typed, ns_map) | ||||
| self.depth -= 1 | self.depth -= 1 | ||||
| @@ -293,7 +292,7 @@ class SOAPBuilder: | |||||
| def dumper(self, nsURI, obj_type, obj, tag, typed = 1, ns_map = {}, | def dumper(self, nsURI, obj_type, obj, tag, typed = 1, ns_map = {}, | ||||
| rootattr = '', id = '', | rootattr = '', id = '', | ||||
| xml = '<%(tag)s%(type)s%(id)s%(attrs)s%(root)s>%(data)s</%(tag)s>\n'): | xml = '<%(tag)s%(type)s%(id)s%(attrs)s%(root)s>%(data)s</%(tag)s>\n'): | ||||
| if self.config.debug: print "In dumper." | |||||
| if self.config.debug: print("In dumper.") | |||||
| if nsURI == None: | if nsURI == None: | ||||
| nsURI = self.config.typesNamespaceURI | nsURI = self.config.typesNamespaceURI | ||||
| @@ -324,7 +323,7 @@ class SOAPBuilder: | |||||
| "id": id, "attrs": a} | "id": id, "attrs": a} | ||||
| def dump_float(self, obj, tag, typed = 1, ns_map = {}): | def dump_float(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_float." | |||||
| if self.config.debug: print("In dump_float.") | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| @@ -346,7 +345,7 @@ class SOAPBuilder: | |||||
| None, "double", obj, tag, typed, ns_map, self.genroot(ns_map))) | None, "double", obj, tag, typed, ns_map, self.genroot(ns_map))) | ||||
| def dump_int(self, obj, tag, typed = 1, ns_map = {}): | def dump_int(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_int." | |||||
| if self.config.debug: print("In dump_int.") | |||||
| # fix error "Bad types (class java.math.BigInteger -> class java.lang.Integer)" | # fix error "Bad types (class java.math.BigInteger -> class java.lang.Integer)" | ||||
| if isinstance(obj, LongType): | if isinstance(obj, LongType): | ||||
| @@ -358,12 +357,12 @@ class SOAPBuilder: | |||||
| ns_map, self.genroot(ns_map))) | ns_map, self.genroot(ns_map))) | ||||
| def dump_bool(self, obj, tag, typed = 1, ns_map = {}): | def dump_bool(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_bool." | |||||
| if self.config.debug: print("In dump_bool.") | |||||
| self.out.append(self.dumper(None, 'boolean', obj, tag, typed, | self.out.append(self.dumper(None, 'boolean', obj, tag, typed, | ||||
| ns_map, self.genroot(ns_map))) | ns_map, self.genroot(ns_map))) | ||||
| def dump_string(self, obj, tag, typed = 0, ns_map = {}): | def dump_string(self, obj, tag, typed = 0, ns_map = {}): | ||||
| if self.config.debug: print "In dump_string." | |||||
| if self.config.debug: print("In dump_string.") | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| @@ -381,7 +380,7 @@ class SOAPBuilder: | |||||
| dump_unicode = dump_string | dump_unicode = dump_string | ||||
| def dump_None(self, obj, tag, typed = 0, ns_map = {}): | def dump_None(self, obj, tag, typed = 0, ns_map = {}): | ||||
| if self.config.debug: print "In dump_None." | |||||
| if self.config.debug: print("In dump_None.") | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| ns = self.genns(ns_map, self.config.schemaNamespaceURI)[0] | ns = self.genns(ns_map, self.config.schemaNamespaceURI)[0] | ||||
| @@ -392,7 +391,7 @@ class SOAPBuilder: | |||||
| dump_NoneType = dump_None # For Python 2.2+ | dump_NoneType = dump_None # For Python 2.2+ | ||||
| def dump_list(self, obj, tag, typed = 1, ns_map = {}): | def dump_list(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_list.", "obj=", obj | |||||
| if self.config.debug: print("In dump_list.", "obj=", obj) | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| @@ -512,7 +511,7 @@ class SOAPBuilder: | |||||
| dump_tuple = dump_list | dump_tuple = dump_list | ||||
| def dump_map(self, obj, tag, typed = 1, ns_map = {}): | def dump_map(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_map.", "obj=", obj | |||||
| if self.config.debug: print("In dump_map.", "obj=", obj) | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| @@ -566,7 +565,7 @@ class SOAPBuilder: | |||||
| self.out.append("</%sFault>\n" % vns) | self.out.append("</%sFault>\n" % vns) | ||||
| def dump_dictionary(self, obj, tag, typed = 1, ns_map = {}): | def dump_dictionary(self, obj, tag, typed = 1, ns_map = {}): | ||||
| if self.config.debug: print "In dump_dictionary." | |||||
| if self.config.debug: print("In dump_dictionary.") | |||||
| tag = tag or self.gentag() | tag = tag or self.gentag() | ||||
| tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding | ||||
| @@ -580,7 +579,7 @@ class SOAPBuilder: | |||||
| self.out.append('<%s%s%s%s>\n' % | self.out.append('<%s%s%s%s>\n' % | ||||
| (tag, id, a, self.genroot(ns_map))) | (tag, id, a, self.genroot(ns_map))) | ||||
| for (k, v) in obj.items(): | |||||
| for (k, v) in list(obj.items()): | |||||
| if k[0] != "_": | if k[0] != "_": | ||||
| self.dump(v, k, 1, ns_map) | self.dump(v, k, 1, ns_map) | ||||
| @@ -607,11 +606,11 @@ class SOAPBuilder: | |||||
| (Exception, self.dump_exception), | (Exception, self.dump_exception), | ||||
| (mapType, self.dump_map), | (mapType, self.dump_map), | ||||
| (arrayType, self.dump_list), | (arrayType, self.dump_list), | ||||
| (basestring, self.dump_string), | |||||
| (str, self.dump_string), | |||||
| (NoneType, self.dump_None), | (NoneType, self.dump_None), | ||||
| (bool, self.dump_bool), | (bool, self.dump_bool), | ||||
| (int, self.dump_int), | (int, self.dump_int), | ||||
| (long, self.dump_int), | |||||
| (int, self.dump_int), | |||||
| (list, self.dump_list), | (list, self.dump_list), | ||||
| (tuple, self.dump_list), | (tuple, self.dump_list), | ||||
| (dict, self.dump_dictionary), | (dict, self.dump_dictionary), | ||||
| @@ -644,7 +643,7 @@ class SOAPBuilder: | |||||
| tag = ns + tag | tag = ns + tag | ||||
| self.out.append("<%s%s%s%s%s>\n" % (tag, ndecl, id, a, r)) | self.out.append("<%s%s%s%s%s>\n" % (tag, ndecl, id, a, r)) | ||||
| keylist = obj.__dict__.keys() | |||||
| keylist = list(obj.__dict__.keys()) | |||||
| # first write out items with order information | # first write out items with order information | ||||
| if hasattr(obj, '_keyord'): | if hasattr(obj, '_keyord'): | ||||
| @@ -688,7 +687,7 @@ class SOAPBuilder: | |||||
| if d1 is None and hasattr(obj, "__slots__"): | if d1 is None and hasattr(obj, "__slots__"): | ||||
| d1 = dict(((k, getattr(obj, k)) for k in obj.__slots__)) | d1 = dict(((k, getattr(obj, k)) for k in obj.__slots__)) | ||||
| if d1 is not None: | if d1 is not None: | ||||
| for (k, v) in d1.items(): | |||||
| for (k, v) in list(d1.items()): | |||||
| if k[0] != "_": | if k[0] != "_": | ||||
| self.dump(v, k, 1, ns_map) | self.dump(v, k, 1, ns_map) | ||||
| @@ -40,33 +40,34 @@ | |||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: Server.py 1468 2008-05-24 01:55:33Z warnes $' | ident = '$Id: Server.py 1468 2008-05-24 01:55:33Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| #import xml.sax | #import xml.sax | ||||
| import socket | import socket | ||||
| import sys | import sys | ||||
| import SocketServer | |||||
| from types import * | |||||
| import BaseHTTPServer | |||||
| import thread | |||||
| import socketserver | |||||
| from .types import * | |||||
| import http.server | |||||
| import _thread | |||||
| # SOAPpy modules | # SOAPpy modules | ||||
| from Parser import parseSOAPRPC | |||||
| from Config import Config | |||||
| from Types import faultType, voidType, simplify | |||||
| from NS import NS | |||||
| from SOAPBuilder import buildSOAP | |||||
| from Utilities import debugHeader, debugFooter | |||||
| from .Parser import parseSOAPRPC | |||||
| from .Config import Config | |||||
| from .Types import faultType, voidType, simplify | |||||
| from .NS import NS | |||||
| from .SOAPBuilder import buildSOAP | |||||
| from .Utilities import debugHeader, debugFooter | |||||
| import collections | |||||
| try: from M2Crypto import SSL | try: from M2Crypto import SSL | ||||
| except: pass | except: pass | ||||
| ident = '$Id: Server.py 1468 2008-05-24 01:55:33Z warnes $' | ident = '$Id: Server.py 1468 2008-05-24 01:55:33Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| ################################################################################ | ################################################################################ | ||||
| # Call context dictionary | # Call context dictionary | ||||
| @@ -76,7 +77,7 @@ _contexts = dict() | |||||
| def GetSOAPContext(): | def GetSOAPContext(): | ||||
| global _contexts | global _contexts | ||||
| return _contexts[thread.get_ident()] | |||||
| return _contexts[_thread.get_ident()] | |||||
| ################################################################################ | ################################################################################ | ||||
| # Server | # Server | ||||
| @@ -93,7 +94,7 @@ class MethodSig: | |||||
| self.__name__ = func.__name__ | self.__name__ = func.__name__ | ||||
| def __call__(self, *args, **kw): | def __call__(self, *args, **kw): | ||||
| return apply(self.func,args,kw) | |||||
| return self.func(*args, **kw) | |||||
| class SOAPContext: | class SOAPContext: | ||||
| def __init__(self, header, body, attrs, xmldata, connection, httpheaders, | def __init__(self, header, body, attrs, xmldata, connection, httpheaders, | ||||
| @@ -111,7 +112,7 @@ class SOAPContext: | |||||
| class HeaderHandler: | class HeaderHandler: | ||||
| # Initially fail out if there are any problems. | # Initially fail out if there are any problems. | ||||
| def __init__(self, header, attrs): | def __init__(self, header, attrs): | ||||
| for i in header.__dict__.keys(): | |||||
| for i in list(header.__dict__.keys()): | |||||
| if i[0] == "_": | if i[0] == "_": | ||||
| continue | continue | ||||
| @@ -123,7 +124,7 @@ class HeaderHandler: | |||||
| fault = 0 | fault = 0 | ||||
| if fault: | if fault: | ||||
| raise faultType, ("%s:MustUnderstand" % NS.ENV_T, | |||||
| raise faultType("%s:MustUnderstand" % NS.ENV_T, | |||||
| "Required Header Misunderstood", | "Required Header Misunderstood", | ||||
| "%s" % i) | "%s" % i) | ||||
| @@ -133,13 +134,13 @@ class HeaderHandler: | |||||
| class SOAPServerBase: | class SOAPServerBase: | ||||
| def get_request(self): | def get_request(self): | ||||
| sock, addr = SocketServer.TCPServer.get_request(self) | |||||
| sock, addr = socketserver.TCPServer.get_request(self) | |||||
| if self.ssl_context: | if self.ssl_context: | ||||
| sock = SSL.Connection(self.ssl_context, sock) | sock = SSL.Connection(self.ssl_context, sock) | ||||
| sock._setup_ssl(addr) | sock._setup_ssl(addr) | ||||
| if sock.accept_ssl() != 1: | if sock.accept_ssl() != 1: | ||||
| raise socket.error, "Couldn't accept SSL connection" | |||||
| raise socket.error("Couldn't accept SSL connection") | |||||
| return sock, addr | return sock, addr | ||||
| @@ -157,7 +158,7 @@ class SOAPServerBase: | |||||
| if namespace == '' and path != '': | if namespace == '' and path != '': | ||||
| namespace = path.replace("/", ":") | namespace = path.replace("/", ":") | ||||
| if namespace[0] == ":": namespace = namespace[1:] | if namespace[0] == ":": namespace = namespace[1:] | ||||
| if self.funcmap.has_key(namespace): | |||||
| if namespace in self.funcmap: | |||||
| self.funcmap[namespace][funcName] = function | self.funcmap[namespace][funcName] = function | ||||
| else: | else: | ||||
| self.funcmap[namespace] = {funcName : function} | self.funcmap[namespace] = {funcName : function} | ||||
| @@ -168,7 +169,7 @@ class SOAPServerBase: | |||||
| namespace = path.replace("/", ":") | namespace = path.replace("/", ":") | ||||
| if namespace[0] == ":": namespace = namespace[1:] | if namespace[0] == ":": namespace = namespace[1:] | ||||
| for i in dir(object.__class__): | for i in dir(object.__class__): | ||||
| if i[0] != "_" and callable(getattr(object, i)): | |||||
| if i[0] != "_" and isinstance(getattr(object, i), collections.Callable): | |||||
| self.registerKWFunction(getattr(object,i), namespace) | self.registerKWFunction(getattr(object,i), namespace) | ||||
| # convenience - wraps your func for you. | # convenience - wraps your func for you. | ||||
| @@ -189,7 +190,7 @@ class SOAPServerBase: | |||||
| del self.objmap[namespace] | del self.objmap[namespace] | ||||
| class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| class SOAPRequestHandler(http.server.BaseHTTPRequestHandler): | |||||
| ignore_ext = True | ignore_ext = True | ||||
| def version_string(self): | def version_string(self): | ||||
| return '<a href="http://pywebsvcs.sf.net">' + \ | return '<a href="http://pywebsvcs.sf.net">' + \ | ||||
| @@ -198,7 +199,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| def date_time_string(self): | def date_time_string(self): | ||||
| self.__last_date_time_string = \ | self.__last_date_time_string = \ | ||||
| BaseHTTPServer.BaseHTTPRequestHandler.\ | |||||
| http.server.BaseHTTPRequestHandler.\ | |||||
| date_time_string(self) | date_time_string(self) | ||||
| return self.__last_date_time_string | return self.__last_date_time_string | ||||
| @@ -211,9 +212,8 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| if self.server.config.dumpHeadersIn: | if self.server.config.dumpHeadersIn: | ||||
| s = 'Incoming HTTP headers' | s = 'Incoming HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print self.raw_requestline.strip() | |||||
| print "\n".join(map (lambda x: x.strip(), | |||||
| self.headers.headers)) | |||||
| print(self.raw_requestline.strip()) | |||||
| print("\n".join([x.strip() for x in self.headers.headers])) | |||||
| debugFooter(s) | debugFooter(s) | ||||
| data = self.rfile.read(int(self.headers["Content-length"])) | data = self.rfile.read(int(self.headers["Content-length"])) | ||||
| @@ -221,9 +221,9 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| if self.server.config.dumpSOAPIn: | if self.server.config.dumpSOAPIn: | ||||
| s = 'Incoming SOAP' | s = 'Incoming SOAP' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print data, | |||||
| print(data, end=' ') | |||||
| if data[-1] != '\n': | if data[-1] != '\n': | ||||
| print() | |||||
| debugFooter(s) | debugFooter(s) | ||||
| (r, header, body, attrs) = \ | (r, header, body, attrs) = \ | ||||
| @@ -255,7 +255,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| if self.server.config.specialArgs: | if self.server.config.specialArgs: | ||||
| for (k,v) in kw.items(): | |||||
| for (k,v) in list(kw.items()): | |||||
| if k[0]=="v": | if k[0]=="v": | ||||
| try: | try: | ||||
| @@ -282,11 +282,11 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| # authorization method | # authorization method | ||||
| a = None | a = None | ||||
| keylist = ordered_args.keys() | |||||
| keylist = list(ordered_args.keys()) | |||||
| keylist.sort() | keylist.sort() | ||||
| # create list in proper order w/o names | # create list in proper order w/o names | ||||
| tmp = map( lambda x: ordered_args[x], keylist) | |||||
| tmp = [ordered_args[x] for x in keylist] | |||||
| ordered_args = tmp | ordered_args = tmp | ||||
| #print '<-> Argument Matching Yielded:' | #print '<-> Argument Matching Yielded:' | ||||
| @@ -303,15 +303,15 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| try: | try: | ||||
| # First look for registered functions | # First look for registered functions | ||||
| if self.server.funcmap.has_key(ns) and \ | |||||
| self.server.funcmap[ns].has_key(method): | |||||
| if ns in self.server.funcmap and \ | |||||
| method in self.server.funcmap[ns]: | |||||
| f = self.server.funcmap[ns][method] | f = self.server.funcmap[ns][method] | ||||
| # look for the authorization method | # look for the authorization method | ||||
| if self.server.config.authMethod != None: | if self.server.config.authMethod != None: | ||||
| authmethod = self.server.config.authMethod | authmethod = self.server.config.authMethod | ||||
| if self.server.funcmap.has_key(ns) and \ | |||||
| self.server.funcmap[ns].has_key(authmethod): | |||||
| if ns in self.server.funcmap and \ | |||||
| authmethod in self.server.funcmap[ns]: | |||||
| a = self.server.funcmap[ns][authmethod] | a = self.server.funcmap[ns][authmethod] | ||||
| else: | else: | ||||
| # Now look at registered objects | # Now look at registered objects | ||||
| @@ -357,11 +357,11 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| # and it won't be necessary here | # and it won't be necessary here | ||||
| # for now we're doing both | # for now we're doing both | ||||
| if "SOAPAction".lower() not in self.headers.keys() or \ | |||||
| if "SOAPAction".lower() not in list(self.headers.keys()) or \ | |||||
| self.headers["SOAPAction"] == "\"\"": | self.headers["SOAPAction"] == "\"\"": | ||||
| self.headers["SOAPAction"] = method | self.headers["SOAPAction"] = method | ||||
| thread_id = thread.get_ident() | |||||
| thread_id = _thread.get_ident() | |||||
| _contexts[thread_id] = SOAPContext(header, body, | _contexts[thread_id] = SOAPContext(header, body, | ||||
| attrs, data, | attrs, data, | ||||
| self.connection, | self.connection, | ||||
| @@ -370,7 +370,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| # Do an authorization check | # Do an authorization check | ||||
| if a != None: | if a != None: | ||||
| if not apply(a, (), {"_SOAPContext" : | |||||
| if not a(*(), **{"_SOAPContext" : | |||||
| _contexts[thread_id] }): | _contexts[thread_id] }): | ||||
| raise faultType("%s:Server" % NS.ENV_T, | raise faultType("%s:Server" % NS.ENV_T, | ||||
| "Authorization failed.", | "Authorization failed.", | ||||
| @@ -386,28 +386,28 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| if self.server.config.specialArgs: | if self.server.config.specialArgs: | ||||
| if c: | if c: | ||||
| named_args["_SOAPContext"] = c | named_args["_SOAPContext"] = c | ||||
| fr = apply(f, ordered_args, named_args) | |||||
| fr = f(*ordered_args, **named_args) | |||||
| elif f.keywords: | elif f.keywords: | ||||
| # This is lame, but have to de-unicode | # This is lame, but have to de-unicode | ||||
| # keywords | # keywords | ||||
| strkw = {} | strkw = {} | ||||
| for (k, v) in kw.items(): | |||||
| for (k, v) in list(kw.items()): | |||||
| strkw[str(k)] = v | strkw[str(k)] = v | ||||
| if c: | if c: | ||||
| strkw["_SOAPContext"] = c | strkw["_SOAPContext"] = c | ||||
| fr = apply(f, (), strkw) | |||||
| fr = f(*(), **strkw) | |||||
| elif c: | elif c: | ||||
| fr = apply(f, args, {'_SOAPContext':c}) | |||||
| fr = f(*args, **{'_SOAPContext':c}) | |||||
| else: | else: | ||||
| fr = apply(f, args, {}) | |||||
| fr = f(*args, **{}) | |||||
| else: | else: | ||||
| if self.server.config.specialArgs: | if self.server.config.specialArgs: | ||||
| fr = apply(f, ordered_args, named_args) | |||||
| fr = f(*ordered_args, **named_args) | |||||
| else: | else: | ||||
| fr = apply(f, args, {}) | |||||
| fr = f(*args, **{}) | |||||
| if type(fr) == type(self) and \ | if type(fr) == type(self) and \ | ||||
| @@ -422,10 +422,10 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| config = self.server.config) | config = self.server.config) | ||||
| # Clean up _contexts | # Clean up _contexts | ||||
| if _contexts.has_key(thread_id): | |||||
| if thread_id in _contexts: | |||||
| del _contexts[thread_id] | del _contexts[thread_id] | ||||
| except Exception, e: | |||||
| except Exception as e: | |||||
| import traceback | import traceback | ||||
| info = sys.exc_info() | info = sys.exc_info() | ||||
| @@ -457,7 +457,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| status = 500 | status = 500 | ||||
| else: | else: | ||||
| status = 200 | status = 200 | ||||
| except faultType, e: | |||||
| except faultType as e: | |||||
| import traceback | import traceback | ||||
| info = sys.exc_info() | info = sys.exc_info() | ||||
| try: | try: | ||||
| @@ -479,7 +479,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| resp = buildSOAP(e, encoding = self.server.encoding, | resp = buildSOAP(e, encoding = self.server.encoding, | ||||
| config = self.server.config) | config = self.server.config) | ||||
| status = 500 | status = 500 | ||||
| except Exception, e: | |||||
| except Exception as e: | |||||
| # internal error, report as HTTP server error | # internal error, report as HTTP server error | ||||
| if self.server.config.dumpFaultInfo: | if self.server.config.dumpFaultInfo: | ||||
| @@ -501,13 +501,13 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| self.request_version != 'HTTP/0.9': | self.request_version != 'HTTP/0.9': | ||||
| s = 'Outgoing HTTP headers' | s = 'Outgoing HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| if self.responses.has_key(status): | |||||
| if status in self.responses: | |||||
| s = ' ' + self.responses[status][0] | s = ' ' + self.responses[status][0] | ||||
| else: | else: | ||||
| s = '' | s = '' | ||||
| print "%s %d%s" % (self.protocol_version, 500, s) | |||||
| print "Server:", self.version_string() | |||||
| print "Date:", self.__last_date_time_string | |||||
| print("%s %d%s" % (self.protocol_version, 500, s)) | |||||
| print("Server:", self.version_string()) | |||||
| print("Date:", self.__last_date_time_string) | |||||
| debugFooter(s) | debugFooter(s) | ||||
| else: | else: | ||||
| # got a valid SOAP response | # got a valid SOAP response | ||||
| @@ -524,23 +524,23 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| self.request_version != 'HTTP/0.9': | self.request_version != 'HTTP/0.9': | ||||
| s = 'Outgoing HTTP headers' | s = 'Outgoing HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| if self.responses.has_key(status): | |||||
| if status in self.responses: | |||||
| s = ' ' + self.responses[status][0] | s = ' ' + self.responses[status][0] | ||||
| else: | else: | ||||
| s = '' | s = '' | ||||
| print "%s %d%s" % (self.protocol_version, status, s) | |||||
| print "Server:", self.version_string() | |||||
| print "Date:", self.__last_date_time_string | |||||
| print "Content-type:", t | |||||
| print "Content-length:", len(resp) | |||||
| print("%s %d%s" % (self.protocol_version, status, s)) | |||||
| print("Server:", self.version_string()) | |||||
| print("Date:", self.__last_date_time_string) | |||||
| print("Content-type:", t) | |||||
| print("Content-length:", len(resp)) | |||||
| debugFooter(s) | debugFooter(s) | ||||
| if self.server.config.dumpSOAPOut: | if self.server.config.dumpSOAPOut: | ||||
| s = 'Outgoing SOAP' | s = 'Outgoing SOAP' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| print resp, | |||||
| print(resp, end=' ') | |||||
| if resp[-1] != '\n': | if resp[-1] != '\n': | ||||
| print() | |||||
| debugFooter(s) | debugFooter(s) | ||||
| self.wfile.write(resp) | self.wfile.write(resp) | ||||
| @@ -573,11 +573,11 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| if path.endswith('wsdl'): | if path.endswith('wsdl'): | ||||
| method = 'wsdl' | method = 'wsdl' | ||||
| function = namespace = None | function = namespace = None | ||||
| if self.server.funcmap.has_key(namespace) \ | |||||
| and self.server.funcmap[namespace].has_key(method): | |||||
| if namespace in self.server.funcmap \ | |||||
| and method in self.server.funcmap[namespace]: | |||||
| function = self.server.funcmap[namespace][method] | function = self.server.funcmap[namespace][method] | ||||
| else: | else: | ||||
| if namespace in self.server.objmap.keys(): | |||||
| if namespace in list(self.server.objmap.keys()): | |||||
| function = self.server.objmap[namespace] | function = self.server.objmap[namespace] | ||||
| l = method.split(".") | l = method.split(".") | ||||
| for i in l: | for i in l: | ||||
| @@ -587,7 +587,7 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| self.send_response(200) | self.send_response(200) | ||||
| self.send_header("Content-type", 'text/plain') | self.send_header("Content-type", 'text/plain') | ||||
| self.end_headers() | self.end_headers() | ||||
| response = apply(function, ()) | |||||
| response = function(*()) | |||||
| self.wfile.write(str(response)) | self.wfile.write(str(response)) | ||||
| return | return | ||||
| @@ -618,16 +618,16 @@ class SOAPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| def log_message(self, format, *args): | def log_message(self, format, *args): | ||||
| if self.server.log: | if self.server.log: | ||||
| BaseHTTPServer.BaseHTTPRequestHandler.\ | |||||
| http.server.BaseHTTPRequestHandler.\ | |||||
| log_message (self, format, *args) | log_message (self, format, *args) | ||||
| class SOAPInsecureRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||
| class SOAPInsecureRequestHandler(http.server.BaseHTTPRequestHandler): | |||||
| '''Request handler that does load POSTed doctypes''' | '''Request handler that does load POSTed doctypes''' | ||||
| ignore_ext = False | ignore_ext = False | ||||
| class SOAPServer(SOAPServerBase, SocketServer.TCPServer): | |||||
| class SOAPServer(SOAPServerBase, socketserver.TCPServer): | |||||
| def __init__(self, addr = ('localhost', 8000), | def __init__(self, addr = ('localhost', 8000), | ||||
| RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | ||||
| @@ -638,8 +638,7 @@ class SOAPServer(SOAPServerBase, SocketServer.TCPServer): | |||||
| ''.encode(encoding) | ''.encode(encoding) | ||||
| if ssl_context != None and not config.SSLserver: | if ssl_context != None and not config.SSLserver: | ||||
| raise AttributeError, \ | |||||
| "SSL server not supported by this Python installation" | |||||
| raise AttributeError("SSL server not supported by this Python installation") | |||||
| self.namespace = namespace | self.namespace = namespace | ||||
| self.objmap = {} | self.objmap = {} | ||||
| @@ -651,10 +650,10 @@ class SOAPServer(SOAPServerBase, SocketServer.TCPServer): | |||||
| self.allow_reuse_address= 1 | self.allow_reuse_address= 1 | ||||
| SocketServer.TCPServer.__init__(self, addr, RequestHandler) | |||||
| socketserver.TCPServer.__init__(self, addr, RequestHandler) | |||||
| class ThreadingSOAPServer(SOAPServerBase, SocketServer.ThreadingTCPServer): | |||||
| class ThreadingSOAPServer(SOAPServerBase, socketserver.ThreadingTCPServer): | |||||
| def __init__(self, addr = ('localhost', 8000), | def __init__(self, addr = ('localhost', 8000), | ||||
| RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | ||||
| @@ -665,8 +664,7 @@ class ThreadingSOAPServer(SOAPServerBase, SocketServer.ThreadingTCPServer): | |||||
| ''.encode(encoding) | ''.encode(encoding) | ||||
| if ssl_context != None and not config.SSLserver: | if ssl_context != None and not config.SSLserver: | ||||
| raise AttributeError, \ | |||||
| "SSL server not supported by this Python installation" | |||||
| raise AttributeError("SSL server not supported by this Python installation") | |||||
| self.namespace = namespace | self.namespace = namespace | ||||
| self.objmap = {} | self.objmap = {} | ||||
| @@ -678,12 +676,12 @@ class ThreadingSOAPServer(SOAPServerBase, SocketServer.ThreadingTCPServer): | |||||
| self.allow_reuse_address= 1 | self.allow_reuse_address= 1 | ||||
| SocketServer.ThreadingTCPServer.__init__(self, addr, RequestHandler) | |||||
| socketserver.ThreadingTCPServer.__init__(self, addr, RequestHandler) | |||||
| # only define class if Unix domain sockets are available | # only define class if Unix domain sockets are available | ||||
| if hasattr(socket, "AF_UNIX"): | if hasattr(socket, "AF_UNIX"): | ||||
| class SOAPUnixSocketServer(SOAPServerBase, SocketServer.UnixStreamServer): | |||||
| class SOAPUnixSocketServer(SOAPServerBase, socketserver.UnixStreamServer): | |||||
| def __init__(self, addr = 8000, | def __init__(self, addr = 8000, | ||||
| RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8', | ||||
| @@ -694,8 +692,7 @@ if hasattr(socket, "AF_UNIX"): | |||||
| ''.encode(encoding) | ''.encode(encoding) | ||||
| if ssl_context != None and not config.SSLserver: | if ssl_context != None and not config.SSLserver: | ||||
| raise AttributeError, \ | |||||
| "SSL server not supported by this Python installation" | |||||
| raise AttributeError("SSL server not supported by this Python installation") | |||||
| self.namespace = namespace | self.namespace = namespace | ||||
| self.objmap = {} | self.objmap = {} | ||||
| @@ -707,7 +704,7 @@ if hasattr(socket, "AF_UNIX"): | |||||
| self.allow_reuse_address= 1 | self.allow_reuse_address= 1 | ||||
| SocketServer.UnixStreamServer.__init__(self, str(addr), RequestHandler) | |||||
| socketserver.UnixStreamServer.__init__(self, str(addr), RequestHandler) | |||||
| @@ -2,10 +2,10 @@ | |||||
| authentication""" | authentication""" | ||||
| ident = '$Id: URLopener.py 541 2004-01-31 04:20:06Z warnes $' | ident = '$Id: URLopener.py 541 2004-01-31 04:20:06Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| from Config import Config | |||||
| from urllib import FancyURLopener | |||||
| from .Config import Config | |||||
| from urllib.request import FancyURLopener | |||||
| class URLopener(FancyURLopener): | class URLopener(FancyURLopener): | ||||
| @@ -34,15 +34,15 @@ | |||||
| """ | """ | ||||
| ident = '$Id: Utilities.py 1298 2006-11-07 00:54:15Z sanxiyn $' | ident = '$Id: Utilities.py 1298 2006-11-07 00:54:15Z sanxiyn $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| import re | import re | ||||
| import string | import string | ||||
| import sys | import sys | ||||
| from types import * | |||||
| from .types import * | |||||
| # SOAPpy modules | # SOAPpy modules | ||||
| from Errors import * | |||||
| from .Errors import * | |||||
| ################################################################################ | ################################################################################ | ||||
| # Utility infielders | # Utility infielders | ||||
| @@ -84,8 +84,7 @@ def decodeHexString(data): | |||||
| try: | try: | ||||
| c = conv[c] | c = conv[c] | ||||
| except KeyError: | except KeyError: | ||||
| raise ValueError, \ | |||||
| "invalid hex string character `%s'" % c | |||||
| raise ValueError("invalid hex string character `%s'" % c) | |||||
| if low: | if low: | ||||
| bin += chr(high * 16 + c) | bin += chr(high * 16 + c) | ||||
| @@ -97,12 +96,11 @@ def decodeHexString(data): | |||||
| i += 1 | i += 1 | ||||
| if low: | if low: | ||||
| raise ValueError, "invalid hex string length" | |||||
| raise ValueError("invalid hex string length") | |||||
| while i < len(data): | while i < len(data): | ||||
| if data[i] not in string.whitespace: | if data[i] not in string.whitespace: | ||||
| raise ValueError, \ | |||||
| "invalid hex string character `%s'" % c | |||||
| raise ValueError("invalid hex string character `%s'" % c) | |||||
| i += 1 | i += 1 | ||||
| @@ -127,7 +125,7 @@ def cleanDate(d, first = 0): | |||||
| names = ('year', 'month', 'day', 'hours', 'minutes', 'seconds') | names = ('year', 'month', 'day', 'hours', 'minutes', 'seconds') | ||||
| if len(d) != 6: | if len(d) != 6: | ||||
| raise ValueError, "date must have 6 elements" | |||||
| raise ValueError("date must have 6 elements") | |||||
| for i in range(first, 6): | for i in range(first, 6): | ||||
| s = d[i] | s = d[i] | ||||
| @@ -139,38 +137,38 @@ def cleanDate(d, first = 0): | |||||
| except OverflowError: | except OverflowError: | ||||
| if i > 0: | if i > 0: | ||||
| raise | raise | ||||
| s = long(s) | |||||
| s = int(s) | |||||
| if s != d[i]: | if s != d[i]: | ||||
| raise ValueError, "%s must be integral" % names[i] | |||||
| raise ValueError("%s must be integral" % names[i]) | |||||
| d[i] = s | d[i] = s | ||||
| elif type(s) == LongType: | elif type(s) == LongType: | ||||
| try: s = int(s) | try: s = int(s) | ||||
| except: pass | except: pass | ||||
| elif type(s) != IntType: | elif type(s) != IntType: | ||||
| raise TypeError, "%s isn't a valid type" % names[i] | |||||
| raise TypeError("%s isn't a valid type" % names[i]) | |||||
| if i == first and s < 0: | if i == first and s < 0: | ||||
| continue | continue | ||||
| if ranges[i] != None and \ | if ranges[i] != None and \ | ||||
| (s < ranges[i][0] or ranges[i][1] < s): | (s < ranges[i][0] or ranges[i][1] < s): | ||||
| raise ValueError, "%s out of range" % names[i] | |||||
| raise ValueError("%s out of range" % names[i]) | |||||
| if first < 6 and d[5] >= 61: | if first < 6 and d[5] >= 61: | ||||
| raise ValueError, "seconds out of range" | |||||
| raise ValueError("seconds out of range") | |||||
| if first < 2: | if first < 2: | ||||
| leap = first < 1 and leapMonth(d[0], d[1]) | leap = first < 1 and leapMonth(d[0], d[1]) | ||||
| if d[2] > months[d[1]] + leap: | if d[2] > months[d[1]] + leap: | ||||
| raise ValueError, "day out of range" | |||||
| raise ValueError("day out of range") | |||||
| def debugHeader(title): | def debugHeader(title): | ||||
| s = '*** ' + title + ' ' | s = '*** ' + title + ' ' | ||||
| print s + ('*' * (72 - len(s))) | |||||
| print(s + ('*' * (72 - len(s)))) | |||||
| def debugFooter(title): | def debugFooter(title): | ||||
| print '*' * 72 | |||||
| print('*' * 72) | |||||
| sys.stdout.flush() | sys.stdout.flush() | ||||
| @@ -3,14 +3,14 @@ | |||||
| Rudimentary support.""" | Rudimentary support.""" | ||||
| ident = '$Id: WSDL.py 1467 2008-05-16 23:32:51Z warnes $' | ident = '$Id: WSDL.py 1467 2008-05-16 23:32:51Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| import wstools | import wstools | ||||
| import xml | import xml | ||||
| from Errors import Error | |||||
| from Client import SOAPProxy, SOAPAddress | |||||
| from Config import Config | |||||
| import urllib | |||||
| from .Errors import Error | |||||
| from .Client import SOAPProxy, SOAPAddress | |||||
| from .Config import Config | |||||
| import urllib.request, urllib.parse, urllib.error | |||||
| class Proxy: | class Proxy: | ||||
| """WSDL Proxy. | """WSDL Proxy. | ||||
| @@ -41,14 +41,14 @@ class Proxy: | |||||
| # From Mark Pilgrim's "Dive Into Python" toolkit.py--open anything. | # From Mark Pilgrim's "Dive Into Python" toolkit.py--open anything. | ||||
| if self.wsdl is None and hasattr(wsdlsource, "read"): | if self.wsdl is None and hasattr(wsdlsource, "read"): | ||||
| print 'stream:', wsdlsource | |||||
| print('stream:', wsdlsource) | |||||
| try: | try: | ||||
| self.wsdl = reader.loadFromStream(wsdlsource) | self.wsdl = reader.loadFromStream(wsdlsource) | ||||
| except xml.parsers.expat.ExpatError, e: | |||||
| newstream = urllib.URLopener(key_file=config.SSL.key_file, cert_file=config.SSL.cert_file).open(wsdlsource) | |||||
| except xml.parsers.expat.ExpatError as e: | |||||
| newstream = urllib.request.URLopener(key_file=config.SSL.key_file, cert_file=config.SSL.cert_file).open(wsdlsource) | |||||
| buf = newstream.readlines() | buf = newstream.readlines() | ||||
| raise Error, "Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf)) | |||||
| raise Error("Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf))) | |||||
| # NOT TESTED (as of April 17, 2003) | # NOT TESTED (as of April 17, 2003) | ||||
| @@ -63,25 +63,25 @@ class Proxy: | |||||
| self.wsdl = reader.loadFromFile(wsdlsource) | self.wsdl = reader.loadFromFile(wsdlsource) | ||||
| #print 'file' | #print 'file' | ||||
| except (IOError, OSError): pass | except (IOError, OSError): pass | ||||
| except xml.parsers.expat.ExpatError, e: | |||||
| newstream = urllib.urlopen(wsdlsource) | |||||
| except xml.parsers.expat.ExpatError as e: | |||||
| newstream = urllib.request.urlopen(wsdlsource) | |||||
| buf = newstream.readlines() | buf = newstream.readlines() | ||||
| raise Error, "Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf)) | |||||
| raise Error("Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf))) | |||||
| if self.wsdl is None: | if self.wsdl is None: | ||||
| try: | try: | ||||
| stream = urllib.URLopener(key_file=config.SSL.key_file, cert_file=config.SSL.cert_file).open(wsdlsource) | |||||
| stream = urllib.request.URLopener(key_file=config.SSL.key_file, cert_file=config.SSL.cert_file).open(wsdlsource) | |||||
| self.wsdl = reader.loadFromStream(stream, wsdlsource) | self.wsdl = reader.loadFromStream(stream, wsdlsource) | ||||
| except (IOError, OSError): pass | except (IOError, OSError): pass | ||||
| except xml.parsers.expat.ExpatError, e: | |||||
| newstream = urllib.urlopen(wsdlsource) | |||||
| except xml.parsers.expat.ExpatError as e: | |||||
| newstream = urllib.request.urlopen(wsdlsource) | |||||
| buf = newstream.readlines() | buf = newstream.readlines() | ||||
| raise Error, "Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf)) | |||||
| raise Error("Unable to parse WSDL file at %s: \n\t%s" % \ | |||||
| (wsdlsource, "\t".join(buf))) | |||||
| if self.wsdl is None: | if self.wsdl is None: | ||||
| import StringIO | |||||
| import io | |||||
| self.wsdl = reader.loadFromString(str(wsdlsource)) | self.wsdl = reader.loadFromString(str(wsdlsource)) | ||||
| #print 'string' | #print 'string' | ||||
| @@ -102,7 +102,7 @@ class Proxy: | |||||
| def __str__(self): | def __str__(self): | ||||
| s = '' | s = '' | ||||
| for method in self.methods.values(): | |||||
| for method in list(self.methods.values()): | |||||
| s += str(method) | s += str(method) | ||||
| return s | return s | ||||
| @@ -111,7 +111,7 @@ class Proxy: | |||||
| Raises AttributeError is method name is not found.""" | Raises AttributeError is method name is not found.""" | ||||
| if not self.methods.has_key(name): raise AttributeError, name | |||||
| if name not in self.methods: raise AttributeError(name) | |||||
| callinfo = self.methods[name] | callinfo = self.methods[name] | ||||
| self.soapproxy.proxy = SOAPAddress(callinfo.location) | self.soapproxy.proxy = SOAPAddress(callinfo.location) | ||||
| @@ -120,18 +120,18 @@ class Proxy: | |||||
| return self.soapproxy.__getattr__(name) | return self.soapproxy.__getattr__(name) | ||||
| def show_methods(self): | def show_methods(self): | ||||
| for key in self.methods.keys(): | |||||
| for key in list(self.methods.keys()): | |||||
| method = self.methods[key] | method = self.methods[key] | ||||
| print "Method Name:", key.ljust(15) | |||||
| print("Method Name:", key.ljust(15)) | |||||
| print() | |||||
| inps = method.inparams | inps = method.inparams | ||||
| for parm in range(len(inps)): | for parm in range(len(inps)): | ||||
| details = inps[parm] | details = inps[parm] | ||||
| print " In #%d: %s (%s)" % (parm, details.name, details.type) | |||||
| print(" In #%d: %s (%s)" % (parm, details.name, details.type)) | |||||
| print() | |||||
| outps = method.outparams | outps = method.outparams | ||||
| for parm in range(len(outps)): | for parm in range(len(outps)): | ||||
| details = outps[parm] | details = outps[parm] | ||||
| print " Out #%d: %s (%s)" % (parm, details.name, details.type) | |||||
| print(" Out #%d: %s (%s)" % (parm, details.name, details.type)) | |||||
| print() | |||||
| @@ -1,15 +1,15 @@ | |||||
| ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $' | ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $' | ||||
| from version import __version__ | |||||
| from .version import __version__ | |||||
| from Client import * | |||||
| from Config import * | |||||
| from Errors import * | |||||
| from NS import * | |||||
| from Parser import * | |||||
| from SOAPBuilder import * | |||||
| from Server import * | |||||
| from Types import * | |||||
| from Utilities import * | |||||
| from .Client import * | |||||
| from .Config import * | |||||
| from .Errors import * | |||||
| from .NS import * | |||||
| from .Parser import * | |||||
| from .SOAPBuilder import * | |||||
| from .Server import * | |||||
| from .Types import * | |||||
| from .Utilities import * | |||||
| import wstools | import wstools | ||||
| import WSDL | |||||
| from . import WSDL | |||||
| @@ -21,12 +21,12 @@ server = WSDL.Proxy('http://www.xmethods.net/sd/2001/BabelFishService.wsdl', | |||||
| english = "Hi Friend!" | english = "Hi Friend!" | ||||
| print "Babelfish Translations" | |||||
| print "------------------------" | |||||
| print "English: '%s'" % english | |||||
| print "French: '%s'" % server.BabelFish('en_fr',english) | |||||
| print "Spanish: '%s'" % server.BabelFish('en_es',english) | |||||
| print "Italian: '%s'" % server.BabelFish('en_it',english) | |||||
| print "German: '%s'" % server.BabelFish('en_de',english) | |||||
| print "Done." | |||||
| print("Babelfish Translations") | |||||
| print("------------------------") | |||||
| print("English: '%s'" % english) | |||||
| print("French: '%s'" % server.BabelFish('en_fr',english)) | |||||
| print("Spanish: '%s'" % server.BabelFish('en_es',english)) | |||||
| print("Italian: '%s'" % server.BabelFish('en_it',english)) | |||||
| print("German: '%s'" % server.BabelFish('en_de',english)) | |||||
| print("Done.") | |||||
| @@ -57,19 +57,19 @@ kw2 = retval[1][1] | |||||
| assert(retval[0] == adgroupid) | assert(retval[0] == adgroupid) | ||||
| for key in kw1.keys(): | |||||
| for key in list(kw1.keys()): | |||||
| assert(kw1[key]==keyword1[key]) | assert(kw1[key]==keyword1[key]) | ||||
| for key in kw2.keys(): | |||||
| for key in list(kw2.keys()): | |||||
| assert(kw2[key]==keyword2[key]) | assert(kw2[key]==keyword2[key]) | ||||
| # Check that the header is preserved | # Check that the header is preserved | ||||
| retval = server.echo_header((adgroupid, keylist)) | retval = server.echo_header((adgroupid, keylist)) | ||||
| assert(retval[1].has_key('useragent')) | |||||
| assert('useragent' in retval[1]) | |||||
| assert(retval[1]['useragent'] == 'foo') | assert(retval[1]['useragent'] == 'foo') | ||||
| server.quit() | server.quit() | ||||
| print "Success!" | |||||
| print("Success!") | |||||
| @@ -20,24 +20,24 @@ Config.simplify_objects = 0 | |||||
| server = SOAPProxy("http://localhost:9900/") | server = SOAPProxy("http://localhost:9900/") | ||||
| x = u'uMOO' # Single unicode string | |||||
| x = 'uMOO' # Single unicode string | |||||
| y = server.echo_simple((x,)) | y = server.echo_simple((x,)) | ||||
| assert( x==y[0] ) | assert( x==y[0] ) | ||||
| x = [u'uMoo1',u'uMoo2'] # array of unicode strings | |||||
| x = ['uMoo1','uMoo2'] # array of unicode strings | |||||
| y = server.echo_simple(x) | y = server.echo_simple(x) | ||||
| assert( x[0] == y[0] ) | assert( x[0] == y[0] ) | ||||
| assert( x[1] == y[1] ) | assert( x[1] == y[1] ) | ||||
| x = { | x = { | ||||
| u'A':1, | |||||
| u'B':u'B', | |||||
| 'C':u'C', | |||||
| 'A':1, | |||||
| 'B':'B', | |||||
| 'C':'C', | |||||
| 'D':'D' | 'D':'D' | ||||
| } | } | ||||
| y = server.echo_simple(x) | y = server.echo_simple(x) | ||||
| for key in x.keys(): | |||||
| for key in list(x.keys()): | |||||
| assert( x[key] == y[0][key] ) | assert( x[key] == y[0][key] ) | ||||
| print "Success" | |||||
| print("Success") | |||||
| @@ -35,4 +35,4 @@ z = parseSOAPRPC(detailed_fault.strip() ) | |||||
| assert(z.__class__==faultType) | assert(z.__class__==faultType) | ||||
| assert(z.faultstring=="Exception thrown on Server") | assert(z.faultstring=="Exception thrown on Server") | ||||
| assert(z.detail.loginFailureFault.description=='Login failure (504):Unknown User') | assert(z.detail.loginFailureFault.description=='Login failure (504):Unknown User') | ||||
| print "Success" | |||||
| print("Success") | |||||
| @@ -8,4 +8,4 @@ results = server.doGoogleSearch(key, 'warnes', 0, 10, False, "", | |||||
| for i in range(len(results.resultElements)): | for i in range(len(results.resultElements)): | ||||
| res = results.resultElements[i] | res = results.resultElements[i] | ||||
| print '%d: %s --> %s' % ( i, res.title, res.URL ) | |||||
| print('%d: %s --> %s' % ( i, res.title, res.URL )) | |||||
| @@ -4,5 +4,5 @@ from SOAPpy import * | |||||
| one = typedArrayType(data=[1],typed=type(1)) | one = typedArrayType(data=[1],typed=type(1)) | ||||
| tmp = typedArrayType(data=[], typed=type(1)) | tmp = typedArrayType(data=[], typed=type(1)) | ||||
| print buildSOAP( one ) | |||||
| print buildSOAP( tmp ) | |||||
| print(buildSOAP( one )) | |||||
| print(buildSOAP( tmp )) | |||||
| @@ -31,4 +31,4 @@ server = SOAPProxy(SoapEndpointURL, | |||||
| ) | ) | ||||
| for category in server.GetCategories(): | for category in server.GetCategories(): | ||||
| print category | |||||
| print(category) | |||||
| @@ -16,15 +16,15 @@ ns = "http://soapinterop.org/" | |||||
| serv = SOAPProxy(endpoint, namespace=ns, soapaction=sa) | serv = SOAPProxy(endpoint, namespace=ns, soapaction=sa) | ||||
| try: hand = serv.dealHand(NumberOfCards = 13, StringSeparator = '\n') | try: hand = serv.dealHand(NumberOfCards = 13, StringSeparator = '\n') | ||||
| except: print "no dealHand"; hand = 0 | |||||
| except: print("no dealHand"); hand = 0 | |||||
| try: sortedhand = serv.dealArrangedHand(NumberOfCards=13,StringSeparator='\n') | try: sortedhand = serv.dealArrangedHand(NumberOfCards=13,StringSeparator='\n') | ||||
| except: print "no sorted"; sortedhand = 0 | |||||
| except: print("no sorted"); sortedhand = 0 | |||||
| try: card = serv.dealCard() | try: card = serv.dealCard() | ||||
| except: print "no card"; card = 0 | |||||
| except: print("no card"); card = 0 | |||||
| print "*****hand****\n",hand,"\n*********" | |||||
| print "******sortedhand*****\n",sortedhand,"\n*********" | |||||
| print "card:",card | |||||
| print("*****hand****\n",hand,"\n*********") | |||||
| print("******sortedhand*****\n",sortedhand,"\n*********") | |||||
| print("card:",card) | |||||
| serv.quit() | serv.quit() | ||||
| @@ -26,7 +26,7 @@ for suit in [__cs, __ds, __hs, __ss]: | |||||
| def deal(num): | def deal(num): | ||||
| if num not in range(1,53): | |||||
| if num not in list(range(1,53)): | |||||
| return -1 | return -1 | ||||
| else: | else: | ||||
| alreadydealt = [] | alreadydealt = [] | ||||
| @@ -82,7 +82,7 @@ def dealHand (NumberOfCards, StringSeparator): | |||||
| def dealArrangedHand (NumberOfCards, StringSeparator): | def dealArrangedHand (NumberOfCards, StringSeparator): | ||||
| if NumberOfCards < 1 or NumberOfCards > 52: | if NumberOfCards < 1 or NumberOfCards > 52: | ||||
| raise ValueError, "NumberOfCards must be between 1 and 52" | |||||
| raise ValueError("NumberOfCards must be between 1 and 52") | |||||
| unarranged = deal(NumberOfCards) | unarranged = deal(NumberOfCards) | ||||
| hand = arrangeHand(unarranged) | hand = arrangeHand(unarranged) | ||||
| return string.join(hand, StringSeparator) | return string.join(hand, StringSeparator) | ||||
| @@ -38,65 +38,65 @@ else: | |||||
| # Echo... | # Echo... | ||||
| try: | try: | ||||
| print server.echo("MOO") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server.echo("MOO")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver.echo("MOO") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver.echo("MOO")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # ...in an object | # ...in an object | ||||
| try: | try: | ||||
| print server.echo_ino("moo") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server.echo_ino("moo")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver.echo_ino("cow") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver.echo_ino("cow")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # ...in an object in an object | # ...in an object in an object | ||||
| try: | try: | ||||
| print server.prop.echo2("moo") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server.prop.echo2("moo")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver.prop.echo2("cow") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver.prop.echo2("cow")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # ...with keyword arguments | # ...with keyword arguments | ||||
| try: | try: | ||||
| print server.echo_wkw(third = "three", first = "one", second = "two") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server.echo_wkw(third = "three", first = "one", second = "two")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver.echo_wkw(third = "three", first = "one", second = "two") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver.echo_wkw(third = "three", first = "one", second = "two")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # ...with a context object | # ...with a context object | ||||
| try: | try: | ||||
| print server.echo_wc("moo") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server.echo_wc("moo")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver.echo_wc("cow") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver.echo_wc("cow")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # ...with a header | # ...with a header | ||||
| hd = headerType(data = {"mystring": "Hello World"}) | hd = headerType(data = {"mystring": "Hello World"}) | ||||
| try: | try: | ||||
| print server._hd(hd).echo_wc("moo") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(server._hd(hd).echo_wc("moo")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| try: | try: | ||||
| print pathserver._hd(hd).echo_wc("cow") | |||||
| except Exception, e: | |||||
| print "Caught exception: ", e | |||||
| print(pathserver._hd(hd).echo_wc("cow")) | |||||
| except Exception as e: | |||||
| print("Caught exception: ", e) | |||||
| # close down server | # close down server | ||||
| server.quit() | server.quit() | ||||
| @@ -18,6 +18,6 @@ Config.BuildWithNoNamespacePrefix = 1 | |||||
| hd = headerType(data = {"mystring": "Hello World"}) | hd = headerType(data = {"mystring": "Hello World"}) | ||||
| server = SOAPProxy("http://localhost:9900/", header=hd) | server = SOAPProxy("http://localhost:9900/", header=hd) | ||||
| print server.echo("Hello world") | |||||
| print(server.echo("Hello world")) | |||||
| server.quit() | server.quit() | ||||
| @@ -36,8 +36,8 @@ def _authorize(*args, **kw): | |||||
| global allowAll, Config | global allowAll, Config | ||||
| if Config.debug: | if Config.debug: | ||||
| print "Authorize (function) called! (result = %d)" % allowAll | |||||
| print "Arguments: %s" % kw | |||||
| print("Authorize (function) called! (result = %d)" % allowAll) | |||||
| print("Arguments: %s" % kw) | |||||
| if allowAll: | if allowAll: | ||||
| return 1 | return 1 | ||||
| @@ -51,7 +51,7 @@ def echo(s): | |||||
| # Test of context retrieval | # Test of context retrieval | ||||
| ctx = Server.GetSOAPContext() | ctx = Server.GetSOAPContext() | ||||
| if Config.debug: | if Config.debug: | ||||
| print "SOAP Context: ", ctx | |||||
| print("SOAP Context: ", ctx) | |||||
| return s + s | return s + s | ||||
| @@ -71,10 +71,10 @@ class echoBuilder: | |||||
| global allowAll, Config | global allowAll, Config | ||||
| if Config.debug: | if Config.debug: | ||||
| print "Authorize (method) called with arguments:" | |||||
| print "*args=%s" % str(args) | |||||
| print "**kw =%s" % str(kw) | |||||
| print "Approved -> %d" % allowAll | |||||
| print("Authorize (method) called with arguments:") | |||||
| print("*args=%s" % str(args)) | |||||
| print("**kw =%s" % str(kw)) | |||||
| print("Approved -> %d" % allowAll) | |||||
| if allowAll: | if allowAll: | ||||
| return 1 | return 1 | ||||
| @@ -91,40 +91,40 @@ def echo_wc(s, _SOAPContext): | |||||
| # The Context object has extra info about the call | # The Context object has extra info about the call | ||||
| if Config.debug: | if Config.debug: | ||||
| print "-- XML", sep[7:] | |||||
| print("-- XML", sep[7:]) | |||||
| # The original XML request | # The original XML request | ||||
| print c.xmldata | |||||
| print(c.xmldata) | |||||
| print "-- Header", sep[10:] | |||||
| print("-- Header", sep[10:]) | |||||
| # The SOAP Header or None if not present | # The SOAP Header or None if not present | ||||
| print c.header | |||||
| print(c.header) | |||||
| if c.header: | if c.header: | ||||
| print "-- Header.mystring", sep[19:] | |||||
| print("-- Header.mystring", sep[19:]) | |||||
| # An element of the SOAP Header | # An element of the SOAP Header | ||||
| print c.header.mystring | |||||
| print(c.header.mystring) | |||||
| print "-- Body", sep[8:] | |||||
| print("-- Body", sep[8:]) | |||||
| # The whole Body object | # The whole Body object | ||||
| print c.body | |||||
| print(c.body) | |||||
| print "-- Peer", sep[8:] | |||||
| print("-- Peer", sep[8:]) | |||||
| if not GSI: | if not GSI: | ||||
| # The socket object, useful for | # The socket object, useful for | ||||
| print c.connection.getpeername() | |||||
| print(c.connection.getpeername()) | |||||
| else: | else: | ||||
| # The socket object, useful for | # The socket object, useful for | ||||
| print c.connection.get_remote_address() | |||||
| print(c.connection.get_remote_address()) | |||||
| ctx = c.connection.get_security_context() | ctx = c.connection.get_security_context() | ||||
| print ctx.inquire()[0].display() | |||||
| print(ctx.inquire()[0].display()) | |||||
| print "-- SOAPAction", sep[14:] | |||||
| print("-- SOAPAction", sep[14:]) | |||||
| # The SOAPaction HTTP header | # The SOAPaction HTTP header | ||||
| print c.soapaction | |||||
| print(c.soapaction) | |||||
| print "-- HTTP headers", sep[16:] | |||||
| print("-- HTTP headers", sep[16:]) | |||||
| # All the HTTP headers | # All the HTTP headers | ||||
| print c.httpheaders | |||||
| print(c.httpheaders) | |||||
| return s + s | return s + s | ||||
| @@ -149,8 +149,7 @@ SSL = 0 | |||||
| if len(sys.argv) > 1 and sys.argv[1] == '-s': | if len(sys.argv) > 1 and sys.argv[1] == '-s': | ||||
| SSL = 1 | SSL = 1 | ||||
| if not Config.SSLserver: | if not Config.SSLserver: | ||||
| raise RuntimeError, \ | |||||
| "this Python installation doesn't have OpenSSL and M2Crypto" | |||||
| raise RuntimeError("this Python installation doesn't have OpenSSL and M2Crypto") | |||||
| ssl_context = SSL.Context() | ssl_context = SSL.Context() | ||||
| ssl_context.load_cert('validate/server.pem') | ssl_context.load_cert('validate/server.pem') | ||||
| server = SOAPServer(addr, ssl_context = ssl_context) | server = SOAPServer(addr, ssl_context = ssl_context) | ||||
| @@ -164,7 +163,7 @@ else: | |||||
| server = SOAPServer(addr) | server = SOAPServer(addr) | ||||
| prefix = 'http' | prefix = 'http' | ||||
| print "Server listening at: %s://%s:%d/" % (prefix, addr[0], addr[1]) | |||||
| print("Server listening at: %s://%s:%d/" % (prefix, addr[0], addr[1])) | |||||
| # register the method | # register the method | ||||
| server.registerFunction(echo) | server.registerFunction(echo) | ||||
| @@ -22,38 +22,38 @@ if __name__ == "__main__": | |||||
| original_integer = 5 | original_integer = 5 | ||||
| result_integer = server.test_integer(original_integer) | result_integer = server.test_integer(original_integer) | ||||
| print "original_integer %s" % original_integer | |||||
| print "result_integer %s" % result_integer | |||||
| print("original_integer %s" % original_integer) | |||||
| print("result_integer %s" % result_integer) | |||||
| assert(result_integer==original_integer) | assert(result_integer==original_integer) | ||||
| print() | |||||
| original_string = "five" | original_string = "five" | ||||
| result_string = server.test_string(original_string) | result_string = server.test_string(original_string) | ||||
| print "original_string %s" % original_string | |||||
| print "result_string %s" % result_string | |||||
| print("original_string %s" % original_string) | |||||
| print("result_string %s" % result_string) | |||||
| assert(result_string==original_string) | assert(result_string==original_string) | ||||
| print() | |||||
| original_float = 5.0 | original_float = 5.0 | ||||
| result_float = server.test_float(original_float) | result_float = server.test_float(original_float) | ||||
| print "original_float %s" % original_float | |||||
| print "result_float %s" % result_float | |||||
| print("original_float %s" % original_float) | |||||
| print("result_float %s" % result_float) | |||||
| assert(result_float==original_float) | assert(result_float==original_float) | ||||
| print() | |||||
| original_tuple = (1,2,"three","four",5) | original_tuple = (1,2,"three","four",5) | ||||
| result_tuple = server.test_tuple(original_tuple) | result_tuple = server.test_tuple(original_tuple) | ||||
| print "original_tuple %s" % str(original_tuple) | |||||
| print "result_tuple %s" % str(result_tuple) | |||||
| print("original_tuple %s" % str(original_tuple)) | |||||
| print("result_tuple %s" % str(result_tuple)) | |||||
| assert(tuple(result_tuple)==original_tuple) | assert(tuple(result_tuple)==original_tuple) | ||||
| print() | |||||
| original_list = [5,4,"three",2,1] | original_list = [5,4,"three",2,1] | ||||
| result_list = server.test_list(original_list) | result_list = server.test_list(original_list) | ||||
| print "original_list %s" % original_list | |||||
| print "result_list %s" % result_list | |||||
| print("original_list %s" % original_list) | |||||
| print("result_list %s" % result_list) | |||||
| assert(result_list==original_list) | assert(result_list==original_list) | ||||
| print() | |||||
| original_dictionary = { | original_dictionary = { | ||||
| 'one': 1, | 'one': 1, | ||||
| @@ -63,9 +63,9 @@ if __name__ == "__main__": | |||||
| "five": 5, | "five": 5, | ||||
| } | } | ||||
| result_dictionary = server.test_dictionary(original_dictionary) | result_dictionary = server.test_dictionary(original_dictionary) | ||||
| print "original_dictionary %s" % original_dictionary | |||||
| print "result_dictionary %s" % result_dictionary | |||||
| print("original_dictionary %s" % original_dictionary) | |||||
| print("result_dictionary %s" % result_dictionary) | |||||
| assert(result_dictionary==original_dictionary) | assert(result_dictionary==original_dictionary) | ||||
| print() | |||||
| server.quit() | server.quit() | ||||
| @@ -12,27 +12,27 @@ class test_service: | |||||
| run = 1 | run = 1 | ||||
| def test_integer(self,pass_integer): | def test_integer(self,pass_integer): | ||||
| print type(pass_integer) | |||||
| print(type(pass_integer)) | |||||
| return pass_integer | return pass_integer | ||||
| def test_string(self,pass_string): | def test_string(self,pass_string): | ||||
| print type(pass_string) | |||||
| print(type(pass_string)) | |||||
| return pass_string | return pass_string | ||||
| def test_float(self,pass_float): | def test_float(self,pass_float): | ||||
| print type(pass_float) | |||||
| print(type(pass_float)) | |||||
| return pass_float | return pass_float | ||||
| def test_tuple(self,pass_tuple): | def test_tuple(self,pass_tuple): | ||||
| print type(pass_tuple), pass_tuple | |||||
| print(type(pass_tuple), pass_tuple) | |||||
| return pass_tuple | return pass_tuple | ||||
| def test_list(self,pass_list): | def test_list(self,pass_list): | ||||
| print type(pass_list), pass_list | |||||
| print(type(pass_list), pass_list) | |||||
| return pass_list | return pass_list | ||||
| def test_dictionary(self,pass_dictionary): | def test_dictionary(self,pass_dictionary): | ||||
| print type(pass_dictionary), pass_dictionary | |||||
| print(type(pass_dictionary), pass_dictionary) | |||||
| return pass_dictionary | return pass_dictionary | ||||
| def quit(self): | def quit(self): | ||||
| @@ -22,29 +22,29 @@ else: | |||||
| big = repr('.' * (1<<18) ) | big = repr('.' * (1<<18) ) | ||||
| # ...in an object | # ...in an object | ||||
| print "server.echo_ino(big):..", | |||||
| print("server.echo_ino(big):..", end=' ') | |||||
| tmp = server.echo_ino(big) | tmp = server.echo_ino(big) | ||||
| print "done" | |||||
| print("done") | |||||
| # ...in an object in an object | # ...in an object in an object | ||||
| print "server.prop.echo2(big)..", | |||||
| print("server.prop.echo2(big)..", end=' ') | |||||
| tmp = server.prop.echo2(big) | tmp = server.prop.echo2(big) | ||||
| print "done" | |||||
| print("done") | |||||
| # ...with keyword arguments | # ...with keyword arguments | ||||
| print 'server.echo_wkw(third = big, first = "one", second = "two")..', | |||||
| print('server.echo_wkw(third = big, first = "one", second = "two")..', end=' ') | |||||
| tmp = server.echo_wkw(third = big, first = "one", second = "two") | tmp = server.echo_wkw(third = big, first = "one", second = "two") | ||||
| print "done" | |||||
| print("done") | |||||
| # ...with a context object | # ...with a context object | ||||
| print "server.echo_wc(big)..", | |||||
| print("server.echo_wc(big)..", end=' ') | |||||
| tmp = server.echo_wc(big) | tmp = server.echo_wc(big) | ||||
| print "done" | |||||
| print("done") | |||||
| # ...with a header | # ...with a header | ||||
| hd = headerType(data = {"mystring": "Hello World"}) | hd = headerType(data = {"mystring": "Hello World"}) | ||||
| print "server._hd(hd).echo_wc(big)..", | |||||
| print("server._hd(hd).echo_wc(big)..", end=' ') | |||||
| tmp = server._hd(hd).echo_wc(big) | tmp = server._hd(hd).echo_wc(big) | ||||
| print "done" | |||||
| print("done") | |||||
| server.quit() | server.quit() | ||||
| @@ -25,22 +25,22 @@ MethodNamespaceURI = 'http://tempuri.org/' | |||||
| server = SOAPProxy(SoapEndpointURL, namespace = MethodNamespaceURI, | server = SOAPProxy(SoapEndpointURL, namespace = MethodNamespaceURI, | ||||
| soapaction='http://tempuri.org/GetCNNNews', encoding = None, | soapaction='http://tempuri.org/GetCNNNews', encoding = None, | ||||
| http_proxy=proxy) | http_proxy=proxy) | ||||
| print "[server level CNN News call]" | |||||
| print server.GetCNNNews() | |||||
| print("[server level CNN News call]") | |||||
| print(server.GetCNNNews()) | |||||
| # Do it inline ala SOAP::LITE, also specify the actually ns (namespace) and | # Do it inline ala SOAP::LITE, also specify the actually ns (namespace) and | ||||
| # sa (soapaction) | # sa (soapaction) | ||||
| server = SOAPProxy(SoapEndpointURL, encoding = None) | server = SOAPProxy(SoapEndpointURL, encoding = None) | ||||
| print "[inline CNNNews call]" | |||||
| print server._ns('ns1', | |||||
| MethodNamespaceURI)._sa('http://tempuri.org/GetCNNNews').GetCNNNews() | |||||
| print("[inline CNNNews call]") | |||||
| print(server._ns('ns1', | |||||
| MethodNamespaceURI)._sa('http://tempuri.org/GetCNNNews').GetCNNNews()) | |||||
| # Create an instance of your server with specific namespace and then use | # Create an instance of your server with specific namespace and then use | ||||
| # inline soapactions for each call | # inline soapactions for each call | ||||
| dq = server._ns(MethodNamespaceURI) | dq = server._ns(MethodNamespaceURI) | ||||
| print "[namespaced CNNNews call]" | |||||
| print dq._sa('http://tempuri.org/GetCNNNews').GetCNNNews() | |||||
| print "[namespaced CBSNews call]" | |||||
| print dq._sa('http://tempuri.org/GetCBSNews').GetCBSNews() | |||||
| print("[namespaced CNNNews call]") | |||||
| print(dq._sa('http://tempuri.org/GetCNNNews').GetCNNNews()) | |||||
| print("[namespaced CBSNews call]") | |||||
| print(dq._sa('http://tempuri.org/GetCBSNews').GetCBSNews()) | |||||
| @@ -23,18 +23,18 @@ server = SOAPProxy("http://services.xmethods.com:9090/soap", | |||||
| namespace = 'urn:xmethods-delayed-quotes', | namespace = 'urn:xmethods-delayed-quotes', | ||||
| http_proxy=proxy) | http_proxy=proxy) | ||||
| print "IBM>>", server.getQuote(symbol = 'IBM') | |||||
| print("IBM>>", server.getQuote(symbol = 'IBM')) | |||||
| # Do it inline ala SOAP::LITE, also specify the actually ns | # Do it inline ala SOAP::LITE, also specify the actually ns | ||||
| server = SOAPProxy("http://services.xmethods.com:9090/soap", | server = SOAPProxy("http://services.xmethods.com:9090/soap", | ||||
| http_proxy=proxy) | http_proxy=proxy) | ||||
| print "IBM>>", server._ns('ns1', | |||||
| 'urn:xmethods-delayed-quotes').getQuote(symbol = 'IBM') | |||||
| print("IBM>>", server._ns('ns1', | |||||
| 'urn:xmethods-delayed-quotes').getQuote(symbol = 'IBM')) | |||||
| # Create a namespaced version of your server | # Create a namespaced version of your server | ||||
| dq = server._ns('urn:xmethods-delayed-quotes') | dq = server._ns('urn:xmethods-delayed-quotes') | ||||
| print "IBM>>", dq.getQuote(symbol='IBM') | |||||
| print "ORCL>>", dq.getQuote(symbol='ORCL') | |||||
| print "INTC>>", dq.getQuote(symbol='INTC') | |||||
| print("IBM>>", dq.getQuote(symbol='IBM')) | |||||
| print("ORCL>>", dq.getQuote(symbol='ORCL')) | |||||
| print("INTC>>", dq.getQuote(symbol='INTC')) | |||||
| @@ -7,4 +7,4 @@ url = 'http://www.xmethods.org/sd/2001/TemperatureService.wsdl' | |||||
| zip = '06340' | zip = '06340' | ||||
| proxy = SOAPpy.WSDL.Proxy(url) | proxy = SOAPpy.WSDL.Proxy(url) | ||||
| temp = proxy.getTemp(zip) | temp = proxy.getTemp(zip) | ||||
| print 'Temperature at', zip, 'is', temp | |||||
| print('Temperature at', zip, 'is', temp) | |||||
| @@ -71,13 +71,13 @@ def DOMParse(inxml): | |||||
| # Wierd but the SAX parser runs really slow the first time. | # Wierd but the SAX parser runs really slow the first time. | ||||
| # Probably got to load a c module or something | # Probably got to load a c module or something | ||||
| SAXParse(x) | SAXParse(x) | ||||
| print "Simple XML" | |||||
| print "SAX Parse, no marshalling ", SAXParse(x) | |||||
| print "SOAP Parse, and marshalling ", SOAPParse(x) | |||||
| print "DOM Parse, no marshalling ", DOMParse(x) | |||||
| print "Complex XML (references)" | |||||
| print "SAX Parse, no marshalling ", SAXParse(x2) | |||||
| print "SOAP Parse, and marshalling ", SOAPParse(x2) | |||||
| print "DOM Parse, no marshalling ", DOMParse(x2) | |||||
| print() | |||||
| print("Simple XML") | |||||
| print("SAX Parse, no marshalling ", SAXParse(x)) | |||||
| print("SOAP Parse, and marshalling ", SOAPParse(x)) | |||||
| print("DOM Parse, no marshalling ", DOMParse(x)) | |||||
| print() | |||||
| print("Complex XML (references)") | |||||
| print("SAX Parse, no marshalling ", SAXParse(x2)) | |||||
| print("SOAP Parse, and marshalling ", SOAPParse(x2)) | |||||
| print("DOM Parse, no marshalling ", DOMParse(x2)) | |||||
| @@ -24,15 +24,15 @@ SERIAL=1123214 | |||||
| MY_PORT=15600 | MY_PORT=15600 | ||||
| def resourceChanged (url): | def resourceChanged (url): | ||||
| print "\n##### NOTIFICATION MESSAGE: Resource %s has changed #####\n" % url | |||||
| print("\n##### NOTIFICATION MESSAGE: Resource %s has changed #####\n" % url) | |||||
| return booleanType(1) | return booleanType(1) | ||||
| def printstatus (cmd, stat): | def printstatus (cmd, stat): | ||||
| print() | |||||
| if stat.flError: | if stat.flError: | ||||
| print "### %s failed: %s ###" % (cmd, stat.message) | |||||
| print("### %s failed: %s ###" % (cmd, stat.message)) | |||||
| else: | else: | ||||
| print "### %s successful: %s ###" % (cmd, stat.message) | |||||
| print("### %s successful: %s ###" % (cmd, stat.message)) | |||||
| return not stat.flError | return not stat.flError | ||||
| server = SOAPProxy(encoding="US-ASCII", | server = SOAPProxy(encoding="US-ASCII", | ||||
| @@ -51,11 +51,11 @@ printstatus("registerUser", reg) | |||||
| # See what this server can do | # See what this server can do | ||||
| reg = server.getServerCapabilities (email=EMAIL, password=PASSWORD) | reg = server.getServerCapabilities (email=EMAIL, password=PASSWORD) | ||||
| if printstatus("getServerCapabilities", reg): | if printstatus("getServerCapabilities", reg): | ||||
| print "Legal file extensions: " + str(reg.legalFileExtensions) | |||||
| print "Maximum file size: " + str(reg.maxFileSize) | |||||
| print "Maximum bytes per user: " + str(reg.maxBytesPerUser) | |||||
| print "Number of bytes in use by the indicated user: " + str(reg.ctBytesInUse) | |||||
| print "URL of the folder containing your files: " + str(reg.yourUpstreamFolderUrl) | |||||
| print("Legal file extensions: " + str(reg.legalFileExtensions)) | |||||
| print("Maximum file size: " + str(reg.maxFileSize)) | |||||
| print("Maximum bytes per user: " + str(reg.maxBytesPerUser)) | |||||
| print("Number of bytes in use by the indicated user: " + str(reg.ctBytesInUse)) | |||||
| print("URL of the folder containing your files: " + str(reg.yourUpstreamFolderUrl)) | |||||
| # Store some files | # Store some files | ||||
| reg = server.saveMultipleFiles (email=EMAIL, password=PASSWORD, | reg = server.saveMultipleFiles (email=EMAIL, password=PASSWORD, | ||||
| @@ -65,9 +65,9 @@ reg = server.saveMultipleFiles (email=EMAIL, password=PASSWORD, | |||||
| '<html><title>bennett@actzero.com home page</title><body>' + | '<html><title>bennett@actzero.com home page</title><body>' + | ||||
| '<a href=index.html>Hello Earth Again</a></body></html>']) | '<a href=index.html>Hello Earth Again</a></body></html>']) | ||||
| if printstatus("saveMultipleFiles", reg): | if printstatus("saveMultipleFiles", reg): | ||||
| print "Files stored:" | |||||
| print("Files stored:") | |||||
| for file in reg.urlList: | for file in reg.urlList: | ||||
| print " %s" % file | |||||
| print(" %s" % file) | |||||
| # Save this for call to test pleaseNotify | # Save this for call to test pleaseNotify | ||||
| mylist = reg.urlList | mylist = reg.urlList | ||||
| @@ -80,12 +80,12 @@ if printstatus("getMyDirectory", reg): | |||||
| i = 1 | i = 1 | ||||
| while hasattr(reg.directory, "file%05d" % i): | while hasattr(reg.directory, "file%05d" % i): | ||||
| d = getattr(reg.directory, "file%05d" % i) | d = getattr(reg.directory, "file%05d" % i) | ||||
| print "Relative Path: %s" % d.relativePath | |||||
| print "Size: %d" % d.size | |||||
| print "Created: %s" % d.whenCreated | |||||
| print "Last Uploaded: %s" % d.whenLastUploaded | |||||
| print "URL: %s" % d.url | |||||
| print("Relative Path: %s" % d.relativePath) | |||||
| print("Size: %d" % d.size) | |||||
| print("Created: %s" % d.whenCreated) | |||||
| print("Last Uploaded: %s" % d.whenLastUploaded) | |||||
| print("URL: %s" % d.url) | |||||
| print() | |||||
| i += 1 | i += 1 | ||||
| # Set up notification | # Set up notification | ||||
| @@ -95,8 +95,8 @@ printstatus("notifyProcedure", reg) | |||||
| pid = os.fork() | pid = os.fork() | ||||
| if pid == 0: | if pid == 0: | ||||
| # I am a child process. Set up SOAP server to receive notification | # I am a child process. Set up SOAP server to receive notification | ||||
| print "## Starting notification server ##" | |||||
| print() | |||||
| print("## Starting notification server ##") | |||||
| s = SOAPServer(('localhost', MY_PORT)) | s = SOAPServer(('localhost', MY_PORT)) | ||||
| s.registerFunction(resourceChanged) | s.registerFunction(resourceChanged) | ||||
| @@ -106,7 +106,7 @@ else: | |||||
| def handler(signum, frame): | def handler(signum, frame): | ||||
| # Kill child process | # Kill child process | ||||
| print "Killing child process %d" % pid | |||||
| print("Killing child process %d" % pid) | |||||
| os.kill(pid, signal.SIGINT) | os.kill(pid, signal.SIGINT) | ||||
| signal.signal(signal.SIGINT, handler) | signal.signal(signal.SIGINT, handler) | ||||
| @@ -119,8 +119,8 @@ else: | |||||
| fileTextList=['<html><title>bennett@actzero.com home page</title><body>' + | fileTextList=['<html><title>bennett@actzero.com home page</title><body>' + | ||||
| '<a href=again.html>Hello Bennett</a></body></html>']) | '<a href=again.html>Hello Bennett</a></body></html>']) | ||||
| if printstatus("saveMultipleFiles", reg): | if printstatus("saveMultipleFiles", reg): | ||||
| print "Files stored:" | |||||
| print("Files stored:") | |||||
| for file in reg.urlList: | for file in reg.urlList: | ||||
| print " %s" % file | |||||
| print(" %s" % file) | |||||
| os.waitpid(pid, 0) | os.waitpid(pid, 0) | ||||
| @@ -27,18 +27,18 @@ def kill(): | |||||
| def server1(): | def server1(): | ||||
| """start a SOAP server on localhost:8000""" | """start a SOAP server on localhost:8000""" | ||||
| print "Starting SOAP Server...", | |||||
| print("Starting SOAP Server...", end=' ') | |||||
| server = SOAPpy.Server.SOAPServer(addr=('127.0.0.1', 8000)) | server = SOAPpy.Server.SOAPServer(addr=('127.0.0.1', 8000)) | ||||
| server.registerFunction(echoDateTime) | server.registerFunction(echoDateTime) | ||||
| server.registerFunction(echo) | server.registerFunction(echo) | ||||
| server.registerFunction(kill) | server.registerFunction(kill) | ||||
| print "Done." | |||||
| print("Done.") | |||||
| global quit | global quit | ||||
| while not quit: | while not quit: | ||||
| server.handle_request() | server.handle_request() | ||||
| quit = 0 | quit = 0 | ||||
| print "Server shut down." | |||||
| print("Server shut down.") | |||||
| class ClientTestCase(unittest.TestCase): | class ClientTestCase(unittest.TestCase): | ||||
| @@ -55,24 +55,24 @@ class ClientTestCase(unittest.TestCase): | |||||
| connected = False | connected = False | ||||
| server = None | server = None | ||||
| while not connected and time.time() - start < self.startup_timeout: | while not connected and time.time() - start < self.startup_timeout: | ||||
| print "Trying to connect to the SOAP server...", | |||||
| print("Trying to connect to the SOAP server...", end=' ') | |||||
| try: | try: | ||||
| server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | ||||
| server.echo('Hello World') | server.echo('Hello World') | ||||
| except socket.error, e: | |||||
| print "Failure:", e | |||||
| except socket.error as e: | |||||
| print("Failure:", e) | |||||
| time.sleep(0.5) | time.sleep(0.5) | ||||
| else: | else: | ||||
| connected = True | connected = True | ||||
| self.server = server | self.server = server | ||||
| print "Success." | |||||
| print("Success.") | |||||
| if not connected: raise 'Server failed to start.' | if not connected: raise 'Server failed to start.' | ||||
| def tearDown(self): | def tearDown(self): | ||||
| '''This is run once after each unit test.''' | '''This is run once after each unit test.''' | ||||
| print "Trying to shut down SOAP server..." | |||||
| print("Trying to shut down SOAP server...") | |||||
| if self.server is not None: | if self.server is not None: | ||||
| self.server.kill() | self.server.kill() | ||||
| time.sleep(5) | time.sleep(5) | ||||
| @@ -84,14 +84,14 @@ class ClientTestCase(unittest.TestCase): | |||||
| server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | ||||
| s = 'Hello World' | s = 'Hello World' | ||||
| self.assertEquals(server.echo(s), s+s) | |||||
| self.assertEqual(server.echo(s), s+s) | |||||
| def testNamedEcho(self): | def testNamedEcho(self): | ||||
| '''Test echo function.''' | '''Test echo function.''' | ||||
| server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | ||||
| s = 'Hello World' | s = 'Hello World' | ||||
| self.assertEquals(server.echo(s=s), s+s) | |||||
| self.assertEqual(server.echo(s=s), s+s) | |||||
| def testEchoDateTime(self): | def testEchoDateTime(self): | ||||
| '''Test passing DateTime objects.''' | '''Test passing DateTime objects.''' | ||||
| @@ -99,7 +99,7 @@ class ClientTestCase(unittest.TestCase): | |||||
| server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | server = SOAPpy.Client.SOAPProxy('127.0.0.1:8000') | ||||
| dt = SOAPpy.Types.dateTimeType(data=time.time()) | dt = SOAPpy.Types.dateTimeType(data=time.time()) | ||||
| dt_return = server.echoDateTime(dt) | dt_return = server.echoDateTime(dt) | ||||
| self.assertEquals(dt_return, dt) | |||||
| self.assertEqual(dt_return, dt) | |||||
| # def testNoLeak(self): | # def testNoLeak(self): | ||||
| @@ -60,11 +60,11 @@ class IntegerArithmenticTestCase(unittest.TestCase): | |||||
| '''Parse XMethods TemperatureService wsdl from a string.''' | '''Parse XMethods TemperatureService wsdl from a string.''' | ||||
| wsdl = SOAPpy.WSDL.Proxy(self.wsdlstr1, http_proxy=http_proxy) | wsdl = SOAPpy.WSDL.Proxy(self.wsdlstr1, http_proxy=http_proxy) | ||||
| self.assertEquals(len(wsdl.methods), 1) | |||||
| method = wsdl.methods.values()[0] | |||||
| self.assertEquals(method.methodName, 'getTemp') | |||||
| self.assertEquals(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEquals(method.location, | |||||
| self.assertEqual(len(wsdl.methods), 1) | |||||
| method = list(wsdl.methods.values())[0] | |||||
| self.assertEqual(method.methodName, 'getTemp') | |||||
| self.assertEqual(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEqual(method.location, | |||||
| 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | ||||
| def testParseWsdlFile(self): | def testParseWsdlFile(self): | ||||
| @@ -77,25 +77,25 @@ class IntegerArithmenticTestCase(unittest.TestCase): | |||||
| try: | try: | ||||
| f = file(fname) | f = file(fname) | ||||
| except (IOError, OSError): | except (IOError, OSError): | ||||
| self.assert_(0, 'Cound not find wsdl file "%s"' % file) | |||||
| self.assertTrue(0, 'Cound not find wsdl file "%s"' % file) | |||||
| wsdl = SOAPpy.WSDL.Proxy(fname, http_proxy=http_proxy) | wsdl = SOAPpy.WSDL.Proxy(fname, http_proxy=http_proxy) | ||||
| self.assertEquals(len(wsdl.methods), 1) | |||||
| method = wsdl.methods.values()[0] | |||||
| self.assertEquals(method.methodName, 'getTemp') | |||||
| self.assertEquals(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEquals(method.location, | |||||
| self.assertEqual(len(wsdl.methods), 1) | |||||
| method = list(wsdl.methods.values())[0] | |||||
| self.assertEqual(method.methodName, 'getTemp') | |||||
| self.assertEqual(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEqual(method.location, | |||||
| 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | ||||
| def testParseWsdlUrl(self): | def testParseWsdlUrl(self): | ||||
| '''Parse XMethods TemperatureService wsdl from a url.''' | '''Parse XMethods TemperatureService wsdl from a url.''' | ||||
| wsdl = SOAPpy.WSDL.Proxy('http://www.xmethods.net/sd/2001/TemperatureService.wsdl', http_proxy=http_proxy) | wsdl = SOAPpy.WSDL.Proxy('http://www.xmethods.net/sd/2001/TemperatureService.wsdl', http_proxy=http_proxy) | ||||
| self.assertEquals(len(wsdl.methods), 1) | |||||
| method = wsdl.methods.values()[0] | |||||
| self.assertEquals(method.methodName, 'getTemp') | |||||
| self.assertEquals(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEquals(method.location, | |||||
| self.assertEqual(len(wsdl.methods), 1) | |||||
| method = list(wsdl.methods.values())[0] | |||||
| self.assertEqual(method.methodName, 'getTemp') | |||||
| self.assertEqual(method.namespace, 'urn:xmethods-Temperature') | |||||
| self.assertEqual(method.location, | |||||
| 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | 'http://services.xmethods.net:80/soap/servlet/rpcrouter') | ||||
| def testGetTemp(self): | def testGetTemp(self): | ||||
| @@ -104,7 +104,7 @@ class IntegerArithmenticTestCase(unittest.TestCase): | |||||
| zip = '01072' | zip = '01072' | ||||
| proxy = SOAPpy.WSDL.Proxy(self.wsdlstr1, http_proxy=http_proxy) | proxy = SOAPpy.WSDL.Proxy(self.wsdlstr1, http_proxy=http_proxy) | ||||
| temp = proxy.getTemp(zip) | temp = proxy.getTemp(zip) | ||||
| print 'Temperature at', zip, 'is', temp | |||||
| print('Temperature at', zip, 'is', temp) | |||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| @@ -16,6 +16,6 @@ for i in range(400): | |||||
| gc.collect() | gc.collect() | ||||
| if len(gc.garbage): | if len(gc.garbage): | ||||
| print 'still leaking' | |||||
| print('still leaking') | |||||
| else: | else: | ||||
| print 'no leak' | |||||
| print('no leak') | |||||
| @@ -6,6 +6,6 @@ __docformat__ = 'restructuredtext en' | |||||
| from SOAPpy import SOAPProxy | from SOAPpy import SOAPProxy | ||||
| server = SOAPProxy("http://localhost:8080/") | server = SOAPProxy("http://localhost:8080/") | ||||
| print server.echo("Hello world") | |||||
| print(server.echo("Hello world")) | |||||
| # vim:set et sts=4 ts=4 tw=80: | # vim:set et sts=4 ts=4 tw=80: | ||||
| @@ -21,5 +21,5 @@ server = SOAPProxy("http://services.xmethods.com:80/perl/soaplite.cgi", | |||||
| http_proxy=proxy) | http_proxy=proxy) | ||||
| babel = server._ns('urn:xmethodsBabelFish#BabelFish') | babel = server._ns('urn:xmethodsBabelFish#BabelFish') | ||||
| print babel.BabelFish(translationmode = "en_fr", | |||||
| sourcedata = "The quick brown fox did something or other") | |||||
| print(babel.BabelFish(translationmode = "en_fr", | |||||
| sourcedata = "The quick brown fox did something or other")) | |||||
| @@ -22,4 +22,4 @@ MethodNamespaceURI = 'urn:xmethods-Temperature' | |||||
| # Do it inline ala SOAP::LITE, also specify the actually ns | # Do it inline ala SOAP::LITE, also specify the actually ns | ||||
| server = SOAPProxy(SoapEndpointURL, http_proxy=proxy) | server = SOAPProxy(SoapEndpointURL, http_proxy=proxy) | ||||
| print "inline", server._ns('ns1', MethodNamespaceURI).getTemp(zipcode='94063') | |||||
| print("inline", server._ns('ns1', MethodNamespaceURI).getTemp(zipcode='94063')) | |||||
| @@ -19,7 +19,7 @@ except: | |||||
| server = SOAPProxy("http://www.SoapClient.com/xml/SQLDataSoap.WSDL", | server = SOAPProxy("http://www.SoapClient.com/xml/SQLDataSoap.WSDL", | ||||
| http_proxy=proxy) | http_proxy=proxy) | ||||
| print "whois>>", server.ProcessSRL(SRLFile="WHOIS.SRI", | |||||
| print("whois>>", server.ProcessSRL(SRLFile="WHOIS.SRI", | |||||
| RequestName="whois", | RequestName="whois", | ||||
| key = "microsoft.com") | |||||
| key = "microsoft.com")) | |||||
| @@ -18,9 +18,9 @@ except: | |||||
| proxy = None | proxy = None | ||||
| print "##########################################" | |||||
| print " SOAP services registered at xmethods.net" | |||||
| print "##########################################" | |||||
| print("##########################################") | |||||
| print(" SOAP services registered at xmethods.net") | |||||
| print("##########################################") | |||||
| server = SOAPProxy("http://www.xmethods.net/interfaces/query", | server = SOAPProxy("http://www.xmethods.net/interfaces/query", | ||||
| namespace = 'urn:xmethods-delayed-quotes', | namespace = 'urn:xmethods-delayed-quotes', | ||||
| @@ -29,6 +29,6 @@ server = SOAPProxy("http://www.xmethods.net/interfaces/query", | |||||
| names = server.getAllServiceNames() | names = server.getAllServiceNames() | ||||
| for item in names: | for item in names: | ||||
| print 'name:', item['name'] | |||||
| print 'id :', item['id'] | |||||
| print('name:', item['name']) | |||||
| print('id :', item['id']) | |||||
| print() | |||||
| @@ -24,35 +24,35 @@ for line in lines: | |||||
| try: table[row[0]].append([restofrow[0],restofrow[2:]]) | try: table[row[0]].append([restofrow[0],restofrow[2:]]) | ||||
| except KeyError: table[row[0]] = [[restofrow[0],restofrow[2:]]] | except KeyError: table[row[0]] = [[restofrow[0],restofrow[2:]]] | ||||
| print "<html><body>" | |||||
| print "<script>function popup(text) {" | |||||
| print "text = '<html><head><title>Test Detail</title></head><body><p>' + text + '</p></body></html>';" | |||||
| print "newWin=window.open('','win1','location=no,menubar=no,width=400,height=200');" | |||||
| print "newWin.document.open();" | |||||
| print "newWin.document.write(text);" | |||||
| print "newWin.focus(); } </script>" | |||||
| print "<br><table style='font-family: Arial; color: #cccccc'><tr><td colspan=2><font face=arial color=#cccccc><b>Summary</b></font></td></tr>" | |||||
| print("<html><body>") | |||||
| print("<script>function popup(text) {") | |||||
| print("text = '<html><head><title>Test Detail</title></head><body><p>' + text + '</p></body></html>';") | |||||
| print("newWin=window.open('','win1','location=no,menubar=no,width=400,height=200');") | |||||
| print("newWin.document.open();") | |||||
| print("newWin.document.write(text);") | |||||
| print("newWin.focus(); } </script>") | |||||
| print("<br><table style='font-family: Arial; color: #cccccc'><tr><td colspan=2><font face=arial color=#cccccc><b>Summary</b></font></td></tr>") | |||||
| for x in tally: | for x in tally: | ||||
| z = x[:-1].split(":",1) | z = x[:-1].split(":",1) | ||||
| print "<tr><td><font face=arial color=#cccccc>",z[0],"</font></td><td><font face=arial color=#cccccc>",z[1],"</font></td></tr>" | |||||
| print "</table><br>" | |||||
| print("<tr><td><font face=arial color=#cccccc>",z[0],"</font></td><td><font face=arial color=#cccccc>",z[1],"</font></td></tr>") | |||||
| print("</table><br>") | |||||
| c = 0 | c = 0 | ||||
| totalmethods = len(table[table.keys()[0]]) | |||||
| totalmethods = len(table[list(table.keys())[0]]) | |||||
| while c < totalmethods: | while c < totalmethods: | ||||
| print "<br><table width='95%' style='font-family: Arial'>" | |||||
| print "<tr><td width='27%' bgcolor='#cccccc'></td>" | |||||
| print("<br><table width='95%' style='font-family: Arial'>") | |||||
| print("<tr><td width='27%' bgcolor='#cccccc'></td>") | |||||
| cols = [c, c + 1, c + 2] | cols = [c, c + 1, c + 2] | ||||
| if c != 16: | if c != 16: | ||||
| cols += [c + 3] | cols += [c + 3] | ||||
| for i in cols: | for i in cols: | ||||
| try: header = table[table.keys()[0]][i][0] | |||||
| try: header = table[list(table.keys())[0]][i][0] | |||||
| except: break | except: break | ||||
| print "<td width ='17%' align='center' bgcolor='#cccccc'><b>",header,"</b></td>" | |||||
| print "</tr>" | |||||
| l = table.keys() | |||||
| print("<td width ='17%' align='center' bgcolor='#cccccc'><b>",header,"</b></td>") | |||||
| print("</tr>") | |||||
| l = list(table.keys()) | |||||
| l.sort() | l.sort() | ||||
| for key in l: | for key in l: | ||||
| print "<tr><td bgcolor='#cccccc'>", key , "</td>" | |||||
| print("<tr><td bgcolor='#cccccc'>", key , "</td>") | |||||
| for i in cols: | for i in cols: | ||||
| try: status = table[key][i][1][0] | try: status = table[key][i][1][0] | ||||
| except: break | except: break | ||||
| @@ -69,8 +69,8 @@ while c < totalmethods: | |||||
| hreftitle = table[key][i][1][1].replace("'","") # remove apostrophes from title properties | hreftitle = table[key][i][1][1].replace("'","") # remove apostrophes from title properties | ||||
| popuphtml = '"' + cgi.escape(cgi.escape(table[key][i][1][1]).replace("'","'").replace('"',""")) + '"' | popuphtml = '"' + cgi.escape(cgi.escape(table[key][i][1][1]).replace("'","'").replace('"',""")) + '"' | ||||
| status = "<a title='" + hreftitle + "' href='javascript:popup(" + popuphtml + ")'>Failed</a>" | status = "<a title='" + hreftitle + "' href='javascript:popup(" + popuphtml + ")'>Failed</a>" | ||||
| print "<td align='center' bgcolor=" , bgcolor , ">" , status , "</td>" | |||||
| print "</tr>" | |||||
| print "</table>" | |||||
| print("<td align='center' bgcolor=" , bgcolor , ">" , status , "</td>") | |||||
| print("</tr>") | |||||
| print("</table>") | |||||
| c = c + len(cols) | c = c + len(cols) | ||||
| print "</body></html>" | |||||
| print("</body></html>") | |||||
| @@ -45,9 +45,9 @@ def usage (error = None): | |||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| if error != None: | if error != None: | ||||
| print error | |||||
| print(error) | |||||
| print """usage: %s [options] [server ...] | |||||
| print("""usage: %s [options] [server ...] | |||||
| If a long option shows an argument is mandatory, it's mandatory for the | If a long option shows an argument is mandatory, it's mandatory for the | ||||
| equivalent short option also. | equivalent short option also. | ||||
| @@ -75,7 +75,7 @@ def usage (error = None): | |||||
| -t, --stacktrace print a stack trace on each unexpected failure | -t, --stacktrace print a stack trace on each unexpected failure | ||||
| -T, --always-stacktrace | -T, --always-stacktrace | ||||
| print a stack trace on any failure | print a stack trace on any failure | ||||
| """ % (sys.argv[0], DEFAULT_SERVERS_FILE), | |||||
| """ % (sys.argv[0], DEFAULT_SERVERS_FILE), end=' ') | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -83,19 +83,19 @@ def usage (error = None): | |||||
| def methodUsage (): | def methodUsage (): | ||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| print "Methods are specified by number. Multiple methods can be " \ | |||||
| print("Methods are specified by number. Multiple methods can be " \ | |||||
| "specified using a\ncomma-separated list of numbers or ranges. " \ | "specified using a\ncomma-separated list of numbers or ranges. " \ | ||||
| "For example 1,4-6,8 specifies\nmethods 1, 4, 5, 6, and 8.\n" | |||||
| "For example 1,4-6,8 specifies\nmethods 1, 4, 5, 6, and 8.\n") | |||||
| print "The available methods are:\n" | |||||
| print("The available methods are:\n") | |||||
| half = (len (DEFAULT_METHODS) + 1) / 2 | half = (len (DEFAULT_METHODS) + 1) / 2 | ||||
| for i in range (half): | for i in range (half): | ||||
| print "%4d. %-25s" % (i + 1, DEFAULT_METHODS[i]), | |||||
| print("%4d. %-25s" % (i + 1, DEFAULT_METHODS[i]), end=' ') | |||||
| if i + half < len (DEFAULT_METHODS): | if i + half < len (DEFAULT_METHODS): | ||||
| print "%4d. %-25s" % (i + 1 + half, DEFAULT_METHODS[i + half]), | |||||
| print("%4d. %-25s" % (i + 1 + half, DEFAULT_METHODS[i + half]), end=' ') | |||||
| print() | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -132,9 +132,8 @@ def readServers (file): | |||||
| value = cur[tag] | value = cur[tag] | ||||
| value += ' ' + line.strip () | value += ' ' + line.strip () | ||||
| elif line[0] == '_': | elif line[0] == '_': | ||||
| raise ValueError, \ | |||||
| "%s, line %d: can't have a tag starting with `_'" % \ | |||||
| (f.filename(), f.filelineno()) | |||||
| raise ValueError("%s, line %d: can't have a tag starting with `_'" % \ | |||||
| (f.filename(), f.filelineno())) | |||||
| else: | else: | ||||
| tag, value = line.split (':', 1) | tag, value = line.split (':', 1) | ||||
| @@ -150,18 +149,16 @@ def readServers (file): | |||||
| elif value.lower() in ('1', 'yes', 'false'): | elif value.lower() in ('1', 'yes', 'false'): | ||||
| value = 1 | value = 1 | ||||
| else: | else: | ||||
| raise ValueError, \ | |||||
| "%s, line %d: unknown typed value `%s'" % \ | |||||
| (f.filename(), f.filelineno(), value) | |||||
| raise ValueError("%s, line %d: unknown typed value `%s'" % \ | |||||
| (f.filename(), f.filelineno(), value)) | |||||
| elif tag == 'name': | elif tag == 'name': | ||||
| if names.has_key(value): | |||||
| if value in names: | |||||
| old = names[value] | old = names[value] | ||||
| raise ValueError, \ | |||||
| "%s, line %d: already saw a server named `%s' " \ | |||||
| raise ValueError("%s, line %d: already saw a server named `%s' " \ | |||||
| "(on line %d of %s)" % \ | "(on line %d of %s)" % \ | ||||
| (f.filename(), f.filelineno(), value, | (f.filename(), f.filelineno(), value, | ||||
| old['_line'], old['_file']) | |||||
| old['_line'], old['_file'])) | |||||
| names[value] = cur | names[value] = cur | ||||
| if tag == 'nonfunctional': | if tag == 'nonfunctional': | ||||
| @@ -173,16 +170,14 @@ def readServers (file): | |||||
| try: | try: | ||||
| del cur['nonfunctional'][value] | del cur['nonfunctional'][value] | ||||
| except: | except: | ||||
| raise ValueError, \ | |||||
| "%s, line %d: `%s' not marked nonfunctional" % \ | |||||
| (f.filename(), f.filelineno(), value) | |||||
| raise ValueError("%s, line %d: `%s' not marked nonfunctional" % \ | |||||
| (f.filename(), f.filelineno(), value)) | |||||
| elif tag == 'like': | elif tag == 'like': | ||||
| try: | try: | ||||
| new = copy.deepcopy(names[value]) | new = copy.deepcopy(names[value]) | ||||
| except: | except: | ||||
| raise ValueError, \ | |||||
| "%s, line %d: don't know about a server named `%s'" % \ | |||||
| (f.filename(), f.filelineno(), value) | |||||
| raise ValueError("%s, line %d: don't know about a server named `%s'" % \ | |||||
| (f.filename(), f.filelineno(), value)) | |||||
| # This is so we don't lose the nonfunctional methods in new or | # This is so we don't lose the nonfunctional methods in new or | ||||
| # in cur | # in cur | ||||
| @@ -213,7 +208,7 @@ def str2list (s): | |||||
| else: | else: | ||||
| l[int (i)] = 1 | l[int (i)] = 1 | ||||
| l = l.keys () | |||||
| l = list(l.keys ()) | |||||
| l.sort () | l.sort () | ||||
| return l | return l | ||||
| @@ -235,7 +230,7 @@ def testActorShouldPass (server, action, harsh): | |||||
| result = int (result) | result = int (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %s, got %s" % (test, result) | |||||
| raise Exception("expected %s, got %s" % (test, result)) | |||||
| def testActorShouldFail (server, action, harsh): | def testActorShouldFail (server, action, harsh): | ||||
| test = 42 | test = 42 | ||||
| @@ -250,12 +245,12 @@ def testActorShouldFail (server, action, harsh): | |||||
| try: | try: | ||||
| result = server.echoInteger (inputInteger = test) | result = server.echoInteger (inputInteger = test) | ||||
| except SOAP.faultType, e: | |||||
| except SOAP.faultType as e: | |||||
| if harsh and e.faultcode != 'SOAP-ENV:MustUnderstand': | if harsh and e.faultcode != 'SOAP-ENV:MustUnderstand': | ||||
| raise AttributeError, "unexpected faultcode %s" % e.faultcode | |||||
| raise AttributeError("unexpected faultcode %s" % e.faultcode) | |||||
| return | return | ||||
| raise Exception, "should fail, succeeded with %s" % result | |||||
| raise Exception("should fail, succeeded with %s" % result) | |||||
| def testEchoFloat (server, action, harsh): | def testEchoFloat (server, action, harsh): | ||||
| server = server._sa (action % {'methodname': 'echoFloat'}) | server = server._sa (action % {'methodname': 'echoFloat'}) | ||||
| @@ -267,7 +262,7 @@ def testEchoFloat (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if not nearlyeq (result, test): | if not nearlyeq (result, test): | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoFloatArray (server, action, harsh): | def testEchoFloatArray (server, action, harsh): | ||||
| test = [0.0, 1.0, -1.0, 3853.33333333] | test = [0.0, 1.0, -1.0, 3853.33333333] | ||||
| @@ -279,8 +274,8 @@ def testEchoFloatArray (server, action, harsh): | |||||
| result[i] = float (result[i]) | result[i] = float (result[i]) | ||||
| if not nearlyeq (result[i], test[i]): | if not nearlyeq (result[i], test[i]): | ||||
| raise Exception, "@ %d expected %s, got %s" % \ | |||||
| (i, repr (test), repr (result)) | |||||
| raise Exception("@ %d expected %s, got %s" % \ | |||||
| (i, repr (test), repr (result))) | |||||
| def testEchoFloatINF (server, action, harsh): | def testEchoFloatINF (server, action, harsh): | ||||
| try: | try: | ||||
| @@ -294,7 +289,7 @@ def testEchoFloatINF (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoFloatNaN (server, action, harsh): | def testEchoFloatNaN (server, action, harsh): | ||||
| try: | try: | ||||
| @@ -308,7 +303,7 @@ def testEchoFloatNaN (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoFloatNegINF (server, action, harsh): | def testEchoFloatNegINF (server, action, harsh): | ||||
| try: | try: | ||||
| @@ -323,7 +318,7 @@ def testEchoFloatNegINF (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoFloatNegZero (server, action, harsh): | def testEchoFloatNegZero (server, action, harsh): | ||||
| test = float ('-0.0') | test = float ('-0.0') | ||||
| @@ -334,7 +329,7 @@ def testEchoFloatNegZero (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoInteger (server, action, harsh): | def testEchoInteger (server, action, harsh): | ||||
| server = server._sa (action % {'methodname': 'echoInteger'}) | server = server._sa (action % {'methodname': 'echoInteger'}) | ||||
| @@ -346,7 +341,7 @@ def testEchoInteger (server, action, harsh): | |||||
| result = int (result) | result = int (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %.8f, got %.8f" % (test, result) | |||||
| raise Exception("expected %.8f, got %.8f" % (test, result)) | |||||
| def testEchoIntegerArray (server, action, harsh): | def testEchoIntegerArray (server, action, harsh): | ||||
| test = [0, 1, -1, 3853] | test = [0, 1, -1, 3853] | ||||
| @@ -358,14 +353,14 @@ def testEchoIntegerArray (server, action, harsh): | |||||
| result[i] = int (result[i]) | result[i] = int (result[i]) | ||||
| if result[i] != test[i]: | if result[i] != test[i]: | ||||
| raise Exception, "@ %d expected %s, got %s" % \ | |||||
| (i, repr (test), repr (result)) | |||||
| raise Exception("@ %d expected %s, got %s" % \ | |||||
| (i, repr (test), repr (result))) | |||||
| relaxedStringTests = ['', 'Hello', '\'<&>"',] | relaxedStringTests = ['', 'Hello', '\'<&>"',] | ||||
| relaxedStringTests = ['Hello', '\'<&>"',] | relaxedStringTests = ['Hello', '\'<&>"',] | ||||
| harshStringTests = ['', 'Hello', '\'<&>"', | harshStringTests = ['', 'Hello', '\'<&>"', | ||||
| u'\u0041', u'\u00a2', u'\u0141', u'\u2342', | |||||
| u'\'<\u0041&>"', u'\'<\u00a2&>"', u'\'<\u0141&>"', u'\'<\u2342&>"',] | |||||
| '\u0041', '\u00a2', '\u0141', '\u2342', | |||||
| '\'<\u0041&>"', '\'<\u00a2&>"', '\'<\u0141&>"', '\'<\u2342&>"',] | |||||
| def testEchoString (server, action, harsh): | def testEchoString (server, action, harsh): | ||||
| if harsh: | if harsh: | ||||
| @@ -378,8 +373,8 @@ def testEchoString (server, action, harsh): | |||||
| result = server.echoString (inputString = test) | result = server.echoString (inputString = test) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %s, got %s" % \ | |||||
| (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % \ | |||||
| (repr (test), repr (result))) | |||||
| def testEchoStringArray (server, action, harsh): | def testEchoStringArray (server, action, harsh): | ||||
| if harsh: | if harsh: | ||||
| @@ -390,7 +385,7 @@ def testEchoStringArray (server, action, harsh): | |||||
| result = server.echoStringArray (inputStringArray = test) | result = server.echoStringArray (inputStringArray = test) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %s, got %s" % (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % (repr (test), repr (result))) | |||||
| def testEchoStruct (server, action, harsh): | def testEchoStruct (server, action, harsh): | ||||
| test = {'varFloat': 2.256, 'varInt': 474, 'varString': 'Utah'} | test = {'varFloat': 2.256, 'varInt': 474, 'varString': 'Utah'} | ||||
| @@ -402,16 +397,16 @@ def testEchoStruct (server, action, harsh): | |||||
| result.varInt = int (result.varInt) | result.varInt = int (result.varInt) | ||||
| if not nearlyeq (test['varFloat'], result.varFloat): | if not nearlyeq (test['varFloat'], result.varFloat): | ||||
| raise Exception, ".varFloat expected %s, got %s" % \ | |||||
| (i, repr (test['varFloat']), repr (result.varFloat)) | |||||
| raise Exception(".varFloat expected %s, got %s" % \ | |||||
| (i, repr (test['varFloat']), repr (result.varFloat))) | |||||
| for i in test.keys (): | |||||
| for i in list(test.keys ()): | |||||
| if i == 'varFloat': | if i == 'varFloat': | ||||
| continue | continue | ||||
| if test[i] != getattr (result, i): | if test[i] != getattr (result, i): | ||||
| raise Exception, ".%s expected %s, got %s" % \ | |||||
| (i, repr (test[i]), repr (getattr (result, i))) | |||||
| raise Exception(".%s expected %s, got %s" % \ | |||||
| (i, repr (test[i]), repr (getattr (result, i)))) | |||||
| def testEchoStructArray (server, action, harsh): | def testEchoStructArray (server, action, harsh): | ||||
| @@ -427,17 +422,16 @@ def testEchoStructArray (server, action, harsh): | |||||
| result[s].varInt = int (result[s].varInt) | result[s].varInt = int (result[s].varInt) | ||||
| if not nearlyeq (test[s]['varFloat'], result[s].varFloat): | if not nearlyeq (test[s]['varFloat'], result[s].varFloat): | ||||
| raise Exception, \ | |||||
| "@ %d.varFloat expected %s, got %s" % \ | |||||
| (s, repr (test[s]['varFloat']), repr (result[s].varFloat)) | |||||
| raise Exception("@ %d.varFloat expected %s, got %s" % \ | |||||
| (s, repr (test[s]['varFloat']), repr (result[s].varFloat))) | |||||
| for i in test[s].keys (): | |||||
| for i in list(test[s].keys ()): | |||||
| if i == 'varFloat': | if i == 'varFloat': | ||||
| continue | continue | ||||
| if test[s][i] != getattr (result[s], i): | if test[s][i] != getattr (result[s], i): | ||||
| raise Exception, "@ %d.%s expected %s, got %s" % \ | |||||
| (s, i, repr (test[s][i]), repr (getattr (result[s], i))) | |||||
| raise Exception("@ %d.%s expected %s, got %s" % \ | |||||
| (s, i, repr (test[s][i]), repr (getattr (result[s], i)))) | |||||
| def testEchoVeryLargeFloat (server, action, harsh): | def testEchoVeryLargeFloat (server, action, harsh): | ||||
| test = 2.2535e29 | test = 2.2535e29 | ||||
| @@ -448,7 +442,7 @@ def testEchoVeryLargeFloat (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if not nearlyeq (result, test): | if not nearlyeq (result, test): | ||||
| raise Exception, "expected %s, got %s" % (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % (repr (test), repr (result))) | |||||
| def testEchoVerySmallFloat (server, action, harsh): | def testEchoVerySmallFloat (server, action, harsh): | ||||
| test = 2.2535e29 | test = 2.2535e29 | ||||
| @@ -459,16 +453,16 @@ def testEchoVerySmallFloat (server, action, harsh): | |||||
| result = float (result) | result = float (result) | ||||
| if not nearlyeq (result, test): | if not nearlyeq (result, test): | ||||
| raise Exception, "expected %s, got %s" % (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % (repr (test), repr (result))) | |||||
| def testEchoVoid (server, action, harsh): | def testEchoVoid (server, action, harsh): | ||||
| server = server._sa (action % {'methodname': 'echoVoid'}) | server = server._sa (action % {'methodname': 'echoVoid'}) | ||||
| result = server.echoVoid () | result = server.echoVoid () | ||||
| for k in result.__dict__.keys (): | |||||
| for k in list(result.__dict__.keys ()): | |||||
| if k[0] != '_': | if k[0] != '_': | ||||
| raise Exception, "expected an empty structType, got %s" % \ | |||||
| repr (result.__dict__) | |||||
| raise Exception("expected an empty structType, got %s" % \ | |||||
| repr (result.__dict__)) | |||||
| def testMustUnderstandEqualsOne (server, action, harsh): | def testMustUnderstandEqualsOne (server, action, harsh): | ||||
| test = 42 | test = 42 | ||||
| @@ -481,12 +475,12 @@ def testMustUnderstandEqualsOne (server, action, harsh): | |||||
| try: | try: | ||||
| result = server.echoInteger (inputInteger = test) | result = server.echoInteger (inputInteger = test) | ||||
| except SOAP.faultType, e: | |||||
| except SOAP.faultType as e: | |||||
| if harsh and e.faultcode != 'SOAP-ENV:MustUnderstand': | if harsh and e.faultcode != 'SOAP-ENV:MustUnderstand': | ||||
| raise AttributeError, "unexpected faultcode %s" % e.faultcode | |||||
| raise AttributeError("unexpected faultcode %s" % e.faultcode) | |||||
| return | return | ||||
| raise Exception, "should fail, succeeded with %s" % result | |||||
| raise Exception("should fail, succeeded with %s" % result) | |||||
| def testMustUnderstandEqualsZero (server, action, harsh): | def testMustUnderstandEqualsZero (server, action, harsh): | ||||
| test = 42 | test = 42 | ||||
| @@ -503,7 +497,7 @@ def testMustUnderstandEqualsZero (server, action, harsh): | |||||
| result = int (result) | result = int (result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %s, got %s" % (test, result) | |||||
| raise Exception("expected %s, got %s" % (test, result)) | |||||
| def testEchoDate (server, action, harsh): | def testEchoDate (server, action, harsh): | ||||
| test = time.gmtime (time.time ()) | test = time.gmtime (time.time ()) | ||||
| @@ -513,12 +507,12 @@ def testEchoDate (server, action, harsh): | |||||
| else: | else: | ||||
| result = server.echoDate (inputDate = SOAP.dateTimeType (test)) | result = server.echoDate (inputDate = SOAP.dateTimeType (test)) | ||||
| if not SOAP.Config.typed and type (result) in (type (''), type (u'')): | |||||
| if not SOAP.Config.typed and type (result) in (type (''), type ('')): | |||||
| p = SOAP.SOAPParser() | p = SOAP.SOAPParser() | ||||
| result = p.convertDateTime(result, 'timeInstant') | result = p.convertDateTime(result, 'timeInstant') | ||||
| if result != test[:6]: | if result != test[:6]: | ||||
| raise Exception, "expected %s, got %s" % (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % (repr (test), repr (result))) | |||||
| def testEchoBase64 (server, action, harsh): | def testEchoBase64 (server, action, harsh): | ||||
| test = '\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\xa0\xb0\xc0\xd0\xe0\xf0' | test = '\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\xa0\xb0\xc0\xd0\xe0\xf0' | ||||
| @@ -530,7 +524,7 @@ def testEchoBase64 (server, action, harsh): | |||||
| result = base64.decodestring(result) | result = base64.decodestring(result) | ||||
| if result != test: | if result != test: | ||||
| raise Exception, "expected %s, got %s" % (repr (test), repr (result)) | |||||
| raise Exception("expected %s, got %s" % (repr (test), repr (result))) | |||||
| def main (): | def main (): | ||||
| @@ -585,8 +579,7 @@ def main (): | |||||
| elif opt in ('-T', '--always-stacktrace'): | elif opt in ('-T', '--always-stacktrace'): | ||||
| printtrace = 2 | printtrace = 2 | ||||
| else: | else: | ||||
| raise AttributeError, \ | |||||
| "Recognized but unimplemented option `%s'" % opt | |||||
| raise AttributeError("Recognized but unimplemented option `%s'" % opt) | |||||
| except SystemExit: | except SystemExit: | ||||
| raise | raise | ||||
| except: | except: | ||||
| @@ -598,7 +591,7 @@ def main (): | |||||
| servers = readServers (servers) | servers = readServers (servers) | ||||
| if methodnums == None: | if methodnums == None: | ||||
| methodnums = range (1, len (DEFAULT_METHODS) + 1) | |||||
| methodnums = list(range(1, len (DEFAULT_METHODS) + 1)) | |||||
| limitre = re.compile ('|'.join (args), re.IGNORECASE) | limitre = re.compile ('|'.join (args), re.IGNORECASE) | ||||
| @@ -628,7 +621,7 @@ def main (): | |||||
| title = '%s: %s (#%d)' % (s['name'], name, num) | title = '%s: %s (#%d)' % (s['name'], name, num) | ||||
| if SOAP.Config.debug: | if SOAP.Config.debug: | ||||
| print "%s:" % title | |||||
| print("%s:" % title) | |||||
| try: | try: | ||||
| fn = globals ()['test' + name[0].upper () + name[1:]] | fn = globals ()['test' + name[0].upper () + name[1:]] | ||||
| @@ -636,17 +629,17 @@ def main (): | |||||
| raise | raise | ||||
| except: | except: | ||||
| if 'n' in output: | if 'n' in output: | ||||
| print title, "test not yet implemented" | |||||
| print(title, "test not yet implemented") | |||||
| notimp += 1 | notimp += 1 | ||||
| continue | continue | ||||
| try: | try: | ||||
| fn (server, s['soapaction'], harsh) | fn (server, s['soapaction'], harsh) | ||||
| if s['nonfunctional'].has_key (name): | |||||
| print title, \ | |||||
| "succeeded despite being marked nonfunctional" | |||||
| if name in s['nonfunctional']: | |||||
| print(title, \ | |||||
| "succeeded despite being marked nonfunctional") | |||||
| if 's' in output: | if 's' in output: | ||||
| print title, "succeeded" | |||||
| print(title, "succeeded") | |||||
| succeed += 1 | succeed += 1 | ||||
| except KeyboardInterrupt: | except KeyboardInterrupt: | ||||
| raise | raise | ||||
| @@ -655,18 +648,18 @@ def main (): | |||||
| if fault[-1] == '\n': | if fault[-1] == '\n': | ||||
| fault = fault[:-1] | fault = fault[:-1] | ||||
| if s['nonfunctional'].has_key (name): | |||||
| if name in s['nonfunctional']: | |||||
| if 'F' in output: | if 'F' in output: | ||||
| t = 'as expected' | t = 'as expected' | ||||
| if s['nonfunctional'][name] != '': | if s['nonfunctional'][name] != '': | ||||
| t += ', ' + s['nonfunctional'][name] | t += ', ' + s['nonfunctional'][name] | ||||
| print title, "failed (%s) -" % t, fault | |||||
| print(title, "failed (%s) -" % t, fault) | |||||
| if printtrace > 1: | if printtrace > 1: | ||||
| traceback.print_exc () | traceback.print_exc () | ||||
| failok += 1 | failok += 1 | ||||
| else: | else: | ||||
| if 'f' in output: | if 'f' in output: | ||||
| print title, "failed -", fault | |||||
| print(title, "failed -", fault) | |||||
| if printtrace: | if printtrace: | ||||
| traceback.print_exc () | traceback.print_exc () | ||||
| fail += 1 | fail += 1 | ||||
| @@ -675,20 +668,20 @@ def main (): | |||||
| return -1 | return -1 | ||||
| if stats: | if stats: | ||||
| print " Tests started at:", time.ctime (started) | |||||
| print(" Tests started at:", time.ctime (started)) | |||||
| if stats > 0: | if stats > 0: | ||||
| print " Total tests: %d" % total | |||||
| print " Successes: %d (%3.2f%%)" % \ | |||||
| (succeed, 100.0 * succeed / total) | |||||
| print(" Total tests: %d" % total) | |||||
| print(" Successes: %d (%3.2f%%)" % \ | |||||
| (succeed, 100.0 * succeed / total)) | |||||
| if stats > 0 or fail > 0: | if stats > 0 or fail > 0: | ||||
| print "Failed unexpectedly: %d (%3.2f%%)" % \ | |||||
| (fail, 100.0 * fail / total) | |||||
| print("Failed unexpectedly: %d (%3.2f%%)" % \ | |||||
| (fail, 100.0 * fail / total)) | |||||
| if stats > 0: | if stats > 0: | ||||
| print " Failed as expected: %d (%3.2f%%)" % \ | |||||
| (failok, 100.0 * failok / total) | |||||
| print(" Failed as expected: %d (%3.2f%%)" % \ | |||||
| (failok, 100.0 * failok / total)) | |||||
| if stats > 0 or notimp > 0: | if stats > 0 or notimp > 0: | ||||
| print " Not implemented: %d (%3.2f%%)" % \ | |||||
| (notimp, 100.0 * notimp / total) | |||||
| print(" Not implemented: %d (%3.2f%%)" % \ | |||||
| (notimp, 100.0 * notimp / total)) | |||||
| return fail + notimp | return fail + notimp | ||||
| @@ -60,19 +60,19 @@ def usage (error = None): | |||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| if error != None: | if error != None: | ||||
| print error | |||||
| print(error) | |||||
| print """usage: %s [options] | |||||
| print("""usage: %s [options] | |||||
| If a long option shows an argument is mandatory, it's mandatory for the | If a long option shows an argument is mandatory, it's mandatory for the | ||||
| equivalent short option also. The default (if any) is shown in brackets. | equivalent short option also. The default (if any) is shown in brackets. | ||||
| -?, --help display this usage | -?, --help display this usage | ||||
| -h, --host=HOST use HOST in the address to listen on [%s] | -h, --host=HOST use HOST in the address to listen on [%s] | ||||
| -p, --port=PORT listen on PORT [%d] | -p, --port=PORT listen on PORT [%d] | ||||
| """ % (sys.argv[0], DEFAULT_HOST, DEFAULT_HTTP_PORT), | |||||
| """ % (sys.argv[0], DEFAULT_HOST, DEFAULT_HTTP_PORT), end=' ') | |||||
| if SOAP.Config.SSLserver: | if SOAP.Config.SSLserver: | ||||
| print " -s, --ssl serve using SSL" | |||||
| print(" -s, --ssl serve using SSL") | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -101,8 +101,7 @@ def main (): | |||||
| elif opt in ('-s', '--ssl'): | elif opt in ('-s', '--ssl'): | ||||
| ssl = 1 | ssl = 1 | ||||
| else: | else: | ||||
| raise AttributeError, \ | |||||
| "Recognized but unimplemented option `%s'" % opt | |||||
| raise AttributeError("Recognized but unimplemented option `%s'" % opt) | |||||
| except SystemExit: | except SystemExit: | ||||
| raise | raise | ||||
| except: | except: | ||||
| @@ -62,16 +62,16 @@ def usage (error = None): | |||||
| sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
| if error != None: | if error != None: | ||||
| print error | |||||
| print(error) | |||||
| print """usage: %s [options] | |||||
| print("""usage: %s [options] | |||||
| If a long option shows an argument is mandatory, it's mandatory for the | If a long option shows an argument is mandatory, it's mandatory for the | ||||
| equivalent short option also. The default (if any) is shown in brackets. | equivalent short option also. The default (if any) is shown in brackets. | ||||
| -?, --help display this usage | -?, --help display this usage | ||||
| -h, --host=HOST use HOST in the address to listen on [%s] | -h, --host=HOST use HOST in the address to listen on [%s] | ||||
| -p, --port=PORT listen on PORT [%d] | -p, --port=PORT listen on PORT [%d] | ||||
| """ % (sys.argv[0], DEFAULT_HOST, DEFAULT_PORT), | |||||
| """ % (sys.argv[0], DEFAULT_HOST, DEFAULT_PORT), end=' ') | |||||
| sys.exit (0) | sys.exit (0) | ||||
| @@ -91,8 +91,7 @@ def main (): | |||||
| elif opt in ('-p', '--port'): | elif opt in ('-p', '--port'): | ||||
| port = int (arg) | port = int (arg) | ||||
| else: | else: | ||||
| raise AttributeError, \ | |||||
| "Recognized but unimplemented option `%s'" % opt | |||||
| raise AttributeError("Recognized but unimplemented option `%s'" % opt) | |||||
| except SystemExit: | except SystemExit: | ||||
| raise | raise | ||||
| except: | except: | ||||
| @@ -15,4 +15,4 @@ else: | |||||
| server = SOAP.SOAPProxy("http://admin:pw3340@localhost:8080/",encoding=None) | server = SOAP.SOAPProxy("http://admin:pw3340@localhost:8080/",encoding=None) | ||||
| x = server.sopa() | x = server.sopa() | ||||
| print x | |||||
| print(x) | |||||