diff --git a/allTests.py b/allTests.py index 863d7d04750..241f14e0bdc 100755 --- a/allTests.py +++ b/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "scripts")) from Util import runTests diff --git a/certs/makecerts.py b/certs/makecerts.py index 26550d79727..38f8ce72554 100755 --- a/certs/makecerts.py +++ b/certs/makecerts.py @@ -3,7 +3,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, socket, getopt +import os +import sys +import socket +import getopt try: import IceCertUtils @@ -12,6 +15,7 @@ "package from the Python package repository?\nerror: " + str(ex)) sys.exit(1) + def usage(): print("Usage: " + sys.argv[0] + " [options]") print("") @@ -21,9 +25,10 @@ def usage(): print("--ip The IP address for the server certificate.") print("--dns The DNS name for the server certificate.") print("--use-dns Use the DNS name for the server certificate common") - print(" name (default is to use the IP address)." ) + print(" name (default is to use the IP address).") sys.exit(1) + # # Check arguments # @@ -33,7 +38,7 @@ def usage(): usedns = False impl = "" try: - opts, args = getopt.getopt(sys.argv[1:], "hd", ["help", "debug", "ip=", "dns=","use-dns","impl="]) + opts, args = getopt.getopt(sys.argv[1:], "hd", ["help", "debug", "ip=", "dns=", "use-dns", "impl="]) except getopt.GetoptError as e: print("Error %s " % e) usage() @@ -54,6 +59,7 @@ def usage(): elif o == "--impl": impl = a + def request(question, newvalue, value): while True: sys.stdout.write(question) @@ -66,6 +72,7 @@ def request(question, newvalue, value): else: return value + # # Change to the directory where the certs files are stored # @@ -103,7 +110,7 @@ def request(question, newvalue, value): # # NOTE: server.pem is used by scripts/TestController.py # -server = factory.create("server", cn = (dns if usedns else ip), ip=ip, dns=dns, extendedKeyUsage="serverAuth,clientAuth") +server = factory.create("server", cn=(dns if usedns else ip), ip=ip, dns=dns, extendedKeyUsage="serverAuth,clientAuth") server.save("server.p12").save("server.pem") try: @@ -116,13 +123,15 @@ def request(question, newvalue, value): client.save("client.bks", caalias="cacert") except Exception as ex: for f in ["server.bks", "client.bks"]: - if os.path.exists(f): os.remove(f) + if os.path.exists(f): + os.remove(f) print("warning: couldn't generate BKS certificates for Android applications:\n" + str(ex)) print("Please fix this issue if you want to run the Android tests.") except Exception as ex: for f in ["server.jks", "client.jks"]: - if os.path.exists(f): os.remove(f) + if os.path.exists(f): + os.remove(f) print("warning: couldn't generate JKS certificates for Java applications:\n" + str(ex)) print("Please fix this issue if you want to run the Java tests.") diff --git a/config/makeprops.py b/config/makeprops.py index ce3996b7e66..45f797c8cf9 100755 --- a/config/makeprops.py +++ b/config/makeprops.py @@ -3,7 +3,13 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, shutil, re, signal, time, pprint +import os +import sys +import shutil +import re +import signal +import time +import pprint from xml.sax import make_parser from xml.sax.handler import feature_namespaces @@ -117,15 +123,17 @@ class %(classname)s """ jsEpilogue = \ -""" + """ Ice.%(classname)s = %(classname)s; module.exports.Ice = Ice; """ + def usage(): global progname print >> sys.stderr, "Usage: " + progname + " [--{cpp|java|csharp|js} file]" + def progError(msg): global progname print >> sys.stderr, progname + ": " + msg @@ -137,8 +145,9 @@ def progError(msg): # the language mapping source code. # + class PropertyClass: - def __init__(self, prefixOnly , childProperties): + def __init__(self, prefixOnly, childProperties): self.prefixOnly = prefixOnly self.childProperties = childProperties @@ -151,6 +160,7 @@ def isPrefixOnly(self): def __repr__(self): return repr((repr(self.preifxOnly), repr(self.childProperties))) + def initPropertyClasses(filename): doc = parse(filename) propertyClassNodes = doc.getElementsByTagName("class") @@ -174,6 +184,7 @@ def initPropertyClasses(filename): # SAX part. # + def handler(signum, frame): """Installed as signal handler. Should cause an files that are in use to be closed and removed""" @@ -181,6 +192,7 @@ def handler(signum, frame): contentHandler.cleanup() sys.exit(128 + signum) + class UnknownElementException(Exception): def __init__(self, value): self.value = value @@ -188,6 +200,7 @@ def __init__(self, value): def __str__(self): return repr(self.value) + class PropertyHandler(ContentHandler): def __init__(self, inputfile, className): @@ -281,7 +294,7 @@ def startElement(self, name, attrs): # a property class, they need to be expanded. if "deprecatedBy" in t: t["deprecatedBy"] = "%s.%s.%s" % (self.currentSection, propertyName, t["deprecatedBy"]) - t['name'] = "%s.%s" % (propertyName, p['name']) + t['name'] = "%s.%s" % (propertyName, p['name']) self.startElement(name, t) if c.isPrefixOnly(): return @@ -292,7 +305,7 @@ def startElement(self, name, attrs): deprecatedBy = attrs.get("deprecatedBy", None) if deprecatedBy != None: self.handleDeprecatedWithReplacement(propertyName, deprecatedBy) - elif attrs.get("deprecated", "false").lower() == "true" : + elif attrs.get("deprecated", "false").lower() == "true": self.handleDeprecated(propertyName) else: self.handleProperty(propertyName) @@ -303,6 +316,7 @@ def endElement(self, name): elif name == "section": self.closeSection() + class CppPropertyHandler(PropertyHandler): def __init__(self, inputfile, c): @@ -323,23 +337,23 @@ def cleanup(self): def startFiles(self): self.hFile = open(self.className + ".h", "w") self.cppFile = open(self.className + ".cpp", "w") - self.hFile.write(cppHeaderPreamble % {'inputfile' : self.inputfile, 'classname' : self.className}) - self.cppFile.write(cppSrcPreamble % {'inputfile' : self.inputfile, 'classname' : self.className}) + self.hFile.write(cppHeaderPreamble % {'inputfile': self.inputfile, 'classname': self.className}) + self.cppFile.write(cppSrcPreamble % {'inputfile': self.inputfile, 'classname': self.className}) def closeFiles(self): - self.hFile.write(cppHeaderPostamble % {'classname' : self.className}) - self.cppFile.write("const IceInternal::PropertyArray "\ - "IceInternal::%(classname)s::validProps[] =\n" % \ - {'classname' : self.className}) + self.hFile.write(cppHeaderPostamble % {'classname': self.className}) + self.cppFile.write("const IceInternal::PropertyArray " + "IceInternal::%(classname)s::validProps[] =\n" % + {'classname': self.className}) self.cppFile.write("{\n") for s in self.sections: self.cppFile.write(" %sProps,\n" % s) - self.cppFile.write(" IceInternal::PropertyArray(0,0)\n"); + self.cppFile.write(" IceInternal::PropertyArray(0,0)\n") self.cppFile.write("};\n\n") - self.cppFile.write("const char* IceInternal::%(classname)s::clPropNames[] =\n" % \ - {'classname' : self.className}) + self.cppFile.write("const char* IceInternal::%(classname)s::clPropNames[] =\n" % + {'classname': self.className}) self.cppFile.write("{\n") for s in self.cmdLineOptions: self.cppFile.write(" \"%s\",\n" % s) @@ -352,16 +366,16 @@ def fix(self, propertyName): return propertyName.replace("[any]", "*") def deprecatedImpl(self, propertyName): - self.cppFile.write(" IceInternal::Property(\"%s.%s\", true, 0),\n" % (self.currentSection, \ - self.fix(propertyName))) + self.cppFile.write(" IceInternal::Property(\"%s.%s\", true, 0),\n" % (self.currentSection, + self.fix(propertyName))) def deprecatedImplWithReplacementImpl(self, propertyName, deprecatedBy): - self.cppFile.write(" IceInternal::Property(\"%s.%s\", true, \"%s\"),\n" % (self.currentSection, \ - self.fix(propertyName), deprecatedBy)) + self.cppFile.write(" IceInternal::Property(\"%s.%s\", true, \"%s\"),\n" % (self.currentSection, + self.fix(propertyName), deprecatedBy)) def propertyImpl(self, propertyName): - self.cppFile.write(" IceInternal::Property(\"%s.%s\", false, 0),\n" % \ - (self.currentSection, self.fix(propertyName))) + self.cppFile.write(" IceInternal::Property(\"%s.%s\", false, 0),\n" % + (self.currentSection, self.fix(propertyName))) def newSection(self): self.hFile.write(" static const PropertyArray %sProps;\n" % self.currentSection) @@ -375,7 +389,7 @@ def closeSection(self): IceInternal::%(className)s::%(section)sProps(%(section)sPropsData, sizeof(%(section)sPropsData)/sizeof(%(section)sPropsData[0])); -""" % { 'className' : self.className, 'section': self.currentSection }) +""" % {'className': self.className, 'section': self.currentSection}) def moveFiles(self, location): dest = os.path.join(location, "cpp", "src", "Ice") @@ -386,6 +400,7 @@ def moveFiles(self, location): shutil.move(self.className + ".h", dest) shutil.move(self.className + ".cpp", dest) + class JavaPropertyHandler(PropertyHandler): def __init__(self, inputfile, c): PropertyHandler.__init__(self, inputfile, c) @@ -399,7 +414,7 @@ def cleanup(self): def startFiles(self): self.srcFile = open(self.className + ".java", "w") - self.srcFile.write(javaPreamble % {'inputfile' : self.inputfile, 'classname' : self.className}) + self.srcFile.write(javaPreamble % {'inputfile': self.inputfile, 'classname': self.className}) def closeFiles(self): self.srcFile.write(" public static final Property[] validProps[] =\n") @@ -426,20 +441,20 @@ def fix(self, propertyName): return propertyName.replace(".", "\\\\.").replace("[any]", "[^\\\\s]+") def deprecatedImpl(self, propertyName): - self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", " \ - "true, null),\n" % \ - {"section" : self.currentSection, "pattern": self.fix(propertyName)}) + self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", " + "true, null),\n" % + {"section": self.currentSection, "pattern": self.fix(propertyName)}) def deprecatedImplWithReplacementImpl(self, propertyName, deprecatedBy): - self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", "\ - "true, \"%(deprecatedBy)s\"),\n" % \ - {"section" : self.currentSection, "pattern": self.fix(propertyName), - "deprecatedBy" : deprecatedBy}) + self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", " + "true, \"%(deprecatedBy)s\"),\n" % + {"section": self.currentSection, "pattern": self.fix(propertyName), + "deprecatedBy": deprecatedBy}) def propertyImpl(self, propertyName): - self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", " \ - "false, null),\n" % \ - {"section" : self.currentSection, "pattern": self.fix(propertyName)} ) + self.srcFile.write(" new Property(\"%(section)s\\\\.%(pattern)s\", " + "false, null),\n" % + {"section": self.currentSection, "pattern": self.fix(propertyName)}) def newSection(self): self.srcFile.write(" public static final Property %sProps[] =\n" % self.currentSection) @@ -455,6 +470,7 @@ def moveFiles(self, location): os.remove(os.path.join(dest, self.className + ".java")) shutil.move(self.className + ".java", dest) + class CSPropertyHandler(PropertyHandler): def __init__(self, inputfile, c): PropertyHandler.__init__(self, inputfile, c) @@ -468,7 +484,7 @@ def cleanup(self): def startFiles(self): self.srcFile = open(self.className + ".cs", "w") - self.srcFile.write(csPreamble % {'inputfile' : self.inputfile, 'classname' : self.className}) + self.srcFile.write(csPreamble % {'inputfile': self.inputfile, 'classname': self.className}) def closeFiles(self): self.srcFile.write(" public static Property[][] validProps =\n") @@ -491,19 +507,19 @@ def fix(self, propertyName): return propertyName.replace(".", "\\.").replace("[any]", "[^\\s]+") def deprecatedImpl(self, propertyName): - self.srcFile.write(" new Property(@\"^%s\.%s$\", true, null),\n" % (self.currentSection, \ - self.fix(propertyName))) + self.srcFile.write(" new Property(@\"^%s\.%s$\", true, null),\n" % (self.currentSection, + self.fix(propertyName))) def deprecatedImplWithReplacementImpl(self, propertyName, deprecatedBy): - self.srcFile.write(" new Property(@\"^%s\.%s$\", true, @\"%s\"),\n" % \ - (self.currentSection, self.fix(propertyName), deprecatedBy)) + self.srcFile.write(" new Property(@\"^%s\.%s$\", true, @\"%s\"),\n" % + (self.currentSection, self.fix(propertyName), deprecatedBy)) def propertyImpl(self, propertyName): - self.srcFile.write(" new Property(@\"^%s\.%s$\", false, null),\n" % (self.currentSection, \ - self.fix(propertyName))) + self.srcFile.write(" new Property(@\"^%s\.%s$\", false, null),\n" % (self.currentSection, + self.fix(propertyName))) def newSection(self): - self.srcFile.write(" public static Property[] %sProps =\n" % self.currentSection); + self.srcFile.write(" public static Property[] %sProps =\n" % self.currentSection) self.srcFile.write(" {\n") def closeSection(self): @@ -516,6 +532,7 @@ def moveFiles(self, location): os.remove(os.path.join(dest, self.className + ".cs")) shutil.move(self.className + ".cs", dest) + class JSPropertyHandler(PropertyHandler): def __init__(self, inputfile, c): PropertyHandler.__init__(self, inputfile, c) @@ -530,7 +547,7 @@ def cleanup(self): def startFiles(self): self.srcFile = open(self.className + ".js", "w") - self.srcFile.write(jsPreamble % {'inputfile' : self.inputfile, 'classname' : self.className}) + self.srcFile.write(jsPreamble % {'inputfile': self.inputfile, 'classname': self.className}) def closeFiles(self): self.srcFile.write("%s.validProps =\n" % (self.className)) @@ -547,7 +564,7 @@ def closeFiles(self): self.srcFile.write(" \"%s\",\n" % s) self.srcFile.write("];\n") - self.srcFile.write(jsEpilogue % {'classname' : self.className}); + self.srcFile.write(jsEpilogue % {'classname': self.className}) self.srcFile.close() def fix(self, propertyName): @@ -555,23 +572,23 @@ def fix(self, propertyName): def deprecatedImpl(self, propertyName): if self.currentSection in self.validSections: - self.srcFile.write(" new Property(\"/^%s\.%s/\", true, null),\n" % (self.currentSection, \ - self.fix(propertyName))) + self.srcFile.write(" new Property(\"/^%s\.%s/\", true, null),\n" % (self.currentSection, + self.fix(propertyName))) def deprecatedImplWithReplacementImpl(self, propertyName, deprecatedBy): if self.currentSection in self.validSections: - self.srcFile.write(" new Property(\"/^%s\.%s/\", true, \"%s\"),\n" % \ - (self.currentSection, self.fix(propertyName), deprecatedBy)) + self.srcFile.write(" new Property(\"/^%s\.%s/\", true, \"%s\"),\n" % + (self.currentSection, self.fix(propertyName), deprecatedBy)) def propertyImpl(self, propertyName): if self.currentSection in self.validSections: - self.srcFile.write(" new Property(\"/^%s\.%s/\", false, null),\n" % (self.currentSection, \ - self.fix(propertyName))) + self.srcFile.write(" new Property(\"/^%s\.%s/\", false, null),\n" % (self.currentSection, + self.fix(propertyName))) def newSection(self): if self.currentSection in self.validSections: self.skipSection = False - self.srcFile.write("%s.%sProps =\n" % (self.className, self.currentSection)); + self.srcFile.write("%s.%sProps =\n" % (self.className, self.currentSection)) self.srcFile.write("[\n") def closeSection(self): @@ -585,6 +602,7 @@ def moveFiles(self, location): os.remove(os.path.join(dest, self.className + ".js")) shutil.move(self.className + ".js", dest) + class MultiHandler(PropertyHandler): def __init__(self, inputfile, c): self.handlers = [] @@ -637,6 +655,7 @@ def moveFiles(self, location): for f in self.handlers: f.moveFiles(location) + def main(): if len(sys.argv) != 1 and len(sys.argv) != 3: usage() @@ -681,9 +700,9 @@ def main(): if lang == None: contentHandler = MultiHandler(infile, "") contentHandler.addHandlers([CppPropertyHandler(infile, className), - JavaPropertyHandler(infile, className), - CSPropertyHandler(infile, className), - JSPropertyHandler(infile, className)]) + JavaPropertyHandler(infile, className), + CSPropertyHandler(infile, className), + JSPropertyHandler(infile, className)]) else: if lang == "cpp": contentHandler = CppPropertyHandler(infile, className) @@ -716,5 +735,6 @@ def main(): progError(str(ex)) contentHandler.cleanup() + if __name__ == "__main__": main() diff --git a/cpp/allTests.py b/cpp/allTests.py index 2241653995d..94a9466c3db 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/cpp/test/Glacier2/attack/test.py b/cpp/test/Glacier2/attack/test.py index a67cc5333d6..900fb11bc2c 100644 --- a/cpp/test/Glacier2/attack/test.py +++ b/cpp/test/Glacier2/attack/test.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -Glacier2TestSuite(__name__, routerProps = { "Glacier2.RoutingTable.MaxSize" : 10 }) +Glacier2TestSuite(__name__, routerProps={"Glacier2.RoutingTable.MaxSize": 10}) diff --git a/cpp/test/Glacier2/dynamicFiltering/test.py b/cpp/test/Glacier2/dynamicFiltering/test.py index 8de08a255ac..bc55729b5b9 100644 --- a/cpp/test/Glacier2/dynamicFiltering/test.py +++ b/cpp/test/Glacier2/dynamicFiltering/test.py @@ -7,12 +7,13 @@ # Note: we limit the send buffer size with Ice.TCP.SndSize, the # test relies on send() blocking # -routerProps = lambda process, current : { - 'Glacier2.SessionManager' : 'SessionManager:{0}'.format(current.getTestEndpoint(0)), - 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', - 'Ice.Default.Locator' : 'locator:{0}'.format(current.getTestEndpoint(1)), +def routerProps(process, current): return { + 'Glacier2.SessionManager': 'SessionManager:{0}'.format(current.getTestEndpoint(0)), + 'Glacier2.PermissionsVerifier': 'Glacier2/NullPermissionsVerifier', + 'Ice.Default.Locator': 'locator:{0}'.format(current.getTestEndpoint(1)), } + Glacier2TestSuite(__name__, testcases=[ClientServerTestCase(servers=[Glacier2Router(props=routerProps, passwords=None), Server(readyCount=3)])]) diff --git a/cpp/test/Glacier2/hashpassword/test.py b/cpp/test/Glacier2/hashpassword/test.py index 9e4cc80f861..896bf9f7bee 100644 --- a/cpp/test/Glacier2/hashpassword/test.py +++ b/cpp/test/Glacier2/hashpassword/test.py @@ -17,7 +17,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') - def hashPasswords(password, args = ""): + def hashPasswords(password, args=""): return run('"%s" "%s" %s' % (sys.executable, hashpassword, args), stdin=(password + "\r\n").encode('UTF-8'), stdinRepeat=False) @@ -88,4 +88,5 @@ def hashPasswords(password, args = ""): current.writeln("ok") + TestSuite(__name__, [Glacier2HashPasswordTestCase()]) diff --git a/cpp/test/Glacier2/override/test.py b/cpp/test/Glacier2/override/test.py index 7edc19a1f6b..b8cb6b305ea 100644 --- a/cpp/test/Glacier2/override/test.py +++ b/cpp/test/Glacier2/override/test.py @@ -8,21 +8,21 @@ # test relies on send() blocking # routerProps = { - 'Ice.Warn.Dispatch' : '0', - 'Ice.Warn.Connections' : '0', - 'Ice.TCP.SndSize' : '100000', - 'Ice.ThreadPool.Server.Serialize' : '1', - 'Ice.ThreadPool.Client.Serialize' : '1', - 'Glacier2.Filter.Category.Accept' : '"c"', - 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', - 'Glacier2.Client.ForwardContext' : '1', - 'Glacier2.Client.ACM.Timeout' : '"30"', - 'Glacier2.Client.Trace.Override' : '0', - 'Glacier2.Client.Trace.Request' : '0', - 'Glacier2.Server.Trace.Override' : '0', - 'Glacier2.Server.Trace.Request' : '0', - 'Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered' : '1', - 'Glacier2.Client.SleepTime=50 --Glacier2.Server.SleepTime' : '50', + 'Ice.Warn.Dispatch': '0', + 'Ice.Warn.Connections': '0', + 'Ice.TCP.SndSize': '100000', + 'Ice.ThreadPool.Server.Serialize': '1', + 'Ice.ThreadPool.Client.Serialize': '1', + 'Glacier2.Filter.Category.Accept': '"c"', + 'Glacier2.PermissionsVerifier': 'Glacier2/NullPermissionsVerifier', + 'Glacier2.Client.ForwardContext': '1', + 'Glacier2.Client.ACM.Timeout': '"30"', + 'Glacier2.Client.Trace.Override': '0', + 'Glacier2.Client.Trace.Request': '0', + 'Glacier2.Server.Trace.Override': '0', + 'Glacier2.Server.Trace.Request': '0', + 'Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered': '1', + 'Glacier2.Client.SleepTime=50 --Glacier2.Server.SleepTime': '50', } Glacier2TestSuite(__name__, routerProps=routerProps) diff --git a/cpp/test/Glacier2/sessionControl/test.py b/cpp/test/Glacier2/sessionControl/test.py index 44fb393f929..85f2d6d0faf 100644 --- a/cpp/test/Glacier2/sessionControl/test.py +++ b/cpp/test/Glacier2/sessionControl/test.py @@ -7,9 +7,10 @@ # Note: we limit the send buffer size with Ice.TCP.SndSize, the # test relies on send() blocking # -routerProps = lambda process, current : { - 'Glacier2.SessionManager' : 'SessionManager:{0}'.format(current.getTestEndpoint(0)), - 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', +def routerProps(process, current): return { + 'Glacier2.SessionManager': 'SessionManager:{0}'.format(current.getTestEndpoint(0)), + 'Glacier2.PermissionsVerifier': 'Glacier2/NullPermissionsVerifier', } + Glacier2TestSuite(__name__, testcases=[ClientServerTestCase(servers=[Glacier2Router(props=routerProps), Server()])]) diff --git a/cpp/test/Glacier2/ssl/test.py b/cpp/test/Glacier2/ssl/test.py index fb3135b0761..4e1aa410ad7 100644 --- a/cpp/test/Glacier2/ssl/test.py +++ b/cpp/test/Glacier2/ssl/test.py @@ -3,22 +3,25 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -routerProps = lambda process, current : { - 'Ice.Warn.Dispatch' : '0', - 'Glacier2.AddConnectionContext' : '1', - 'Glacier2.Client.Endpoints' : '{0}:{1}'.format(current.getTestEndpoint(0, "tcp"), current.getTestEndpoint(1, "ssl")), - 'Ice.Admin.Endpoints' : current.getTestEndpoint(2, "tcp"), - 'Glacier2.SessionManager' : 'sessionmanager:{0}'.format(current.getTestEndpoint(3, "tcp")), - 'Glacier2.PermissionsVerifier' : 'verifier:{0}'.format(current.getTestEndpoint(3, "tcp")), - 'Glacier2.SSLSessionManager' : 'sslsessionmanager:{0}'.format(current.getTestEndpoint(3, "tcp")), - 'Glacier2.SSLPermissionsVerifier' : 'sslverifier:{0}'.format(current.getTestEndpoint(3, "tcp")), +def routerProps(process, current): return { + 'Ice.Warn.Dispatch': '0', + 'Glacier2.AddConnectionContext': '1', + 'Glacier2.Client.Endpoints': '{0}:{1}'.format(current.getTestEndpoint(0, "tcp"), current.getTestEndpoint(1, "ssl")), + 'Ice.Admin.Endpoints': current.getTestEndpoint(2, "tcp"), + 'Glacier2.SessionManager': 'sessionmanager:{0}'.format(current.getTestEndpoint(3, "tcp")), + 'Glacier2.PermissionsVerifier': 'verifier:{0}'.format(current.getTestEndpoint(3, "tcp")), + 'Glacier2.SSLSessionManager': 'sslsessionmanager:{0}'.format(current.getTestEndpoint(3, "tcp")), + 'Glacier2.SSLPermissionsVerifier': 'sslverifier:{0}'.format(current.getTestEndpoint(3, "tcp")), } # # Always enable SSL for the Glacier2 router and client # -sslProps = lambda process, current: current.testcase.getMapping().getSSLProps(process, current) -Glacier2TestSuite(__name__, routerProps=routerProps, options={ "ipv6" : [ False ] }, multihost=False, + +def sslProps(process, current): return current.testcase.getMapping().getSSLProps(process, current) + + +Glacier2TestSuite(__name__, routerProps=routerProps, options={"ipv6": [False]}, multihost=False, testcases=[ClientServerTestCase(servers=[Glacier2Router(props=sslProps), Server()], client=Client(props=sslProps))]) diff --git a/cpp/test/Glacier2/staticFiltering/test.py b/cpp/test/Glacier2/staticFiltering/test.py index d4517bb0242..75b8c732006 100644 --- a/cpp/test/Glacier2/staticFiltering/test.py +++ b/cpp/test/Glacier2/staticFiltering/test.py @@ -12,9 +12,9 @@ def __init__(self, testcase, hostname): self.hostname = hostname description, self.tcArgs, self.attacks, self.xtraConfig = testcase - clientProps = { "Ice.Config" : "{testdir}/client.cfg", "Ice.Warn.Connections" : 0 } - serverProps = { "Ice.Config" : "{testdir}/server.cfg", "Ice.Warn.Connections" : 0 } - routerProps = { "Ice.Config" : "{testdir}/router.cfg", "Glacier2.RoutingTable.MaxSize" : 10 } + clientProps = {"Ice.Config": "{testdir}/client.cfg", "Ice.Warn.Connections": 0} + serverProps = {"Ice.Config": "{testdir}/server.cfg", "Ice.Warn.Connections": 0} + routerProps = {"Ice.Config": "{testdir}/router.cfg", "Glacier2.RoutingTable.MaxSize": 10} # Override the server/router default host property, we don't want to use the loopback serverProps["Ice.Default.Host"] = "" @@ -38,15 +38,15 @@ def setupServerSide(self, current): # configuration file is easier. # with open(os.path.join(self.getTestSuite().getPath(), 'client.cfg'), 'w') as clientConfig: - accepts=0 - rejects=0 + accepts = 0 + rejects = 0 for expect, proxy in self.attacks: if expect: clientConfig.write('Accept.Proxy.' + str(accepts) + '=') - accepts +=1 + accepts += 1 else: clientConfig.write('Reject.Proxy.' + str(rejects) + '=') - rejects +=1 + rejects += 1 clientConfig.write(proxy + '\n') with open(os.path.join(self.getTestSuite().getPath(), 'server.cfg'), 'w') as serverConfig: @@ -132,7 +132,7 @@ def setup(self, current): limitedTests = True else: dot = fqdn.find(".") - domainname = fqdn[dot+1:] + domainname = fqdn[dot + 1:] # # Some Python installs are going to return a FQDN for gethostname(). # This invalidates the tests that need to differentiate between the @@ -164,127 +164,127 @@ def setup(self, current): domainname = "" testcases = [ - ('testing category filter', - ('', '', '', 'foo "a cat with spaces"', '', ''), - [(True, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), - (True, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010')], []), - ('testing adapter id filter', - ('', '*', '', '', '', 'foo "an adapter with spaces"'), - [(False, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), - (False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'helloE @ bar'), - (True, 'helloF1 @ "an adapter with spaces"'), - (True, 'helloF @ foo')], []), - ('test identity filters', - ('', '', '', '', 'myident cata/fooa "a funny id/that might mess it up"', ''), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, 'myident:tcp -h 127.0.0.1 -p 12010'), - (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ('test mixing filters', - ('', '', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up" "a\\"nother"', - 'myadapter'), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/foo @ jimbo'), - (False, 'hiscatA @ jimbo'), - (True, 'hiscat @ myadapter'), - (True, 'a\"nother @ jimbo'), - (True, 'myident:tcp -h 127.0.0.1 -p 12010'), - (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ('test mixing filters (indirect only)', - ('', '*', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up"', 'myadapter'), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (False, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), - (False, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/foo @ jimbo'), - (False, 'hiscatA @ jimbo'), - (True, 'hiscat @ myadapter'), - (False, 'myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up" @ myadapter'), - (False, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ] + ('testing category filter', + ('', '', '', 'foo "a cat with spaces"', '', ''), + [(True, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), + (True, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010')], []), + ('testing adapter id filter', + ('', '*', '', '', '', 'foo "an adapter with spaces"'), + [(False, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), + (False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'helloE @ bar'), + (True, 'helloF1 @ "an adapter with spaces"'), + (True, 'helloF @ foo')], []), + ('test identity filters', + ('', '', '', '', 'myident cata/fooa "a funny id/that might mess it up"', ''), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, 'myident:tcp -h 127.0.0.1 -p 12010'), + (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ('test mixing filters', + ('', '', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up" "a\\"nother"', + 'myadapter'), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/foo @ jimbo'), + (False, 'hiscatA @ jimbo'), + (True, 'hiscat @ myadapter'), + (True, 'a\"nother @ jimbo'), + (True, 'myident:tcp -h 127.0.0.1 -p 12010'), + (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ('test mixing filters (indirect only)', + ('', '*', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up"', 'myadapter'), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (False, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), + (False, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/foo @ jimbo'), + (False, 'hiscatA @ jimbo'), + (True, 'hiscat @ myadapter'), + (False, 'myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up" @ myadapter'), + (False, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ] if not limitedTests: testcases.extend([ - ('testing reject all', - ('', '*', '', '', '', ''), - [(False, 'helloA:tcp -h %s -p 12010' % fqdn), - (False, 'helloB:tcp -h %s -p 12010' % hostname), - (False, 'helloC:tcp -h 127.0.0.1 -p 12010'), - (True, 'bar @ foo')], []), - ('testing loopback only rule', - ('127.0.0.1 localhost', '', '', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010' % fqdn), - (False, 'hello:tcp -h %s -p 12010' % hostname), - (False, '127.0.0.1:tcp -h %s -p 12010' % hostname), - (False, 'localhost:tcp -h %s -p 12010' % hostname), - (False, 'localhost/127.0.0.1:tcp -h %s -p 12010' % hostname), - (True, 'localhost:tcp -h 127.0.0.1 -p 12010'), - (True, 'localhost/127.0.0.1:tcp -h localhost -p 12010'), - (True, 'hello:tcp -h 127.0.0.1 -p 12010'), - (True, 'hello/somecat:tcp -h localhost -p 12010')], []), - ('testing port filter rule', - ('127.0.0.1:12010 localhost:12010', '', '', '', '', ''), - [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), - (False, 'hello2:tcp -h localhost -p 12011'), - (False, 'hello5:tcp -h %s -p 12010' % hostname), - (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), - (True, 'hello4:tcp -h localhost -p 12010')], []), - ('testing reject port filter rule', - ('', '127.0.0.1:[0-12009,12011-65535] localhost:[0-12009,12011-65535]', '', '', '', ''), - [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), - (False, 'hello2:tcp -h localhost -p 12011'), - (True, 'hello5:tcp -h %s -p 12010' % hostname), - (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), - (True, 'hello4:tcp -h localhost -p 12010')], []), - ('testing port filter rule with wildcard address rule', - ('*:12010', '', '', '', '', ''), - [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), - (False, 'hello2:tcp -h localhost -p 12011'), - (True, 'hello5:tcp -h %s -p 12010' % hostname), - (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), - (True, 'hello4:tcp -h localhost -p 12010')], []), - ('testing domain filter rule (accept)', - ("*" + domainname, '', '', '', '', ''), - [(True, 'hello:tcp -h %s -p 12010' % fqdn), - (False, 'hello:tcp -h %s -p 12010' % hostname)], []), - ('testing domain filter rule (reject)', - ('', "*" + domainname, '', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010' % fqdn), - (True, 'hello:tcp -h %s -p 12010' % hostname), - (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), - ('testing domain filter rule (mixed)', - ("127.0.0.1", fqdn, '', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010:tcp -h 127.0.0.1 -p 12010' % fqdn), - (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), - ('testing maximum proxy length rule', - ('', '', '53', '', '', ''), - [(True, 'hello:tcp -h 127.0.0.1 -p 12010 -t infinite'), - (False, '012345678901234567890123456789012345678901234567890123456789:tcp -h 127.0.0.1 -p 12010')], []), - ]) + ('testing reject all', + ('', '*', '', '', '', ''), + [(False, 'helloA:tcp -h %s -p 12010' % fqdn), + (False, 'helloB:tcp -h %s -p 12010' % hostname), + (False, 'helloC:tcp -h 127.0.0.1 -p 12010'), + (True, 'bar @ foo')], []), + ('testing loopback only rule', + ('127.0.0.1 localhost', '', '', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010' % fqdn), + (False, 'hello:tcp -h %s -p 12010' % hostname), + (False, '127.0.0.1:tcp -h %s -p 12010' % hostname), + (False, 'localhost:tcp -h %s -p 12010' % hostname), + (False, 'localhost/127.0.0.1:tcp -h %s -p 12010' % hostname), + (True, 'localhost:tcp -h 127.0.0.1 -p 12010'), + (True, 'localhost/127.0.0.1:tcp -h localhost -p 12010'), + (True, 'hello:tcp -h 127.0.0.1 -p 12010'), + (True, 'hello/somecat:tcp -h localhost -p 12010')], []), + ('testing port filter rule', + ('127.0.0.1:12010 localhost:12010', '', '', '', '', ''), + [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), + (False, 'hello2:tcp -h localhost -p 12011'), + (False, 'hello5:tcp -h %s -p 12010' % hostname), + (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), + (True, 'hello4:tcp -h localhost -p 12010')], []), + ('testing reject port filter rule', + ('', '127.0.0.1:[0-12009,12011-65535] localhost:[0-12009,12011-65535]', '', '', '', ''), + [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), + (False, 'hello2:tcp -h localhost -p 12011'), + (True, 'hello5:tcp -h %s -p 12010' % hostname), + (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), + (True, 'hello4:tcp -h localhost -p 12010')], []), + ('testing port filter rule with wildcard address rule', + ('*:12010', '', '', '', '', ''), + [(False, 'hello1:tcp -h 127.0.0.1 -p 12011'), + (False, 'hello2:tcp -h localhost -p 12011'), + (True, 'hello5:tcp -h %s -p 12010' % hostname), + (True, 'hello3:tcp -h 127.0.0.1 -p 12010'), + (True, 'hello4:tcp -h localhost -p 12010')], []), + ('testing domain filter rule (accept)', + ("*" + domainname, '', '', '', '', ''), + [(True, 'hello:tcp -h %s -p 12010' % fqdn), + (False, 'hello:tcp -h %s -p 12010' % hostname)], []), + ('testing domain filter rule (reject)', + ('', "*" + domainname, '', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010' % fqdn), + (True, 'hello:tcp -h %s -p 12010' % hostname), + (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), + ('testing domain filter rule (mixed)', + ("127.0.0.1", fqdn, '', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010:tcp -h 127.0.0.1 -p 12010' % fqdn), + (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), + ('testing maximum proxy length rule', + ('', '', '53', '', '', ''), + [(True, 'hello:tcp -h 127.0.0.1 -p 12010 -t infinite'), + (False, '012345678901234567890123456789012345678901234567890123456789:tcp -h 127.0.0.1 -p 12010')], []), + ]) if len(testcases) == 0: current.writeln("WARNING: You are running this test with SSL disabled and the network ") @@ -298,4 +298,6 @@ def setup(self, current): for testcase in testcases: self.addTestCase(Glacier2StaticFilteringTestCase(testcase, hostname)) -Glacier2StaticFilteringTestSuite(__name__, testcases=[], runOnMainThread=True, options={ "ipv6" : [False] }, multihost=False) + +Glacier2StaticFilteringTestSuite(__name__, testcases=[], runOnMainThread=True, + options={"ipv6": [False]}, multihost=False) diff --git a/cpp/test/Ice/echo/test.py b/cpp/test/Ice/echo/test.py index 8740a4f05fe..349529c649a 100644 --- a/cpp/test/Ice/echo/test.py +++ b/cpp/test/Ice/echo/test.py @@ -10,4 +10,5 @@ def __init__(self): def runClientSide(self, current): pass + TestSuite(__name__, [EchoServerTestCase()]) diff --git a/cpp/test/Ice/invoke/test.py b/cpp/test/Ice/invoke/test.py index 176ed12558f..b76279f57d0 100644 --- a/cpp/test/Ice/invoke/test.py +++ b/cpp/test/Ice/invoke/test.py @@ -4,5 +4,5 @@ TestSuite(__file__, [ClientServerTestCase(), - ClientServerTestCase(name = "client/server array", servers=[Server(args = ["--array"])]), - ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) + ClientServerTestCase(name="client/server array", servers=[Server(args=["--array"])]), + ClientServerTestCase(name="client/server async", servers=[Server(args=["--async"])])]) diff --git a/cpp/test/Ice/logger/test.py b/cpp/test/Ice/logger/test.py index 99a458d2064..5da1445b203 100644 --- a/cpp/test/Ice/logger/test.py +++ b/cpp/test/Ice/logger/test.py @@ -5,6 +5,7 @@ import glob + def test(process, current, match, enc, mapping): cmd = process.getCommandLine(current) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=mapping.getEnv(process, current)) @@ -15,6 +16,7 @@ def test(process, current, match, enc, mapping): if out.decode(enc).find(match.decode(enc)) == -1: raise RuntimeError("test failed") + class IceLoggerTestCase(ClientTestCase): def runClientSide(self, current): @@ -67,7 +69,7 @@ def runClientSide(self, current): if (not os.path.isfile("client5-0.log") or not os.stat("client5-0.log").st_size == 512 or - len(glob.glob("client5-0-*.log")) != 19): + len(glob.glob("client5-0-*.log")) != 19): raise RuntimeError("failed!") for f in glob.glob("client5-0-*.log"): @@ -77,12 +79,12 @@ def runClientSide(self, current): if (not os.path.isfile("client5-1.log") or not os.stat("client5-1.log").st_size == 1024 or - len(glob.glob("client5-1-*.log")) != 0): + len(glob.glob("client5-1-*.log")) != 0): raise RuntimeError("failed!") if (not os.path.isfile("client5-2.log") or not os.stat("client5-2.log").st_size == 128 or - len(glob.glob("client5-2-*.log")) != 7): + len(glob.glob("client5-2-*.log")) != 7): raise RuntimeError("failed!") for f in glob.glob("client5-2-*.log"): @@ -92,7 +94,7 @@ def runClientSide(self, current): if (not os.path.isfile("client5-3.log") or not os.stat("client5-2.log").st_size == 128 or - len(glob.glob("client5-2-*.log")) != 7): + len(glob.glob("client5-2-*.log")) != 7): raise RuntimeError("failed!") for f in glob.glob("client5-3-*.log"): @@ -107,7 +109,7 @@ def runClientSide(self, current): if isinstance(platform, Windows) or os.getuid() != 0: if (not os.path.isfile("log/client5-4.log") or os.stat("log/client5-4.log").st_size < 1024 or - len(glob.glob("log/client5-4-*.log")) > 0): + len(glob.glob("log/client5-4-*.log")) > 0): raise RuntimeError("failed!") with open("log/client5-4.log", 'r') as f: @@ -131,4 +133,5 @@ def clean(self): os.remove(f) os.rmdir("log") -TestSuite(__name__, [ IceLoggerTestCase() ], chdir=True) + +TestSuite(__name__, [IceLoggerTestCase()], chdir=True) diff --git a/cpp/test/Ice/threadPoolPriority/test.py b/cpp/test/Ice/threadPoolPriority/test.py index 5ccb55bbbfe..78111b490b1 100644 --- a/cpp/test/Ice/threadPoolPriority/test.py +++ b/cpp/test/Ice/threadPoolPriority/test.py @@ -6,4 +6,4 @@ TestSuite(__file__, [ ClientServerTestCase(), ClientServerTestCase(name="client/custom server", server="servercustom") - ], options={ "mx" : [False] }) + ], options={"mx": [False]}) diff --git a/cpp/test/IceGrid/admin/test.py b/cpp/test/IceGrid/admin/test.py index 287a643e0eb..344c5bc72bd 100644 --- a/cpp/test/IceGrid/admin/test.py +++ b/cpp/test/IceGrid/admin/test.py @@ -17,7 +17,7 @@ def expect(admin, msg): current.write("testing login with username/password... ") - admin=IceGridAdmin() + admin = IceGridAdmin() admin.start(current) expect(admin, '>>> ') @@ -26,7 +26,7 @@ def expect(admin, msg): admin.sendline(current, 'exit') admin.stop(current, True) - defaultRouterProps = { "Ice.Default.Router" : self.glacier2router.getClientProxy(current) } + defaultRouterProps = {"Ice.Default.Router": self.glacier2router.getClientProxy(current)} admin.start(current, props=defaultRouterProps) expect(admin, '>>> ') @@ -152,15 +152,17 @@ def expect(admin, msg): admin.stop(current, False) raise RuntimeError("failed!\n" + str(e)) -routerProps= lambda process, current: { - 'Glacier2.SessionTimeout' : 5, - 'Glacier2.SessionManager' : 'TestIceGrid/AdminSessionManager', - 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', - 'Glacier2.SSLSessionManager' : 'TestIceGrid/AdminSSLSessionManager', - 'Glacier2.SSLPermissionsVerifier' : 'Glacier2/NullSSLPermissionsVerifier', - 'Ice.Default.Locator' : current.testcase.getLocator(current), - 'IceSSL.VerifyPeer' : 1 + +def routerProps(process, current): return { + 'Glacier2.SessionTimeout': 5, + 'Glacier2.SessionManager': 'TestIceGrid/AdminSessionManager', + 'Glacier2.PermissionsVerifier': 'Glacier2/NullPermissionsVerifier', + 'Glacier2.SSLSessionManager': 'TestIceGrid/AdminSSLSessionManager', + 'Glacier2.SSLPermissionsVerifier': 'Glacier2/NullSSLPermissionsVerifier', + 'Ice.Default.Locator': current.testcase.getLocator(current), + 'IceSSL.VerifyPeer': 1 } + if isinstance(platform, Windows) or os.getuid() != 0: - TestSuite(__file__, [ IceGridAdminTestCase() ], multihost=False) + TestSuite(__file__, [IceGridAdminTestCase()], multihost=False) diff --git a/cpp/test/IceGrid/allocation/test.py b/cpp/test/IceGrid/allocation/test.py index 82b990c9c41..f644ddfd40d 100644 --- a/cpp/test/IceGrid/allocation/test.py +++ b/cpp/test/IceGrid/allocation/test.py @@ -4,4 +4,4 @@ # if isinstance(platform, Windows) or os.getuid() != 0: - TestSuite(__file__, [IceGridTestCase(exevars={ "verifier.dir": "verifier" })], runOnMainThread=True, multihost=False) + TestSuite(__file__, [IceGridTestCase(exevars={"verifier.dir": "verifier"})], runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceGrid/deployer/test.py b/cpp/test/IceGrid/deployer/test.py index 6b274e34675..09cd9f30296 100644 --- a/cpp/test/IceGrid/deployer/test.py +++ b/cpp/test/IceGrid/deployer/test.py @@ -3,15 +3,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -clientProps=lambda process, current: { "TestDir" : current.getBuildDir("server") } +def clientProps(process, current): return {"TestDir": current.getBuildDir("server")} + if isinstance(platform, Windows) or os.getuid() != 0: TestSuite(__file__, [ IceGridTestCase("without targets", - icegridnode=IceGridNode(envs={ "MY_FOO" : 12 }), + icegridnode=IceGridNode(envs={"MY_FOO": 12}), client=IceGridClient(props=clientProps)), IceGridTestCase("with targets", - icegridnode=IceGridNode(envs={ "MY_FOO" : 12 }), + icegridnode=IceGridNode(envs={"MY_FOO": 12}), client=IceGridClient(props=clientProps), targets=["moreservers", "moreservices", "moreproperties"]) ], libDirs=["testservice"], multihost=False) diff --git a/cpp/test/IceGrid/distribution/test.py b/cpp/test/IceGrid/distribution/test.py index 80130d90a25..d9f8984b1a6 100644 --- a/cpp/test/IceGrid/distribution/test.py +++ b/cpp/test/IceGrid/distribution/test.py @@ -11,14 +11,14 @@ def setupClientSide(self, current): datadir = os.path.join(current.testsuite.getPath(), "data") files = [ - [ "original/rootfile", "rootfile" ], - [ "original/dir1/file1", "dummy-file1"], - [ "original/dir1/file2", "dummy-file2"], - [ "original/dir2/file3", "dummy-file3"], - [ "updated/rootfile", "rootfile-updated!" ], - [ "updated/dir1/file2", "dummy-file2-updated!"], - [ "updated/dir2/file3", "dummy-file3"], - [ "updated/dir2/file4", "dummy-file4"], + ["original/rootfile", "rootfile"], + ["original/dir1/file1", "dummy-file1"], + ["original/dir1/file2", "dummy-file2"], + ["original/dir2/file3", "dummy-file3"], + ["updated/rootfile", "rootfile-updated!"], + ["updated/dir1/file2", "dummy-file2-updated!"], + ["updated/dir2/file3", "dummy-file3"], + ["updated/dir2/file4", "dummy-file4"], ] current.write("creating IcePatch2 data directory... ") @@ -37,5 +37,6 @@ def setupClientSide(self, current): current.writeln("ok") + if isinstance(platform, Windows) or os.getuid() != 0: - TestSuite(__file__, [ IceGridDistributionTestCase() ], runOnMainThread=True, multihost=False) + TestSuite(__file__, [IceGridDistributionTestCase()], runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceGrid/fileLock/test.py b/cpp/test/IceGrid/fileLock/test.py index 11055392cad..03733519563 100644 --- a/cpp/test/IceGrid/fileLock/test.py +++ b/cpp/test/IceGrid/fileLock/test.py @@ -8,10 +8,11 @@ class IceGridAdminTestCase(IceGridTestCase): def runClientSide(self, current): sys.stdout.write("testing IceGrid file lock... ") - registry = IceGridRegistryMaster(portnum=25, ready="", quiet=True); + registry = IceGridRegistryMaster(portnum=25, ready="", quiet=True) registry.start(current) registry.expect(current, ".*IceUtil::FileLockException.*") registry.stop(current, False) print("ok") -TestSuite(__file__, [ IceGridAdminTestCase(application=None) ], runOnMainThread=True, multihost=False) + +TestSuite(__file__, [IceGridAdminTestCase(application=None)], runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceGrid/noRestartUpdate/test.py b/cpp/test/IceGrid/noRestartUpdate/test.py index b2e2d3ecf0f..b5901db87e2 100644 --- a/cpp/test/IceGrid/noRestartUpdate/test.py +++ b/cpp/test/IceGrid/noRestartUpdate/test.py @@ -10,12 +10,14 @@ def setupClientSide(self, current): current.mkdirs("db/node1") current.mkdirs("db/node2") -clientProps = lambda process, current: { - "IceBoxExe" : IceBox().getCommandLine(current), - "ServerDir" : current.getBuildDir("server"), - "ServiceDir" : current.getBuildDir("testservice") + +def clientProps(process, current): return { + "IceBoxExe": IceBox().getCommandLine(current), + "ServerDir": current.getBuildDir("server"), + "ServiceDir": current.getBuildDir("testservice") } + if isinstance(platform, Windows) or os.getuid() != 0: TestSuite(__file__, [IceGridNoRestartUpdateTestCase(application=None, client=IceGridClient(props=clientProps))], diff --git a/cpp/test/IceGrid/replicaGroup/test.py b/cpp/test/IceGrid/replicaGroup/test.py index 988cfaed8e5..66a71480dd4 100644 --- a/cpp/test/IceGrid/replicaGroup/test.py +++ b/cpp/test/IceGrid/replicaGroup/test.py @@ -4,8 +4,8 @@ # registryProps = { - "Ice.Plugin.RegistryPlugin" : "RegistryPlugin:createRegistryPlugin", - "IceGrid.Registry.DynamicRegistration" : 1 + "Ice.Plugin.RegistryPlugin": "RegistryPlugin:createRegistryPlugin", + "IceGrid.Registry.DynamicRegistration": 1 } registryTraceProps = { "IceGrid.Registry.Trace.Locator": 2, @@ -16,7 +16,7 @@ } clientProps = { - "Ice.RetryIntervals" : "0 50 100 250" + "Ice.RetryIntervals": "0 50 100 250" } clientTraceProps = { "Ice.Trace.Locator": 2, diff --git a/cpp/test/IceGrid/replication/test.py b/cpp/test/IceGrid/replication/test.py index 079a08a495d..af53cf130c8 100644 --- a/cpp/test/IceGrid/replication/test.py +++ b/cpp/test/IceGrid/replication/test.py @@ -3,18 +3,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -clientProps = lambda process, current: { "ServerDir" : current.getBuildDir("server") } +def clientProps(process, current): return {"ServerDir": current.getBuildDir("server")} + # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Network" : 2, - "Ice.Trace.Retry" : 1, - "Ice.Trace.Protocol" : 1, + "Ice.Trace.Network": 2, + "Ice.Trace.Retry": 1, + "Ice.Trace.Protocol": 1, "Ice.ACM.Client.Heartbeat": 2 } if isinstance(platform, Windows) or os.getuid() != 0: TestSuite(__file__, - [ IceGridTestCase(client=IceGridClient(props=clientProps, traceProps=traceProps)) ], + [IceGridTestCase(client=IceGridClient(props=clientProps, traceProps=traceProps))], runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceGrid/session/test.py b/cpp/test/IceGrid/session/test.py index 49dfc35acc5..35b81626c7c 100644 --- a/cpp/test/IceGrid/session/test.py +++ b/cpp/test/IceGrid/session/test.py @@ -11,7 +11,7 @@ def setupClientSide(self, current): def setupServerSide(self, current): self.verifier = Server(exe="verifier", waitForShutdown=False, props={ - "PermissionsVerifier.Endpoints" : "tcp -p 12002" + "PermissionsVerifier.Endpoints": "tcp -p 12002" }) current.write("starting permission verifier... ") self.verifier.start(current) @@ -21,36 +21,40 @@ def teardownServerSide(self, current, success): self.verifier.stop(current, success) self.verifier = None + registryProps = { - 'Ice.Warn.Dispatch' : '0', - 'IceGrid.Registry.DynamicRegistration' : True, - 'IceGrid.Registry.SessionFilters' : True, - 'IceGrid.Registry.AdminSessionFilters' : True, - 'IceGrid.Registry.PermissionsVerifier' : 'ClientPermissionsVerifier', - 'IceGrid.Registry.AdminPermissionsVerifier' : 'AdminPermissionsVerifier:tcp -p 12002', - 'IceGrid.Registry.SSLPermissionsVerifier' : 'SSLPermissionsVerifier', - 'IceGrid.Registry.AdminSSLPermissionsVerifier' : 'SSLPermissionsVerifier', + 'Ice.Warn.Dispatch': '0', + 'IceGrid.Registry.DynamicRegistration': True, + 'IceGrid.Registry.SessionFilters': True, + 'IceGrid.Registry.AdminSessionFilters': True, + 'IceGrid.Registry.PermissionsVerifier': 'ClientPermissionsVerifier', + 'IceGrid.Registry.AdminPermissionsVerifier': 'AdminPermissionsVerifier:tcp -p 12002', + 'IceGrid.Registry.SSLPermissionsVerifier': 'SSLPermissionsVerifier', + 'IceGrid.Registry.AdminSSLPermissionsVerifier': 'SSLPermissionsVerifier', } -clientProps = lambda process, current: { - "IceGridNodeExe" : IceGridNode().getCommandLine(current), - "ServerDir" : current.getBuildDir("server"), - "TestDir" : "{testdir}", + +def clientProps(process, current): return { + "IceGridNodeExe": IceGridNode().getCommandLine(current), + "ServerDir": current.getBuildDir("server"), + "TestDir": "{testdir}", } -clientProps10 = lambda process, current: { - "IceGridNodeExe" : IceGridNode().getCommandLine(current), - "ServerDir" : current.getBuildDir("server"), - "TestDir" : "{testdir}", - "Ice.Default.EncodingVersion" : "1.0" + +def clientProps10(process, current): return { + "IceGridNodeExe": IceGridNode().getCommandLine(current), + "ServerDir": current.getBuildDir("server"), + "TestDir": "{testdir}", + "Ice.Default.EncodingVersion": "1.0" } + icegridregistry = [IceGridRegistryMaster(props=registryProps)] if isinstance(platform, Windows) or os.getuid() != 0: TestSuite(__file__, - [ IceGridSessionTestCase("with default encoding", icegridregistry=icegridregistry, - client=IceGridClient(props=clientProps)), - IceGridSessionTestCase("with 1.0 encoding", icegridregistry=icegridregistry, - client=IceGridClient(props=clientProps10))], - runOnMainThread=True, multihost=False) + [IceGridSessionTestCase("with default encoding", icegridregistry=icegridregistry, + client=IceGridClient(props=clientProps)), + IceGridSessionTestCase("with 1.0 encoding", icegridregistry=icegridregistry, + client=IceGridClient(props=clientProps10))], + runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceGrid/update/test.py b/cpp/test/IceGrid/update/test.py index d13c25ba817..be99848f546 100644 --- a/cpp/test/IceGrid/update/test.py +++ b/cpp/test/IceGrid/update/test.py @@ -10,13 +10,16 @@ def setupClientSide(self, current): current.mkdirs("db/node-1") current.mkdirs("db/node-2") -clientProps = lambda process, current: { - "NodePropertiesOverride" : current.testcase.icegridnode[0].getPropertiesOverride(current), - "IceBoxExe" : IceBox().getCommandLine(current), - "IceGridNodeExe" : IceGridNode().getCommandLine(current), - "ServerDir" : current.getBuildDir("server"), - "TestDir" : "{testdir}" + +def clientProps(process, current): return { + "NodePropertiesOverride": current.testcase.icegridnode[0].getPropertiesOverride(current), + "IceBoxExe": IceBox().getCommandLine(current), + "IceGridNodeExe": IceGridNode().getCommandLine(current), + "ServerDir": current.getBuildDir("server"), + "TestDir": "{testdir}" } + if isinstance(platform, Windows) or os.getuid() != 0: - TestSuite(__file__, [IceGridUpdateTestCase(application=None, client=IceGridClient(props=clientProps))], multihost=False) + TestSuite(__file__, [IceGridUpdateTestCase(application=None, + client=IceGridClient(props=clientProps))], multihost=False) diff --git a/cpp/test/IceSSL/certs/makecerts.py b/cpp/test/IceSSL/certs/makecerts.py index ce56c0a046c..17b1b110670 100755 --- a/cpp/test/IceSSL/certs/makecerts.py +++ b/cpp/test/IceSSL/certs/makecerts.py @@ -3,7 +3,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, socket, getopt +import os +import sys +import socket +import getopt try: import IceCertUtils @@ -16,6 +19,7 @@ print("openssl is required to generate the test certificates") sys.exit(1) + def usage(): print("Usage: " + sys.argv[0] + " [options]") print("") @@ -26,12 +30,14 @@ def usage(): print("--force Re-save all the files even if they already exists.") sys.exit(1) + def runCommands(commands): for command in commands: if os.system(command) != 0: print("error running command `{0}'".format(command)) sys.exit(1) + # # Check arguments # @@ -103,31 +109,41 @@ def runCommands(commands): # for ca, name in [(ca1, "cacert1"), (ca2, "cacert2"), (ca3, "cacert3"), (ca4, "cacert4")]: pem = "{}.pem".format(name) - if force or not os.path.exists(pem): ca.getCA().save(pem) + if force or not os.path.exists(pem): + ca.getCA().save(pem) der = "{}.der".format(name) - if force or not os.path.exists(der): ca.getCA().save(der) + if force or not os.path.exists(der): + ca.getCA().save(der) if force or not os.path.exists("cacerts.pem"): pem = "" - with open("cacert1.pem", "r") as f: pem += f.read() - with open("cacert2.pem", "r") as f: pem += f.read() - with open("cacert3.pem", "r") as f: pem += f.read() - with open("cacert4.pem", "r") as f: pem += f.read() - with open("cacerts.pem", "w") as f: f.write(pem) + with open("cacert1.pem", "r") as f: + pem += f.read() + with open("cacert2.pem", "r") as f: + pem += f.read() + with open("cacert3.pem", "r") as f: + pem += f.read() + with open("cacert4.pem", "r") as f: + pem += f.read() + with open("cacerts.pem", "w") as f: + f.write(pem) # Also export the ca2 self-signed certificate, it's used by the tests to test self-signed certificates -if force or not os.path.exists("cacert2_pub.pem"): ca2.getCA().save("cacert2_pub.pem") -if force or not os.path.exists("cacert2_priv.pem"): ca2.getCA().saveKey("cacert2_priv.pem") -if force or not os.path.exists("cacert2.p12"): ca2.getCA().save("cacert2.p12", addkey=True) +if force or not os.path.exists("cacert2_pub.pem"): + ca2.getCA().save("cacert2_pub.pem") +if force or not os.path.exists("cacert2_priv.pem"): + ca2.getCA().saveKey("cacert2_priv.pem") +if force or not os.path.exists("cacert2.p12"): + ca2.getCA().save("cacert2.p12", addkey=True) # Create intermediate CAs cai1 = ca1.getIntermediateFactory("intermediate1") if not cai1: - cai1 = ca1.createIntermediateFactory("intermediate1", cn = "ZeroC Test Intermediate CA 1") + cai1 = ca1.createIntermediateFactory("intermediate1", cn="ZeroC Test Intermediate CA 1") cai2 = cai1.getIntermediateFactory("intermediate1") if not cai2: - cai2 = cai1.createIntermediateFactory("intermediate1", cn = "ZeroC Test Intermediate CA 2") + cai2 = cai1.createIntermediateFactory("intermediate1", cn="ZeroC Test Intermediate CA 2") cai3 = ca3.getIntermediateFactory("intermediate1") if not cai3: @@ -135,8 +151,10 @@ def runCommands(commands): cn="ZeroC Test Intermediate CA 3", crlDistributionPoints="http://127.0.0.1:20001/cai3.crl.pem") -if force or not os.path.exists("cai3.pem"): cai3.getCA().save("cai3.pem") -if force or not os.path.exists("cai3.der"): cai3.getCA().save("cai3.der") +if force or not os.path.exists("cai3.pem"): + cai3.getCA().save("cai3.pem") +if force or not os.path.exists("cai3.der"): + cai3.getCA().save("cai3.der") cai4 = ca4.getIntermediateFactory("intermediate1") if not cai4: @@ -145,62 +163,64 @@ def runCommands(commands): ocspResponder="http://127.0.0.1:20002", caIssuers="http://127.0.0.1:20001/cai4.der") -if force or not os.path.exists("cai4.pem"): cai4.getCA().save("cai4.pem") -if force or not os.path.exists("cai4.der"): cai4.getCA().save("cai4.der") +if force or not os.path.exists("cai4.pem"): + cai4.getCA().save("cai4.pem") +if force or not os.path.exists("cai4.der"): + cai4.getCA().save("cai4.der") # # Create certificates (CA, alias, { creation parameters passed to ca.create(...) }) # certs = [ - (ca1, "s_rsa_ca1", { "cn": "Server", "ip": "127.0.0.1", "dns": "server", "serial": 1 }), - (ca1, "c_rsa_ca1", { "cn": "Client", "ip": "127.0.0.1", "dns": "client", "serial": 2 }), - (ca1, "s_rsa_ca1_exp", { "cn": "Server", "validity": -1 }), # Expired certificate - (ca1, "c_rsa_ca1_exp", { "cn": "Client", "validity": -1 }), # Expired certificate - - (ca1, "s_rsa_ca1_cn1", { "cn": "Server", "dns": "localhost" }), # DNS subjectAltName localhost - (ca1, "s_rsa_ca1_cn2", { "cn": "Server", "dns": "localhostXX" }), # DNS subjectAltName localhostXX - (ca1, "s_rsa_ca1_cn3", { "cn": "localhost" }), # No subjectAltName, CN=localhost - (ca1, "s_rsa_ca1_cn4", { "cn": "localhostXX" }), # No subjectAltName, CN=localhostXX - (ca1, "s_rsa_ca1_cn5", { "cn": "localhost", "dns": "localhostXX" }), # DNS subjectAltName localhostXX, CN=localhost - (ca1, "s_rsa_ca1_cn6", { "cn": "Server", "ip": "127.0.0.1" }), # IP subjectAltName 127.0.0.1 - (ca1, "s_rsa_ca1_cn7", { "cn": "Server", "ip": "127.0.0.2" }), # IP subjectAltName 127.0.0.2 - (ca1, "s_rsa_ca1_cn8", { "cn": "127.0.0.1" }), # No subjectAltName, CN=127.0.0.1 - (ca1, "s_rsa_ca1_cn9", { "cn": "127.0.0.1", "ip": ["127.0.0.1", "::1"] }), - (ca1, "s_rsa_ca1_cn10", { "cn": "127.0.0.1", "dns": ["host1", "host2"] }), - (ca1, "s_rsa_ca1_cn11", { "cn": "127.0.0.1", "ip": ["127.0.0.1", "127.0.0.2"], "dns": ["host1", "host2"] }), - - (ca2, "s_rsa_ca2", { "cn": "Server", "ip": "127.0.0.1", "dns": "server" }), - (ca2, "c_rsa_ca2", { "cn": "Client", "ip": "127.0.0.1", "dns": "client" }), - (dsaca, "s_dsa_ca1", { "cn": "Server", "ip": "127.0.0.1", "dns": "server" }), # DSA - (dsaca, "c_dsa_ca1", { "cn": "Client", "ip": "127.0.0.1", "dns": "client" }), # DSA - (cai1, "s_rsa_cai1", { "cn": "Server", "ip": "127.0.0.1", "dns": "server" }), - (cai2, "s_rsa_cai2", { "cn": "Server", "ip": "127.0.0.1", "dns": "server" }), - (cai2, "c_rsa_cai2", { "cn": "Client", "ip": "127.0.0.1", "dns": "client" }), + (ca1, "s_rsa_ca1", {"cn": "Server", "ip": "127.0.0.1", "dns": "server", "serial": 1}), + (ca1, "c_rsa_ca1", {"cn": "Client", "ip": "127.0.0.1", "dns": "client", "serial": 2}), + (ca1, "s_rsa_ca1_exp", {"cn": "Server", "validity": -1}), # Expired certificate + (ca1, "c_rsa_ca1_exp", {"cn": "Client", "validity": -1}), # Expired certificate + + (ca1, "s_rsa_ca1_cn1", {"cn": "Server", "dns": "localhost"}), # DNS subjectAltName localhost + (ca1, "s_rsa_ca1_cn2", {"cn": "Server", "dns": "localhostXX"}), # DNS subjectAltName localhostXX + (ca1, "s_rsa_ca1_cn3", {"cn": "localhost"}), # No subjectAltName, CN=localhost + (ca1, "s_rsa_ca1_cn4", {"cn": "localhostXX"}), # No subjectAltName, CN=localhostXX + (ca1, "s_rsa_ca1_cn5", {"cn": "localhost", "dns": "localhostXX"}), # DNS subjectAltName localhostXX, CN=localhost + (ca1, "s_rsa_ca1_cn6", {"cn": "Server", "ip": "127.0.0.1"}), # IP subjectAltName 127.0.0.1 + (ca1, "s_rsa_ca1_cn7", {"cn": "Server", "ip": "127.0.0.2"}), # IP subjectAltName 127.0.0.2 + (ca1, "s_rsa_ca1_cn8", {"cn": "127.0.0.1"}), # No subjectAltName, CN=127.0.0.1 + (ca1, "s_rsa_ca1_cn9", {"cn": "127.0.0.1", "ip": ["127.0.0.1", "::1"]}), + (ca1, "s_rsa_ca1_cn10", {"cn": "127.0.0.1", "dns": ["host1", "host2"]}), + (ca1, "s_rsa_ca1_cn11", {"cn": "127.0.0.1", "ip": ["127.0.0.1", "127.0.0.2"], "dns": ["host1", "host2"]}), + + (ca2, "s_rsa_ca2", {"cn": "Server", "ip": "127.0.0.1", "dns": "server"}), + (ca2, "c_rsa_ca2", {"cn": "Client", "ip": "127.0.0.1", "dns": "client"}), + (dsaca, "s_dsa_ca1", {"cn": "Server", "ip": "127.0.0.1", "dns": "server"}), # DSA + (dsaca, "c_dsa_ca1", {"cn": "Client", "ip": "127.0.0.1", "dns": "client"}), # DSA + (cai1, "s_rsa_cai1", {"cn": "Server", "ip": "127.0.0.1", "dns": "server"}), + (cai2, "s_rsa_cai2", {"cn": "Server", "ip": "127.0.0.1", "dns": "server"}), + (cai2, "c_rsa_cai2", {"cn": "Client", "ip": "127.0.0.1", "dns": "client"}), # Certificates with CRL distribution points - (ca3, "s_rsa_ca3", { "cn": "Server", "ip": "127.0.0.1", "dns": "server" }), - (ca3, "c_rsa_ca3", { "cn": "Client", "ip": "127.0.0.1", "dns": "client" }), - (ca3, "s_rsa_ca3_revoked", { "cn": "Server ca3 revoked", "ip": "127.0.0.1", "dns": "server" }), - (ca3, "c_rsa_ca3_revoked", { "cn": "Client ca3 revoked", "ip": "127.0.0.1", "dns": "client" }), + (ca3, "s_rsa_ca3", {"cn": "Server", "ip": "127.0.0.1", "dns": "server"}), + (ca3, "c_rsa_ca3", {"cn": "Client", "ip": "127.0.0.1", "dns": "client"}), + (ca3, "s_rsa_ca3_revoked", {"cn": "Server ca3 revoked", "ip": "127.0.0.1", "dns": "server"}), + (ca3, "c_rsa_ca3_revoked", {"cn": "Client ca3 revoked", "ip": "127.0.0.1", "dns": "client"}), - (cai3, "s_rsa_cai3", { "cn": "Server cai3", "ip": "127.0.0.1", "dns": "server" }), - (cai3, "c_rsa_cai3", { "cn": "Client cai3", "ip": "127.0.0.1", "dns": "client" }), - (cai3, "s_rsa_cai3_revoked", { "cn": "Server cai3 revoked", "ip": "127.0.0.1", "dns": "server" }), - (cai3, "c_rsa_cai3_revoked", { "cn": "Client cai3 revoked", "ip": "127.0.0.1", "dns": "client" }), + (cai3, "s_rsa_cai3", {"cn": "Server cai3", "ip": "127.0.0.1", "dns": "server"}), + (cai3, "c_rsa_cai3", {"cn": "Client cai3", "ip": "127.0.0.1", "dns": "client"}), + (cai3, "s_rsa_cai3_revoked", {"cn": "Server cai3 revoked", "ip": "127.0.0.1", "dns": "server"}), + (cai3, "c_rsa_cai3_revoked", {"cn": "Client cai3 revoked", "ip": "127.0.0.1", "dns": "client"}), # Certificates with AIA extension - (ca4, "s_rsa_ca4", { "cn": "Server ca4", "ip": "127.0.0.1", "dns": "server" }), - (ca4, "c_rsa_ca4", { "cn": "Client ca4", "ip": "127.0.0.1", "dns": "client" }), - (ca4, "s_rsa_ca4_revoked", { "cn": "Server ca4 revoked", "ip": "127.0.0.1", "dns": "server" }), - (ca4, "c_rsa_ca4_revoked", { "cn": "Client ca4 revoked", "ip": "127.0.0.1", "dns": "client" }), + (ca4, "s_rsa_ca4", {"cn": "Server ca4", "ip": "127.0.0.1", "dns": "server"}), + (ca4, "c_rsa_ca4", {"cn": "Client ca4", "ip": "127.0.0.1", "dns": "client"}), + (ca4, "s_rsa_ca4_revoked", {"cn": "Server ca4 revoked", "ip": "127.0.0.1", "dns": "server"}), + (ca4, "c_rsa_ca4_revoked", {"cn": "Client ca4 revoked", "ip": "127.0.0.1", "dns": "client"}), # The OCSP responder doesn't know about this certs - (ca4, "s_rsa_ca4_unknown", { "cn": "Server ca4 unknown", "ip": "127.0.0.1", "dns": "server" }), - (ca4, "c_rsa_ca4_unknown", { "cn": "Client ca4 unknown", "ip": "127.0.0.1", "dns": "client" }), + (ca4, "s_rsa_ca4_unknown", {"cn": "Server ca4 unknown", "ip": "127.0.0.1", "dns": "server"}), + (ca4, "c_rsa_ca4_unknown", {"cn": "Client ca4 unknown", "ip": "127.0.0.1", "dns": "client"}), - (cai4, "s_rsa_cai4", { "cn": "Server cai4", "ip": "127.0.0.1", "dns": "server" }), - (cai4, "c_rsa_cai4", { "cn": "Client cai4", "ip": "127.0.0.1", "dns": "client" }), - (cai4, "s_rsa_cai4_revoked", { "cn": "Server cai4 revoked", "ip": "127.0.0.1", "dns": "server" }), - (cai4, "c_rsa_cai4_revoked", { "cn": "Client cai4 revoked", "ip": "127.0.0.1", "dns": "client" }), + (cai4, "s_rsa_cai4", {"cn": "Server cai4", "ip": "127.0.0.1", "dns": "server"}), + (cai4, "c_rsa_cai4", {"cn": "Client cai4", "ip": "127.0.0.1", "dns": "client"}), + (cai4, "s_rsa_cai4_revoked", {"cn": "Server cai4 revoked", "ip": "127.0.0.1", "dns": "server"}), + (cai4, "c_rsa_cai4_revoked", {"cn": "Client cai4 revoked", "ip": "127.0.0.1", "dns": "client"}), ] # @@ -212,12 +232,12 @@ def runCommands(commands): # Additional certs for extended key usage testing certs = [ - (ca1, "rsa_ca1_none", None, { "cn": "None"}), - (ca1, "rsa_ca1_serverAuth", "serverAuth", { "cn": "Server Auth"}), - (ca1, "rsa_ca1_clientAuth", "clientAuth", { "cn": "Client Auth"}), - (ca1, "rsa_ca1_codeSigning", "codeSigning", { "cn": "Code Signing"}), - (ca1, "rsa_ca1_emailProtection", "emailProtection", { "cn": "Email Protection"}), - (ca1, "rsa_ca1_timeStamping", "timeStamping", { "cn": "Time Stamping"}), + (ca1, "rsa_ca1_none", None, {"cn": "None"}), + (ca1, "rsa_ca1_serverAuth", "serverAuth", {"cn": "Server Auth"}), + (ca1, "rsa_ca1_clientAuth", "clientAuth", {"cn": "Client Auth"}), + (ca1, "rsa_ca1_codeSigning", "codeSigning", {"cn": "Code Signing"}), + (ca1, "rsa_ca1_emailProtection", "emailProtection", {"cn": "Email Protection"}), + (ca1, "rsa_ca1_timeStamping", "timeStamping", {"cn": "Time Stamping"}), (ca1, "rsa_ca1_ocspSigning", "OCSPSigning", {"cn": "OCSP Signing"}), (ca1, "rsa_ca1_anyExtendedKeyUsage", "anyExtendedKeyUsage", {"cn": "Any Extended Key Usage"}) ] @@ -227,70 +247,71 @@ def runCommands(commands): ca.create(alias, extendedKeyUsage=extendedKeyUsage, **args) savecerts = [ - (ca1, "s_rsa_ca1", None, {}), - (ca1, "c_rsa_ca1", None, {}), - (ca1, "s_rsa_ca1_exp", None, {}), - (ca1, "c_rsa_ca1_exp", None, {}), - (ca1, "s_rsa_ca1_cn1", None, {}), - (ca1, "s_rsa_ca1_cn2", None, {}), - (ca1, "s_rsa_ca1_cn3", None, {}), - (ca1, "s_rsa_ca1_cn4", None, {}), - (ca1, "s_rsa_ca1_cn5", None, {}), - (ca1, "s_rsa_ca1_cn6", None, {}), - (ca1, "s_rsa_ca1_cn7", None, {}), - (ca1, "s_rsa_ca1_cn8", None, {}), - (ca1, "s_rsa_ca1_cn9", None, {}), - (ca1, "s_rsa_ca1_cn10", None, {}), - (ca1, "s_rsa_ca1_cn11", None, {}), - - (ca1, "rsa_ca1_none", None, {}), - (ca1, "rsa_ca1_serverAuth", None, {}), - (ca1, "rsa_ca1_clientAuth", None, {}), - (ca1, "rsa_ca1_codeSigning", None, {}), - (ca1, "rsa_ca1_emailProtection", None, {}), - (ca1, "rsa_ca1_timeStamping", None, {}), - (ca1, "rsa_ca1_ocspSigning", None, {}), + (ca1, "s_rsa_ca1", None, {}), + (ca1, "c_rsa_ca1", None, {}), + (ca1, "s_rsa_ca1_exp", None, {}), + (ca1, "c_rsa_ca1_exp", None, {}), + (ca1, "s_rsa_ca1_cn1", None, {}), + (ca1, "s_rsa_ca1_cn2", None, {}), + (ca1, "s_rsa_ca1_cn3", None, {}), + (ca1, "s_rsa_ca1_cn4", None, {}), + (ca1, "s_rsa_ca1_cn5", None, {}), + (ca1, "s_rsa_ca1_cn6", None, {}), + (ca1, "s_rsa_ca1_cn7", None, {}), + (ca1, "s_rsa_ca1_cn8", None, {}), + (ca1, "s_rsa_ca1_cn9", None, {}), + (ca1, "s_rsa_ca1_cn10", None, {}), + (ca1, "s_rsa_ca1_cn11", None, {}), + + (ca1, "rsa_ca1_none", None, {}), + (ca1, "rsa_ca1_serverAuth", None, {}), + (ca1, "rsa_ca1_clientAuth", None, {}), + (ca1, "rsa_ca1_codeSigning", None, {}), + (ca1, "rsa_ca1_emailProtection", None, {}), + (ca1, "rsa_ca1_timeStamping", None, {}), + (ca1, "rsa_ca1_ocspSigning", None, {}), (ca1, "rsa_ca1_anyExtendedKeyUsage", None, {}), - (ca2, "s_rsa_ca2", None, {}), - (ca2, "c_rsa_ca2", None, {}), - (dsaca, "s_dsa_ca1", None, {}), - (dsaca, "c_dsa_ca1", None, {}), - (cai1, "s_rsa_cai1", None, {}), - (cai2, "s_rsa_cai2", None, {}), - (cai2, "c_rsa_cai2", None, {}), - (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", { "root": True }), - (ca1, "s_rsa_ca1", "s_rsa_pass_ca1", { "password": "server" }), - (ca1, "c_rsa_ca1", "c_rsa_pass_ca1", { "password": "client" }), - - (ca3, "s_rsa_ca3", None, {} ), - (ca3, "c_rsa_ca3", None, {} ), - (ca3, "s_rsa_ca3_revoked", None, {} ), - (ca3, "c_rsa_ca3_revoked", None, {} ), - - (cai3, "s_rsa_cai3", None, {} ), - (cai3, "c_rsa_cai3", None, {} ), - (cai3, "s_rsa_cai3_revoked", None, {} ), - (cai3, "c_rsa_cai3_revoked", None, {} ), - - (ca4, "s_rsa_ca4", None, {} ), - (ca4, "c_rsa_ca4", None, {} ), - (ca4, "s_rsa_ca4_revoked", None, {} ), - (ca4, "c_rsa_ca4_revoked", None, {} ), - (ca4, "s_rsa_ca4_unknown", None, {} ), - (ca4, "c_rsa_ca4_unknown", None, {} ), - - (cai4, "s_rsa_cai4", None, {} ), - (cai4, "c_rsa_cai4", None, {} ), - (cai4, "s_rsa_cai4_revoked", None, {} ), - (cai4, "c_rsa_cai4_revoked", None, {} ), + (ca2, "s_rsa_ca2", None, {}), + (ca2, "c_rsa_ca2", None, {}), + (dsaca, "s_dsa_ca1", None, {}), + (dsaca, "c_dsa_ca1", None, {}), + (cai1, "s_rsa_cai1", None, {}), + (cai2, "s_rsa_cai2", None, {}), + (cai2, "c_rsa_cai2", None, {}), + (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", {"root": True}), + (ca1, "s_rsa_ca1", "s_rsa_pass_ca1", {"password": "server"}), + (ca1, "c_rsa_ca1", "c_rsa_pass_ca1", {"password": "client"}), + + (ca3, "s_rsa_ca3", None, {}), + (ca3, "c_rsa_ca3", None, {}), + (ca3, "s_rsa_ca3_revoked", None, {}), + (ca3, "c_rsa_ca3_revoked", None, {}), + + (cai3, "s_rsa_cai3", None, {}), + (cai3, "c_rsa_cai3", None, {}), + (cai3, "s_rsa_cai3_revoked", None, {}), + (cai3, "c_rsa_cai3_revoked", None, {}), + + (ca4, "s_rsa_ca4", None, {}), + (ca4, "c_rsa_ca4", None, {}), + (ca4, "s_rsa_ca4_revoked", None, {}), + (ca4, "c_rsa_ca4_revoked", None, {}), + (ca4, "s_rsa_ca4_unknown", None, {}), + (ca4, "c_rsa_ca4_unknown", None, {}), + + (cai4, "s_rsa_cai4", None, {}), + (cai4, "c_rsa_cai4", None, {}), + (cai4, "s_rsa_cai4_revoked", None, {}), + (cai4, "c_rsa_cai4_revoked", None, {}), ] # # Save the certificates in PEM and PKCS12 format. # for (ca, alias, path, args) in savecerts: - if not path: path = alias + if not path: + path = alias password = args.get("password", None) cert = ca.get(alias) if force or not os.path.exists(path + "_pub.pem"): @@ -322,6 +343,7 @@ def runCommands(commands): if os.path.exists("cacert_custom.csr"): os.remove("cacert_custom.csr") + def revokeCertificates(ca, cadir, certs): crlnumber = "{}/crlnumber".format(cadir) crlindex = "{}/index.txt".format(cadir) @@ -349,6 +371,7 @@ def revokeCertificates(ca, cadir, certs): "openssl ca -config {ca}.cnf -gencrl -out {ca}.crl.pem -crldays 825 -passin pass:password".format(ca=ca)) runCommands(commands) + crlfile = "ca.crl.pem" if force or not os.path.exists(crlfile): revokeCertificates("ca3", "db/ca3", ["s_rsa_ca3_revoked.pem", @@ -361,7 +384,6 @@ def revokeCertificates(ca, cadir, certs): "intermediate1/ca.pem"]) revokeCertificates("cai4", "db/ca4/intermediate1", ["s_rsa_cai4_revoked.pem", "c_rsa_cai4_revoked.pem"]) - # Concatenate CRL files if os.path.exists(crlfile): os.unlink(crlfile) diff --git a/cpp/test/IceStorm/federation/test.py b/cpp/test/IceStorm/federation/test.py index df740b30aeb..80d421afb5f 100644 --- a/cpp/test/IceStorm/federation/test.py +++ b/cpp/test/IceStorm/federation/test.py @@ -21,14 +21,15 @@ def teardownClientSide(self, current, success): self.runadmin(current, "destroy fed1 fed2 fed3") self.shutdown(current) + # Override ReplicatedPublishEndpoints property to empty for testing without replicated publisher -props = {'IceStorm.ReplicatedPublishEndpoints' : ''} +props = {'IceStorm.ReplicatedPublishEndpoints': ''} TestSuite(__file__, [ IceStormFederationTestCase("persistent", icestorm=IceStorm()), IceStormFederationTestCase("transient", icestorm=IceStorm(transient=True)), IceStormFederationTestCase("replicated with non-replicated publisher", - icestorm=[IceStorm(replica=i, nreplicas=3, props=props) for i in range(0,3)]), + icestorm=[IceStorm(replica=i, nreplicas=3, props=props) for i in range(0, 3)]), IceStormFederationTestCase("replicated with replicated publisher", - icestorm=[IceStorm(replica=i, nreplicas=3) for i in range(0,3)]), + icestorm=[IceStorm(replica=i, nreplicas=3) for i in range(0, 3)]), ], multihost=False) diff --git a/cpp/test/IceStorm/federation2/test.py b/cpp/test/IceStorm/federation2/test.py index 396546cd211..b01a3b3881a 100644 --- a/cpp/test/IceStorm/federation2/test.py +++ b/cpp/test/IceStorm/federation2/test.py @@ -7,10 +7,11 @@ # Publisher/subscriber test cases, publisher publishes on TestIceStorm1 instance(s) and # the subscriber subscribes to the TestIceStorm2 instance(s) # -pub1Sub2Oneway=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2")) -pub1Sub2Batch=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2", args=["-b"])) +pub1Sub2Oneway = ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2")) +pub1Sub2Batch = ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2", args=["-b"])) + +pub1Sub1Oneway = ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm1")) -pub1Sub1Oneway=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm1")) class IceStormFederation2TestCase(IceStormTestCase): @@ -156,7 +157,7 @@ def runClientSide(self, current): nRetry = 5 while len(line) > 0 and nRetry > 0: line = self.runadmin(current, "links TestIceStorm1") - time.sleep(1) # Give more time for unsubscription to propagate. + time.sleep(1) # Give more time for unsubscription to propagate. nRetry -= 1 if len(line) > 0: raise RuntimeError("unexpected output (`{0}')".format(line)) @@ -171,21 +172,19 @@ def runClientSide(self, current): self.stopIceStorm(current) + # Override ReplicatedPublishEndpoints property to empty for testing without replicated publisher -props = { 'IceStorm.Discard.Interval' : 2 } -nonRepProps = { 'IceStorm.Discard.Interval' : 2, 'IceStorm.ReplicatedPublishEndpoints' : '' } +props = {'IceStorm.Discard.Interval': 2} +nonRepProps = {'IceStorm.Discard.Interval': 2, 'IceStorm.ReplicatedPublishEndpoints': ''} TestSuite(__file__, [ - IceStormFederation2TestCase("persistent", icestorm= - [IceStorm("TestIceStorm1", quiet=True, props=props), - IceStorm("TestIceStorm2", quiet=True,portnum=20, props=props)]), + IceStormFederation2TestCase("persistent", icestorm=[IceStorm("TestIceStorm1", quiet=True, props=props), + IceStorm("TestIceStorm2", quiet=True, portnum=20, props=props)]), - IceStormFederation2TestCase("replicated with non-replicated publisher", icestorm= - [IceStorm("TestIceStorm1", i, 3, quiet=True, props=nonRepProps) for i in range(0,3)] + - [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=nonRepProps) for i in range(0,3)]), + IceStormFederation2TestCase("replicated with non-replicated publisher", icestorm=[IceStorm("TestIceStorm1", i, 3, quiet=True, props=nonRepProps) for i in range(0, 3)] + + [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=nonRepProps) for i in range(0, 3)]), - IceStormFederation2TestCase("replicated with replicated publisher", icestorm= - [IceStorm("TestIceStorm1", i, 3, quiet=True, props=props) for i in range(0,3)] + - [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=props) for i in range(0,3)]), + IceStormFederation2TestCase("replicated with replicated publisher", icestorm=[IceStorm("TestIceStorm1", i, 3, quiet=True, props=props) for i in range(0, 3)] + + [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=props) for i in range(0, 3)]), ], multihost=False) diff --git a/cpp/test/IceStorm/persistent/test.py b/cpp/test/IceStorm/persistent/test.py index 6a7b5b7c243..f59a122d367 100644 --- a/cpp/test/IceStorm/persistent/test.py +++ b/cpp/test/IceStorm/persistent/test.py @@ -47,6 +47,7 @@ def teardownClientSide(self, current, success): self.icestorm.shutdown(current) + class PersistentClient(IceStormProcess, Client): processType = "client" @@ -55,7 +56,8 @@ def __init__(self, instanceName=None, instance=None, *args, **kargs): Client.__init__(self, *args, **kargs) IceStormProcess.__init__(self, instanceName, instance) - getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + TestSuite(__file__, [ IceStormPersistentTestCase("persistent create", icestorm1, diff --git a/cpp/test/IceStorm/rep1/test.py b/cpp/test/IceStorm/rep1/test.py index 3ecf655909e..947d2152489 100644 --- a/cpp/test/IceStorm/rep1/test.py +++ b/cpp/test/IceStorm/rep1/test.py @@ -11,12 +11,13 @@ # truncated). See also bug #6070. # props = { - "IceStorm.Election.MasterTimeout" : 2, - "IceStorm.Election.ElectionTimeout" : 2, - "IceStorm.Election.ResponseTimeout" : 2 + "IceStorm.Election.MasterTimeout": 2, + "IceStorm.Election.ElectionTimeout": 2, + "IceStorm.Election.ResponseTimeout": 2 } -icestorm = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] +icestorm = [IceStorm(replica=i, nreplicas=3, props=props) for i in range(0, 3)] + class IceStormRep1TestCase(IceStormTestCase): @@ -282,4 +283,5 @@ def rununsub2(replica=None, expect=None): self.stopIceStorm(current) current.writeln("ok") -TestSuite(__file__, [ IceStormRep1TestCase("replicated", icestorm=icestorm) ], multihost=False) + +TestSuite(__file__, [IceStormRep1TestCase("replicated", icestorm=icestorm)], multihost=False) diff --git a/cpp/test/IceStorm/repgrid/test.py b/cpp/test/IceStorm/repgrid/test.py index a894bad3fce..1c6f2b8dc09 100644 --- a/cpp/test/IceStorm/repgrid/test.py +++ b/cpp/test/IceStorm/repgrid/test.py @@ -6,6 +6,6 @@ # Use the IceGridServer for the client because the client is an IceStorm subscriber and needs to be able # to accept connections (this is important for picking the correct server certificate for TLS). if isinstance(platform, Windows) or os.getuid() != 0: - TestSuite(__file__, [ IceGridTestCase(icegridregistry=IceGridRegistryMaster(), - client=IceGridServer()) ], + TestSuite(__file__, [IceGridTestCase(icegridregistry=IceGridRegistryMaster(), + client=IceGridServer())], runOnMainThread=True, multihost=False) diff --git a/cpp/test/IceStorm/repstress/test.py b/cpp/test/IceStorm/repstress/test.py index 95014662a63..71586d230d0 100644 --- a/cpp/test/IceStorm/repstress/test.py +++ b/cpp/test/IceStorm/repstress/test.py @@ -11,13 +11,14 @@ # truncated). See also bug #6070. # props = { - "IceStorm.Election.MasterTimeout" : 2, - "IceStorm.Election.ElectionTimeout" : 2, - "IceStorm.Election.ResponseTimeout" : 2, - "Ice.Warn.Dispatch" : 0 + "IceStorm.Election.MasterTimeout": 2, + "IceStorm.Election.ElectionTimeout": 2, + "IceStorm.Election.ResponseTimeout": 2, + "Ice.Warn.Dispatch": 0 } -icestorm = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] +icestorm = [IceStorm(replica=i, nreplicas=3, props=props) for i in range(0, 3)] + class IceStormRepStressTestCase(IceStormTestCase): @@ -100,9 +101,11 @@ def startReplica(num): subscriber.stop(current, True) current.writeln("ok") - current.writeln("publisher published %s events, subscriber received %s events" % (publisherCount, subscriberCount)) + current.writeln("publisher published %s events, subscriber received %s events" % + (publisherCount, subscriberCount)) + TestSuite(__file__, - [ IceStormRepStressTestCase("replicated", icestorm=icestorm) ], - options={ "ipv6" : [False] }, + [IceStormRepStressTestCase("replicated", icestorm=icestorm)], + options={"ipv6": [False]}, multihost=False, runOnMainThread=True) diff --git a/cpp/test/IceStorm/single/test.py b/cpp/test/IceStorm/single/test.py index 9e4500ac08c..7d34463ba74 100644 --- a/cpp/test/IceStorm/single/test.py +++ b/cpp/test/IceStorm/single/test.py @@ -10,14 +10,15 @@ # send buffer size (causing the received messages to be truncated). See # bug #6070 and #7558. # -props = { "Ice.UDP.SndSize" : 512 * 1024, "Ice.Warn.Dispatch" : 0 } -persistent = IceStorm(props = props) -transient = IceStorm(props = props, transient=True) -replicated = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] +props = {"Ice.UDP.SndSize": 512 * 1024, "Ice.Warn.Dispatch": 0} +persistent = IceStorm(props=props) +transient = IceStorm(props=props, transient=True) +replicated = [IceStorm(replica=i, nreplicas=3, props=props) for i in range(0, 3)] -sub = Subscriber(args=["{testcase.parent.name}"], props = { "Ice.UDP.RcvSize" : 1024 * 1024 }, readyCount=3) +sub = Subscriber(args=["{testcase.parent.name}"], props={"Ice.UDP.RcvSize": 1024 * 1024}, readyCount=3) pub = Publisher(args=["{testcase.parent.name}"]) + class IceStormSingleTestCase(IceStormTestCase): def setupClientSide(self, current): @@ -27,6 +28,7 @@ def teardownClientSide(self, current, success): self.runadmin(current, "destroy single") self.shutdown(current) + TestSuite(__file__, [ IceStormSingleTestCase("persistent", icestorm=persistent, client=ClientServerTestCase(client=pub, server=sub)), IceStormSingleTestCase("transient", icestorm=transient, client=ClientServerTestCase(client=pub, server=sub)), diff --git a/cpp/test/IceStorm/stress/test.py b/cpp/test/IceStorm/stress/test.py index 8bfe4f6c3b1..e867aedbe83 100644 --- a/cpp/test/IceStorm/stress/test.py +++ b/cpp/test/IceStorm/stress/test.py @@ -7,7 +7,8 @@ # Publisher/subscriber test cases, publisher publishes on TestIceStorm1 instance(s) and # the subscriber subscribes to the TestIceStorm2 instance(s) # -pubSub=lambda si, pi, s={}, p={}: ClientServerTestCase(client=Publisher(args=s), server=Subscriber(args=p)) +pubSub = lambda si, pi, s={}, p={}: ClientServerTestCase(client=Publisher(args=s), server=Subscriber(args=p)) + class IceStormStressTestCase(IceStormTestCase): @@ -65,7 +66,7 @@ def doTest(subOpts, pubOpts): current.write("Sending 20000 unordered events with slow subscriber... ") doTest([("TestIceStorm1", '--events 2 --slow'), ("TestIceStorm1", '--events 20000 ')], - '--events 20000 --oneway') + '--events 20000 --oneway') current.writeln("ok") self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") @@ -74,7 +75,7 @@ def doTest(subOpts, pubOpts): ("TestIceStorm1", '--events 20000'), ("TestIceStorm2", '--events 2 --slow'), ("TestIceStorm2", '--events 20000')], - '--events 20000 --oneway') + '--events 20000 --oneway') current.writeln("ok") current.write("shutting down icestorm services... ") @@ -92,21 +93,21 @@ def doTest(subOpts, pubOpts): self.runadmin(current, "unlink TestIceStorm1/fed1 TestIceStorm2/fed1") current.write("Sending 20000 unordered events with erratic subscriber... ") - doTest([ ("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000'), - ("TestIceStorm1", '--erratic 5 --events 20000'), - ("TestIceStorm1", '--events 20000')], - '--events 20000 --oneway') + doTest([("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000'), + ("TestIceStorm1", '--erratic 5 --events 20000'), + ("TestIceStorm1", '--events 20000')], + '--events 20000 --oneway') current.writeln("ok") self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") current.write("Sending 20000 unordered events with erratic subscriber across a link... ") - doTest([ ("TestIceStorm1", '--events 20000'), - ("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000 '), - ("TestIceStorm1", '--erratic 5 --events 20000 '), - ("TestIceStorm2", '--events 20000'), - ("TestIceStorm2", '--erratic 5 --qos "reliability,ordered" --events 20000 '), - ("TestIceStorm2", '--erratic 5 --events 20000 ')], - '--events 20000 --oneway ') + doTest([("TestIceStorm1", '--events 20000'), + ("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000 '), + ("TestIceStorm1", '--erratic 5 --events 20000 '), + ("TestIceStorm2", '--events 20000'), + ("TestIceStorm2", '--erratic 5 --qos "reliability,ordered" --events 20000 '), + ("TestIceStorm2", '--erratic 5 --events 20000 ')], + '--events 20000 --oneway ') current.writeln("ok") # @@ -138,13 +139,13 @@ def doTest(subOpts, pubOpts): s.stop(current, True) current.writeln("ok") + TestSuite(__file__, [ IceStormStressTestCase("persistent", icestorm=[IceStorm("TestIceStorm1", quiet=True), IceStorm("TestIceStorm2", quiet=True, portnum=20)]), - IceStormStressTestCase("replicated with replicated publisher", icestorm= - [IceStorm("TestIceStorm1", i, 3, quiet=True) for i in range(0,3)] + - [IceStorm("TestIceStorm2", i, 3, portnum=20, quiet=True) for i in range(0,3)]), + IceStormStressTestCase("replicated with replicated publisher", icestorm=[IceStorm("TestIceStorm1", i, 3, quiet=True) for i in range(0, 3)] + + [IceStorm("TestIceStorm2", i, 3, portnum=20, quiet=True) for i in range(0, 3)]), ], multihost=False) diff --git a/cpp/test/IceUtil/stacktrace/test.py b/cpp/test/IceUtil/stacktrace/test.py index 3636632dd89..0e43fabdb4a 100644 --- a/cpp/test/IceUtil/stacktrace/test.py +++ b/cpp/test/IceUtil/stacktrace/test.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, options = { "cpp11" : [False] }) +TestSuite(__name__, options={"cpp11": [False]}) diff --git a/cpp/test/IceUtil/unicode/test.py b/cpp/test/IceUtil/unicode/test.py index f0bd36f72fa..4e585b2492b 100644 --- a/cpp/test/IceUtil/unicode/test.py +++ b/cpp/test/IceUtil/unicode/test.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, [ ClientTestCase(client=SimpleClient(args=["{testdir}"])) ]) +TestSuite(__name__, [ClientTestCase(client=SimpleClient(args=["{testdir}"]))]) diff --git a/cpp/test/Slice/errorDetection/test.py b/cpp/test/Slice/errorDetection/test.py index fa1d4307f1c..48435938a96 100644 --- a/cpp/test/Slice/errorDetection/test.py +++ b/cpp/test/Slice/errorDetection/test.py @@ -62,4 +62,5 @@ def runClientSide(self, current): if os.path.exists(outdir): shutil.rmtree(outdir) -TestSuite(__name__, [ SliceErrorDetectionTestCase() ]) + +TestSuite(__name__, [SliceErrorDetectionTestCase()]) diff --git a/cpp/test/Slice/headers/test.py b/cpp/test/Slice/headers/test.py index 938fcb65a9e..958a5ed18cd 100644 --- a/cpp/test/Slice/headers/test.py +++ b/cpp/test/Slice/headers/test.py @@ -5,6 +5,7 @@ import glob + class SliceHeadersTestCase(ClientTestCase): def runClientSide(self, current): @@ -148,13 +149,16 @@ def clean(self): # Device or resource busy: 'project1/.nfs00000000006216b500000024' # try: - if os.path.exists("project1"): shutil.rmtree("project1") + if os.path.exists("project1"): + shutil.rmtree("project1") except: pass try: - if os.path.exists("tmp"): shutil.rmtree("tmp") + if os.path.exists("tmp"): + shutil.rmtree("tmp") except: pass + if not isinstance(platform, Windows): - TestSuite(__name__, [ SliceHeadersTestCase() ], chdir=True) + TestSuite(__name__, [SliceHeadersTestCase()], chdir=True) diff --git a/cpp/test/Slice/unicodePaths/test.py b/cpp/test/Slice/unicodePaths/test.py index 39d07fa1f10..744d8ae84a6 100644 --- a/cpp/test/Slice/unicodePaths/test.py +++ b/cpp/test/Slice/unicodePaths/test.py @@ -3,7 +3,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import shutil, locale +import shutil +import locale + class SliceUnicodePathsTestCase(ClientTestCase): @@ -20,7 +22,8 @@ def runClientSide(self, current): srcPath = "./\u4e2d\u56fd" - if os.path.exists(srcPath): shutil.rmtree(srcPath) + if os.path.exists(srcPath): + shutil.rmtree(srcPath) os.mkdir(srcPath) current.createFile("%s/Test.ice" % srcPath, @@ -55,6 +58,8 @@ def runClientSide(self, current): current.writeln("ok") finally: - if os.path.exists(srcPath): shutil.rmtree(srcPath) + if os.path.exists(srcPath): + shutil.rmtree(srcPath) + -TestSuite(__name__, [ SliceUnicodePathsTestCase() ], chdir=True) +TestSuite(__name__, [SliceUnicodePathsTestCase()], chdir=True) diff --git a/csharp/allTests.py b/csharp/allTests.py index 2241653995d..94a9466c3db 100755 --- a/csharp/allTests.py +++ b/csharp/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/csharp/test/Ice/invoke/test.py b/csharp/test/Ice/invoke/test.py index 3c563fa249c..da809b21a8c 100644 --- a/csharp/test/Ice/invoke/test.py +++ b/csharp/test/Ice/invoke/test.py @@ -4,4 +4,4 @@ TestSuite(__file__, [ClientServerTestCase(), - ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) + ClientServerTestCase(name="client/server async", servers=[Server(args=["--async"])])]) diff --git a/csharp/test/IceSSL/certs/makecerts.py b/csharp/test/IceSSL/certs/makecerts.py index c1beb6ee40f..a782e065f5a 100755 --- a/csharp/test/IceSSL/certs/makecerts.py +++ b/csharp/test/IceSSL/certs/makecerts.py @@ -3,7 +3,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, socket, getopt +import os +import sys +import socket +import getopt try: import IceCertUtils @@ -12,8 +15,8 @@ "from Python package repository") sys.exit(1) -toplevel="." -while(os.path.abspath(toplevel) != "/"): +toplevel = "." +while (os.path.abspath(toplevel) != "/"): toplevel = os.path.normpath(os.path.join("..", toplevel)) if os.path.exists(os.path.join(toplevel, "scripts", "Util.py")): break @@ -26,6 +29,7 @@ " run makecerts.py in `" + cppcerts + "' first") sys.exit(1) + def usage(): print("Usage: " + sys.argv[0] + " [options]") print("") @@ -35,6 +39,7 @@ def usage(): print("--force Re-save all the files even if they already exists.") sys.exit(1) + # # Check arguments # @@ -61,20 +66,26 @@ def usage(): cai1 = ca1.getIntermediateFactory("intermediate1") cai2 = cai1.getIntermediateFactory("intermediate1") -if force or not os.path.exists("cacert1.pem"): ca1.getCA().save("cacert1.pem") -if force or not os.path.exists("cacert2.pem"): ca2.getCA().save("cacert2.pem") -if force or not os.path.exists("cacert1.der"): ca1.getCA().save("cacert1.der") +if force or not os.path.exists("cacert1.pem"): + ca1.getCA().save("cacert1.pem") +if force or not os.path.exists("cacert2.pem"): + ca2.getCA().save("cacert2.pem") +if force or not os.path.exists("cacert1.der"): + ca1.getCA().save("cacert1.der") if force or not os.path.exists("cacerts.pem"): pem = "" - with open("cacert1.pem", "r") as f: pem += f.read() - with open("cacert2.pem", "r") as f: pem += f.read() - with open("cacerts.pem", "w") as f: f.write(pem); + with open("cacert1.pem", "r") as f: + pem += f.read() + with open("cacert2.pem", "r") as f: + pem += f.read() + with open("cacerts.pem", "w") as f: + f.write(pem) certs = [ (ca1, "s_rsa_ca1", None, {}), (ca1, "c_rsa_ca1", None, {}), - (ca1, "s_rsa_ca1_exp", None, {}), # Expired certificate - (ca1, "c_rsa_ca1_exp", None, {}), # Expired certificate + (ca1, "s_rsa_ca1_exp", None, {}), # Expired certificate + (ca1, "c_rsa_ca1_exp", None, {}), # Expired certificate (ca1, "s_rsa_ca1_cn1", None, {}), (ca1, "s_rsa_ca1_cn2", None, {}), (ca1, "s_rsa_ca1_cn3", None, {}), @@ -88,17 +99,19 @@ def usage(): (cai1, "s_rsa_cai1", None, {}), (cai2, "s_rsa_cai2", None, {}), (cai2, "c_rsa_cai2", None, {}), - (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", { "root": True }), + (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", {"root": True}), ] # # Save the certificate PKCS12 files. # for (ca, alias, path, args) in certs: - if not path: path = alias + if not path: + path = alias cert = ca.get(alias) if force or not os.path.exists(path + ".p12"): cert.save(path + ".p12", **args) # Also export the ca2 self-signed certificate, it's used by the tests to test self-signed certificates -if force or not os.path.exists("cacert2.p12"): ca2.getCA().save("cacert2.p12", addkey=True) +if force or not os.path.exists("cacert2.p12"): + ca2.getCA().save("cacert2.p12", addkey=True) diff --git a/java/allTests.py b/java/allTests.py index 2241653995d..94a9466c3db 100755 --- a/java/allTests.py +++ b/java/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/java/test/src/main/java/test/Ice/invoke/test.py b/java/test/src/main/java/test/Ice/invoke/test.py index 3c563fa249c..da809b21a8c 100644 --- a/java/test/src/main/java/test/Ice/invoke/test.py +++ b/java/test/src/main/java/test/Ice/invoke/test.py @@ -4,4 +4,4 @@ TestSuite(__file__, [ClientServerTestCase(), - ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) + ClientServerTestCase(name="client/server async", servers=[Server(args=["--async"])])]) diff --git a/java/test/src/main/java/test/IceSSL/certs/makecerts.py b/java/test/src/main/java/test/IceSSL/certs/makecerts.py index c647d833eb4..81c3ff4acc2 100755 --- a/java/test/src/main/java/test/IceSSL/certs/makecerts.py +++ b/java/test/src/main/java/test/IceSSL/certs/makecerts.py @@ -3,7 +3,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, socket, getopt +import os +import sys +import socket +import getopt try: import IceCertUtils @@ -12,8 +15,8 @@ "from Python package repository") sys.exit(1) -toplevel="." -while(os.path.abspath(toplevel) != "/"): +toplevel = "." +while (os.path.abspath(toplevel) != "/"): toplevel = os.path.normpath(os.path.join("..", toplevel)) if os.path.exists(os.path.join(toplevel, "scripts", "Util.py")): break @@ -26,6 +29,7 @@ " run makecerts.py in `" + cppcerts + "' first") sys.exit(1) + def usage(): print("Usage: " + sys.argv[0] + " [options]") print("") @@ -35,6 +39,7 @@ def usage(): print("--force Re-save all the files even if they already exists.") sys.exit(1) + # # Check arguments # @@ -61,14 +66,16 @@ def usage(): cai1 = ca1.getIntermediateFactory("intermediate1") cai2 = cai1.getIntermediateFactory("intermediate1") -if force or not os.path.exists("cacert1.jks"): ca1.getCA().save("cacert1.jks") -if force or not os.path.exists("cacert2.jks"): ca2.getCA().save("cacert2.jks") +if force or not os.path.exists("cacert1.jks"): + ca1.getCA().save("cacert1.jks") +if force or not os.path.exists("cacert2.jks"): + ca2.getCA().save("cacert2.jks") certs = [ (ca1, "s_rsa_ca1", None, {}), (ca1, "c_rsa_ca1", None, {}), - (ca1, "s_rsa_ca1_exp", None, {}), # Expired certificate - (ca1, "c_rsa_ca1_exp", None, {}), # Expired certificate + (ca1, "s_rsa_ca1_exp", None, {}), # Expired certificate + (ca1, "c_rsa_ca1_exp", None, {}), # Expired certificate (ca1, "s_rsa_ca1_cn1", None, {}), (ca1, "s_rsa_ca1_cn2", None, {}), (ca1, "s_rsa_ca1_cn3", None, {}), @@ -84,14 +91,15 @@ def usage(): (cai1, "s_rsa_cai1", None, {}), (cai2, "s_rsa_cai2", None, {}), (cai2, "c_rsa_cai2", None, {}), - (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", { "root": True }), + (ca1, "s_rsa_ca1", "s_rsa_wroot_ca1", {"root": True}), ] # # Save the certificate JKS files. # for (ca, alias, path, args) in certs: - if not path: path = alias + if not path: + path = alias cert = ca.get(alias) if force or not os.path.exists(path + ".jks"): cert.save(path + ".jks", alias="cert", **args) @@ -100,17 +108,20 @@ def usage(): # Create a cacerts.jks truststore that contains both CA certs. # if force or not os.path.exists("cacerts.jks"): - if os.path.exists("cacerts.jks"): os.remove("cacerts.jks") + if os.path.exists("cacerts.jks"): + os.remove("cacerts.jks") ca1.getCA().exportToKeyStore("cacerts.jks", alias="cacert1") ca2.getCA().exportToKeyStore("cacerts.jks", alias="cacert2") -if force or not os.path.exists("s_cacert2.jks"): ca2.getCA().saveJKS("s_cacert2.jks", addkey=True) +if force or not os.path.exists("s_cacert2.jks"): + ca2.getCA().saveJKS("s_cacert2.jks", addkey=True) # # Create a client/server certificate that contains both the DSA and # RSA certs. # if force or not os.path.exists("s_rsa_dsa_ca1.jks"): - if os.path.exists("s_rsa_dsa_ca1.jks"): os.remove("s_rsa_dsa_ca1.jks") + if os.path.exists("s_rsa_dsa_ca1.jks"): + os.remove("s_rsa_dsa_ca1.jks") ca1.get("s_rsa_ca1").exportToKeyStore("s_rsa_dsa_ca1.jks", alias="rsacert") ca1.get("s_dsa_ca1").exportToKeyStore("s_rsa_dsa_ca1.jks", alias="dsacert") diff --git a/js/allTests.py b/js/allTests.py index 2241653995d..94a9466c3db 100755 --- a/js/allTests.py +++ b/js/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/matlab/allTests.py b/matlab/allTests.py index 2241653995d..94a9466c3db 100755 --- a/matlab/allTests.py +++ b/matlab/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/php/allTests.py b/php/allTests.py index 2241653995d..94a9466c3db 100755 --- a/php/allTests.py +++ b/php/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/php/test/Ice/ini/test.py b/php/test/Ice/ini/test.py index 58241cb947d..eef8114afec 100644 --- a/php/test/Ice/ini/test.py +++ b/php/test/Ice/ini/test.py @@ -28,6 +28,7 @@ def getPhpArgs(self, current): else: return ["-d", "ice.options=\"{0}\"".format(self.iceOptions), "-d", "ice.config=\"config.client\""] + TestSuite(__name__, [ ClientTestCase("php INI settings", client=IniClient("--Ice.Trace.Network=1 --Ice.Warn.Connections=1")), diff --git a/python/allTests.py b/python/allTests.py index 2241653995d..94a9466c3db 100755 --- a/python/allTests.py +++ b/python/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/python/config/s2py.py b/python/config/s2py.py index cd65c0e4cf5..f96bd7263a5 100755 --- a/python/config/s2py.py +++ b/python/config/s2py.py @@ -3,7 +3,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, os, platform +import sys +import os +import platform basepath = os.path.dirname(os.path.realpath(__file__)) @@ -17,9 +19,11 @@ import IcePy + def main(): val = IcePy.compile(sys.argv) sys.exit(int(val)) + if __name__ == '__main__': - main() + main() diff --git a/python/python/Glacier2/__init__.py b/python/python/Glacier2/__init__.py index d678e6982fd..5ce8afea632 100644 --- a/python/python/Glacier2/__init__.py +++ b/python/python/Glacier2/__init__.py @@ -6,7 +6,9 @@ Glacier2 module """ -import threading, traceback, copy +import threading +import traceback +import copy # # Import the Python extension. @@ -20,17 +22,20 @@ import Glacier2.SSLInfo_ice import Glacier2.Metrics_ice + class SessionNotExistException(Exception): def __init__(self): pass + class RestartSessionException(Exception): def __init__(self): pass + class Application(Ice.Application): - def __init__(self, signalPolicy=0): # HandleSignals=0 + def __init__(self, signalPolicy=0): # HandleSignals=0 '''The constructor accepts an optional argument indicating whether to handle signals. The value should be either Application.HandleSignals (the default) or @@ -130,13 +135,13 @@ def doMainInternal(self, args, initData): acmTimeout = 0 try: acmTimeout = Application._router.getACMTimeout() - except(Ice.OperationNotExistException): + except (Ice.OperationNotExistException): pass if acmTimeout <= 0: acmTimeout = Application._router.getSessionTimeout() if acmTimeout > 0: connection = Application._router.ice_getCachedConnection() - assert(connection) + assert (connection) connection.setACM(acmTimeout, Ice.Unset, Ice.ACMHeartbeat.HeartbeatAlways) connection.setCloseCallback(lambda conn: self.sessionDestroyed()) Application._category = Application._router.getCategoryForClient() @@ -146,10 +151,10 @@ def doMainInternal(self, args, initData): # break down in communications, but not those exceptions that # indicate a programming logic error (ie: marshal, protocol # failure, etc). - except(RestartSessionException): + except (RestartSessionException): restart = True - except(Ice.ConnectionRefusedException, Ice.ConnectionLostException, Ice.UnknownLocalException, \ - Ice.RequestFailedException, Ice.TimeoutException): + except (Ice.ConnectionRefusedException, Ice.ConnectionLostException, Ice.UnknownLocalException, + Ice.RequestFailedException, Ice.TimeoutException): Ice.getProcessLogger().error(traceback.format_exc()) restart = True except: @@ -184,7 +189,7 @@ def doMainInternal(self, args, initData): except (Ice.ConnectionLostException, SessionNotExistException): pass except: - Ice.getProcessLogger().error("unexpected exception when destroying the session " + \ + Ice.getProcessLogger().error("unexpected exception when destroying the session " + traceback.format_exc()) Application._router = None diff --git a/python/python/Ice/CommunicatorF_local.py b/python/python/Ice/CommunicatorF_local.py index 3c69dbdc2a3..876ebc6e5f0 100644 --- a/python/python/Ice/CommunicatorF_local.py +++ b/python/python/Ice/CommunicatorF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Communicator_local.py b/python/python/Ice/Communicator_local.py index da0b092224a..3322335e661 100644 --- a/python/python/Ice/Communicator_local.py +++ b/python/python/Ice/Communicator_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.LoggerF_local import Ice.InstrumentationF_local import Ice.ObjectAdapterF_local @@ -44,11 +45,13 @@ if 'Communicator' not in _M_Ice.__dict__: _M_Ice.Communicator = Ice.createTempClass() + class Communicator(object): """ The central object in Ice. One or more communicators can be instantiated for an Ice application. Communicator instantiation is language-specific, and not specified in Slice code. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Communicator: raise RuntimeError('Ice.Communicator is an abstract class') @@ -344,6 +347,7 @@ def __str__(self): if 'ToStringMode' not in _M_Ice.__dict__: _M_Ice.ToStringMode = Ice.createTempClass() + class ToStringMode(Ice.EnumBase): """ The output mode for xxxToString method such as identityToString and proxyToString. The actual encoding format for @@ -372,7 +376,7 @@ def valueOf(self, _n): ToStringMode.Unicode = ToStringMode("Unicode", 0) ToStringMode.ASCII = ToStringMode("ASCII", 1) ToStringMode.Compat = ToStringMode("Compat", 2) - ToStringMode._enumerators = { 0:ToStringMode.Unicode, 1:ToStringMode.ASCII, 2:ToStringMode.Compat } + ToStringMode._enumerators = {0: ToStringMode.Unicode, 1: ToStringMode.ASCII, 2: ToStringMode.Compat} _M_Ice._t_ToStringMode = IcePy.defineEnum('::Ice::ToStringMode', ToStringMode, (), ToStringMode._enumerators) diff --git a/python/python/Ice/ConnectionF_local.py b/python/python/Ice/ConnectionF_local.py index 2e2ec54b62c..8953bb361a8 100644 --- a/python/python/Ice/ConnectionF_local.py +++ b/python/python/Ice/ConnectionF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Connection_local.py b/python/python/Ice/Connection_local.py index d26808453ee..4fa2d64ccf3 100644 --- a/python/python/Ice/Connection_local.py +++ b/python/python/Ice/Connection_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.ObjectAdapterF_local import Ice.Identity_ice import Ice.Endpoint_local @@ -27,6 +28,7 @@ if 'CompressBatch' not in _M_Ice.__dict__: _M_Ice.CompressBatch = Ice.createTempClass() + class CompressBatch(Ice.EnumBase): """ The batch compression option when flushing queued batch requests. @@ -48,7 +50,7 @@ def valueOf(self, _n): CompressBatch.Yes = CompressBatch("Yes", 0) CompressBatch.No = CompressBatch("No", 1) CompressBatch.BasedOnProxy = CompressBatch("BasedOnProxy", 2) - CompressBatch._enumerators = { 0:CompressBatch.Yes, 1:CompressBatch.No, 2:CompressBatch.BasedOnProxy } + CompressBatch._enumerators = {0: CompressBatch.Yes, 1: CompressBatch.No, 2: CompressBatch.BasedOnProxy} _M_Ice._t_CompressBatch = IcePy.defineEnum('::Ice::CompressBatch', CompressBatch, (), CompressBatch._enumerators) @@ -57,6 +59,7 @@ def valueOf(self, _n): if 'ConnectionInfo' not in _M_Ice.__dict__: _M_Ice.ConnectionInfo = Ice.createTempClass() + class ConnectionInfo(object): """ Base class providing access to the connection details. @@ -66,6 +69,7 @@ class ConnectionInfo(object): adapterName -- The name of the adapter associated with the connection. connectionId -- The connection id. """ + def __init__(self, underlying=None, incoming=False, adapterName='', connectionId=''): self.underlying = underlying self.incoming = incoming @@ -95,10 +99,12 @@ def __str__(self): if 'CloseCallback' not in _M_Ice.__dict__: _M_Ice.CloseCallback = Ice.createTempClass() + class CloseCallback(object): """ An application can implement this interface to receive notifications when a connection closes. """ + def __init__(self): if Ice.getType(self) == _M_Ice.CloseCallback: raise RuntimeError('Ice.CloseCallback is an abstract class') @@ -125,11 +131,13 @@ def __str__(self): if 'HeartbeatCallback' not in _M_Ice.__dict__: _M_Ice.HeartbeatCallback = Ice.createTempClass() + class HeartbeatCallback(object): """ An application can implement this interface to receive notifications when a connection receives a heartbeat message. """ + def __init__(self): if Ice.getType(self) == _M_Ice.HeartbeatCallback: raise RuntimeError('Ice.HeartbeatCallback is an abstract class') @@ -147,7 +155,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice._t_HeartbeatCallback = IcePy.defineValue('::Ice::HeartbeatCallback', HeartbeatCallback, -1, (), False, True, None, ()) + _M_Ice._t_HeartbeatCallback = IcePy.defineValue( + '::Ice::HeartbeatCallback', HeartbeatCallback, -1, (), False, True, None, ()) HeartbeatCallback._ice_type = _M_Ice._t_HeartbeatCallback _M_Ice.HeartbeatCallback = HeartbeatCallback @@ -155,6 +164,7 @@ def __str__(self): if 'ACMClose' not in _M_Ice.__dict__: _M_Ice.ACMClose = Ice.createTempClass() + class ACMClose(Ice.EnumBase): """ Specifies the close semantics for Active Connection Management. @@ -182,7 +192,8 @@ def valueOf(self, _n): ACMClose.CloseOnInvocation = ACMClose("CloseOnInvocation", 2) ACMClose.CloseOnInvocationAndIdle = ACMClose("CloseOnInvocationAndIdle", 3) ACMClose.CloseOnIdleForceful = ACMClose("CloseOnIdleForceful", 4) - ACMClose._enumerators = { 0:ACMClose.CloseOff, 1:ACMClose.CloseOnIdle, 2:ACMClose.CloseOnInvocation, 3:ACMClose.CloseOnInvocationAndIdle, 4:ACMClose.CloseOnIdleForceful } + ACMClose._enumerators = {0: ACMClose.CloseOff, 1: ACMClose.CloseOnIdle, 2: ACMClose.CloseOnInvocation, + 3: ACMClose.CloseOnInvocationAndIdle, 4: ACMClose.CloseOnIdleForceful} _M_Ice._t_ACMClose = IcePy.defineEnum('::Ice::ACMClose', ACMClose, (), ACMClose._enumerators) @@ -191,6 +202,7 @@ def valueOf(self, _n): if 'ACMHeartbeat' not in _M_Ice.__dict__: _M_Ice.ACMHeartbeat = Ice.createTempClass() + class ACMHeartbeat(Ice.EnumBase): """ Specifies the heartbeat semantics for Active Connection Management. @@ -214,7 +226,8 @@ def valueOf(self, _n): ACMHeartbeat.HeartbeatOnDispatch = ACMHeartbeat("HeartbeatOnDispatch", 1) ACMHeartbeat.HeartbeatOnIdle = ACMHeartbeat("HeartbeatOnIdle", 2) ACMHeartbeat.HeartbeatAlways = ACMHeartbeat("HeartbeatAlways", 3) - ACMHeartbeat._enumerators = { 0:ACMHeartbeat.HeartbeatOff, 1:ACMHeartbeat.HeartbeatOnDispatch, 2:ACMHeartbeat.HeartbeatOnIdle, 3:ACMHeartbeat.HeartbeatAlways } + ACMHeartbeat._enumerators = {0: ACMHeartbeat.HeartbeatOff, 1: ACMHeartbeat.HeartbeatOnDispatch, + 2: ACMHeartbeat.HeartbeatOnIdle, 3: ACMHeartbeat.HeartbeatAlways} _M_Ice._t_ACMHeartbeat = IcePy.defineEnum('::Ice::ACMHeartbeat', ACMHeartbeat, (), ACMHeartbeat._enumerators) @@ -223,6 +236,7 @@ def valueOf(self, _n): if 'ACM' not in _M_Ice.__dict__: _M_Ice.ACM = Ice.createTempClass() + class ACM(object): """ A collection of Active Connection Management configuration settings. @@ -231,6 +245,7 @@ class ACM(object): close -- The close semantics. heartbeat -- The heartbeat semantics. """ + def __init__(self, timeout=0, close=_M_Ice.ACMClose.CloseOff, heartbeat=_M_Ice.ACMHeartbeat.HeartbeatOff): self.timeout = timeout self.close = close @@ -333,6 +348,7 @@ def __str__(self): if 'ConnectionClose' not in _M_Ice.__dict__: _M_Ice.ConnectionClose = Ice.createTempClass() + class ConnectionClose(Ice.EnumBase): """ Determines the behavior when manually closing a connection. @@ -356,19 +372,23 @@ def valueOf(self, _n): ConnectionClose.Forcefully = ConnectionClose("Forcefully", 0) ConnectionClose.Gracefully = ConnectionClose("Gracefully", 1) ConnectionClose.GracefullyWithWait = ConnectionClose("GracefullyWithWait", 2) - ConnectionClose._enumerators = { 0:ConnectionClose.Forcefully, 1:ConnectionClose.Gracefully, 2:ConnectionClose.GracefullyWithWait } + ConnectionClose._enumerators = {0: ConnectionClose.Forcefully, + 1: ConnectionClose.Gracefully, 2: ConnectionClose.GracefullyWithWait} - _M_Ice._t_ConnectionClose = IcePy.defineEnum('::Ice::ConnectionClose', ConnectionClose, (), ConnectionClose._enumerators) + _M_Ice._t_ConnectionClose = IcePy.defineEnum( + '::Ice::ConnectionClose', ConnectionClose, (), ConnectionClose._enumerators) _M_Ice.ConnectionClose = ConnectionClose del ConnectionClose if 'Connection' not in _M_Ice.__dict__: _M_Ice.Connection = Ice.createTempClass() + class Connection(object): """ The user-level interface to a connection. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Connection: raise RuntimeError('Ice.Connection is an abstract class') @@ -527,6 +547,7 @@ def __str__(self): if 'IPConnectionInfo' not in _M_Ice.__dict__: _M_Ice.IPConnectionInfo = Ice.createTempClass() + class IPConnectionInfo(_M_Ice.ConnectionInfo): """ Provides access to the connection details of an IP connection @@ -536,6 +557,7 @@ class IPConnectionInfo(_M_Ice.ConnectionInfo): remoteAddress -- The remote address. remotePort -- The remote port. """ + def __init__(self, underlying=None, incoming=False, adapterName='', connectionId='', localAddress="", localPort=-1, remoteAddress="", remotePort=-1): _M_Ice.ConnectionInfo.__init__(self, underlying, incoming, adapterName, connectionId) self.localAddress = localAddress @@ -563,6 +585,7 @@ def __str__(self): if 'TCPConnectionInfo' not in _M_Ice.__dict__: _M_Ice.TCPConnectionInfo = Ice.createTempClass() + class TCPConnectionInfo(_M_Ice.IPConnectionInfo): """ Provides access to the connection details of a TCP connection @@ -570,8 +593,10 @@ class TCPConnectionInfo(_M_Ice.IPConnectionInfo): rcvSize -- The connection buffer receive size. sndSize -- The connection buffer send size. """ + def __init__(self, underlying=None, incoming=False, adapterName='', connectionId='', localAddress="", localPort=-1, remoteAddress="", remotePort=-1, rcvSize=0, sndSize=0): - _M_Ice.IPConnectionInfo.__init__(self, underlying, incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort) + _M_Ice.IPConnectionInfo.__init__(self, underlying, incoming, adapterName, + connectionId, localAddress, localPort, remoteAddress, remotePort) self.rcvSize = rcvSize self.sndSize = sndSize @@ -593,6 +618,7 @@ def __str__(self): if 'UDPConnectionInfo' not in _M_Ice.__dict__: _M_Ice.UDPConnectionInfo = Ice.createTempClass() + class UDPConnectionInfo(_M_Ice.IPConnectionInfo): """ Provides access to the connection details of a UDP connection @@ -602,8 +628,10 @@ class UDPConnectionInfo(_M_Ice.IPConnectionInfo): rcvSize -- The connection buffer receive size. sndSize -- The connection buffer send size. """ + def __init__(self, underlying=None, incoming=False, adapterName='', connectionId='', localAddress="", localPort=-1, remoteAddress="", remotePort=-1, mcastAddress='', mcastPort=-1, rcvSize=0, sndSize=0): - _M_Ice.IPConnectionInfo.__init__(self, underlying, incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort) + _M_Ice.IPConnectionInfo.__init__(self, underlying, incoming, adapterName, + connectionId, localAddress, localPort, remoteAddress, remotePort) self.mcastAddress = mcastAddress self.mcastPort = mcastPort self.rcvSize = rcvSize @@ -632,12 +660,14 @@ def __str__(self): if 'WSConnectionInfo' not in _M_Ice.__dict__: _M_Ice.WSConnectionInfo = Ice.createTempClass() + class WSConnectionInfo(_M_Ice.ConnectionInfo): """ Provides access to the connection details of a WebSocket connection Members: headers -- The headers from the HTTP upgrade request. """ + def __init__(self, underlying=None, incoming=False, adapterName='', connectionId='', headers=None): _M_Ice.ConnectionInfo.__init__(self, underlying, incoming, adapterName, connectionId) self.headers = headers @@ -649,7 +679,8 @@ def __str__(self): _M_Ice._t_WSConnectionInfo = IcePy.declareValue('::Ice::WSConnectionInfo') - _M_Ice._t_WSConnectionInfo = IcePy.defineValue('::Ice::WSConnectionInfo', WSConnectionInfo, -1, (), False, False, _M_Ice._t_ConnectionInfo, (('headers', (), _M_Ice._t_HeaderDict, False, 0),)) + _M_Ice._t_WSConnectionInfo = IcePy.defineValue('::Ice::WSConnectionInfo', WSConnectionInfo, -1, + (), False, False, _M_Ice._t_ConnectionInfo, (('headers', (), _M_Ice._t_HeaderDict, False, 0),)) WSConnectionInfo._ice_type = _M_Ice._t_WSConnectionInfo _M_Ice.WSConnectionInfo = WSConnectionInfo diff --git a/python/python/Ice/Current_local.py b/python/python/Ice/Current_local.py index 4d5a26ffb14..7e7a36cc6e4 100644 --- a/python/python/Ice/Current_local.py +++ b/python/python/Ice/Current_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.ObjectAdapterF_local import Ice.ConnectionF_local import Ice.Context_ice @@ -30,6 +31,7 @@ if 'Current' not in _M_Ice.__dict__: _M_Ice.Current = Ice.createTempClass() + class Current(object): """ Information about the current method invocation for servers. Each operation on the server has a @@ -47,6 +49,7 @@ class Current(object): requestId -- The request id unless oneway (0). encoding -- The encoding version used to encode the input and output parameters. """ + def __init__(self, adapter=None, con=None, id=Ice._struct_marker, facet='', operation='', mode=_M_Ice.OperationMode.Normal, ctx=None, requestId=0, encoding=Ice._struct_marker): self.adapter = adapter self.con = con diff --git a/python/python/Ice/EndpointF_local.py b/python/python/Ice/EndpointF_local.py index 316527e072a..4c8b1b9ddb2 100644 --- a/python/python/Ice/EndpointF_local.py +++ b/python/python/Ice/EndpointF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/EndpointSelectionType_local.py b/python/python/Ice/EndpointSelectionType_local.py index c7fcc517119..c41a4006290 100644 --- a/python/python/Ice/EndpointSelectionType_local.py +++ b/python/python/Ice/EndpointSelectionType_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') @@ -22,6 +23,7 @@ if 'EndpointSelectionType' not in _M_Ice.__dict__: _M_Ice.EndpointSelectionType = Ice.createTempClass() + class EndpointSelectionType(Ice.EnumBase): """ Determines the order in which the Ice run time uses the endpoints in a proxy when establishing a connection. @@ -41,9 +43,10 @@ def valueOf(self, _n): EndpointSelectionType.Random = EndpointSelectionType("Random", 0) EndpointSelectionType.Ordered = EndpointSelectionType("Ordered", 1) - EndpointSelectionType._enumerators = { 0:EndpointSelectionType.Random, 1:EndpointSelectionType.Ordered } + EndpointSelectionType._enumerators = {0: EndpointSelectionType.Random, 1: EndpointSelectionType.Ordered} - _M_Ice._t_EndpointSelectionType = IcePy.defineEnum('::Ice::EndpointSelectionType', EndpointSelectionType, (), EndpointSelectionType._enumerators) + _M_Ice._t_EndpointSelectionType = IcePy.defineEnum( + '::Ice::EndpointSelectionType', EndpointSelectionType, (), EndpointSelectionType._enumerators) _M_Ice.EndpointSelectionType = EndpointSelectionType del EndpointSelectionType diff --git a/python/python/Ice/Endpoint_local.py b/python/python/Ice/Endpoint_local.py index 05ab73cdfcb..fc5a8ae35a5 100644 --- a/python/python/Ice/Endpoint_local.py +++ b/python/python/Ice/Endpoint_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.Version_ice import Ice.BuiltinSequences_ice import Ice.EndpointF_local @@ -27,6 +28,7 @@ if 'EndpointInfo' not in _M_Ice.__dict__: _M_Ice.EndpointInfo = Ice.createTempClass() + class EndpointInfo(object): """ Base class providing access to the endpoint details. @@ -35,6 +37,7 @@ class EndpointInfo(object): timeout -- The timeout for the endpoint in milliseconds. 0 means non-blocking, -1 means no timeout. compress -- Specifies whether or not compression should be used if available when using this endpoint. """ + def __init__(self, underlying=None, timeout=0, compress=False): if Ice.getType(self) == _M_Ice.EndpointInfo: raise RuntimeError('Ice.EndpointInfo is an abstract class') @@ -81,10 +84,12 @@ def __str__(self): if 'Endpoint' not in _M_Ice.__dict__: _M_Ice.Endpoint = Ice.createTempClass() + class Endpoint(object): """ The user-level interface to an endpoint. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Endpoint: raise RuntimeError('Ice.Endpoint is an abstract class') @@ -116,6 +121,7 @@ def __str__(self): if 'IPEndpointInfo' not in _M_Ice.__dict__: _M_Ice.IPEndpointInfo = Ice.createTempClass() + class IPEndpointInfo(_M_Ice.EndpointInfo): """ Provides access to the address details of a IP endpoint. @@ -124,6 +130,7 @@ class IPEndpointInfo(_M_Ice.EndpointInfo): port -- The port number. sourceAddress -- The source IP address. """ + def __init__(self, underlying=None, timeout=0, compress=False, host='', port=0, sourceAddress=''): if Ice.getType(self) == _M_Ice.IPEndpointInfo: raise RuntimeError('Ice.IPEndpointInfo is an abstract class') @@ -151,10 +158,12 @@ def __str__(self): if 'TCPEndpointInfo' not in _M_Ice.__dict__: _M_Ice.TCPEndpointInfo = Ice.createTempClass() + class TCPEndpointInfo(_M_Ice.IPEndpointInfo): """ Provides access to a TCP endpoint information. """ + def __init__(self, underlying=None, timeout=0, compress=False, host='', port=0, sourceAddress=''): if Ice.getType(self) == _M_Ice.TCPEndpointInfo: raise RuntimeError('Ice.TCPEndpointInfo is an abstract class') @@ -167,7 +176,8 @@ def __str__(self): _M_Ice._t_TCPEndpointInfo = IcePy.declareValue('::Ice::TCPEndpointInfo') - _M_Ice._t_TCPEndpointInfo = IcePy.defineValue('::Ice::TCPEndpointInfo', TCPEndpointInfo, -1, (), False, False, _M_Ice._t_IPEndpointInfo, ()) + _M_Ice._t_TCPEndpointInfo = IcePy.defineValue( + '::Ice::TCPEndpointInfo', TCPEndpointInfo, -1, (), False, False, _M_Ice._t_IPEndpointInfo, ()) TCPEndpointInfo._ice_type = _M_Ice._t_TCPEndpointInfo _M_Ice.TCPEndpointInfo = TCPEndpointInfo @@ -175,6 +185,7 @@ def __str__(self): if 'UDPEndpointInfo' not in _M_Ice.__dict__: _M_Ice.UDPEndpointInfo = Ice.createTempClass() + class UDPEndpointInfo(_M_Ice.IPEndpointInfo): """ Provides access to an UDP endpoint information. @@ -182,6 +193,7 @@ class UDPEndpointInfo(_M_Ice.IPEndpointInfo): mcastInterface -- The multicast interface. mcastTtl -- The multicast time-to-live (or hops). """ + def __init__(self, underlying=None, timeout=0, compress=False, host='', port=0, sourceAddress='', mcastInterface='', mcastTtl=0): if Ice.getType(self) == _M_Ice.UDPEndpointInfo: raise RuntimeError('Ice.UDPEndpointInfo is an abstract class') @@ -207,12 +219,14 @@ def __str__(self): if 'WSEndpointInfo' not in _M_Ice.__dict__: _M_Ice.WSEndpointInfo = Ice.createTempClass() + class WSEndpointInfo(_M_Ice.EndpointInfo): """ Provides access to a WebSocket endpoint information. Members: resource -- The URI configured with the endpoint. """ + def __init__(self, underlying=None, timeout=0, compress=False, resource=''): if Ice.getType(self) == _M_Ice.WSEndpointInfo: raise RuntimeError('Ice.WSEndpointInfo is an abstract class') @@ -226,7 +240,8 @@ def __str__(self): _M_Ice._t_WSEndpointInfo = IcePy.declareValue('::Ice::WSEndpointInfo') - _M_Ice._t_WSEndpointInfo = IcePy.defineValue('::Ice::WSEndpointInfo', WSEndpointInfo, -1, (), False, False, _M_Ice._t_EndpointInfo, (('resource', (), IcePy._t_string, False, 0),)) + _M_Ice._t_WSEndpointInfo = IcePy.defineValue('::Ice::WSEndpointInfo', WSEndpointInfo, -1, + (), False, False, _M_Ice._t_EndpointInfo, (('resource', (), IcePy._t_string, False, 0),)) WSEndpointInfo._ice_type = _M_Ice._t_WSEndpointInfo _M_Ice.WSEndpointInfo = WSEndpointInfo @@ -234,6 +249,7 @@ def __str__(self): if 'OpaqueEndpointInfo' not in _M_Ice.__dict__: _M_Ice.OpaqueEndpointInfo = Ice.createTempClass() + class OpaqueEndpointInfo(_M_Ice.EndpointInfo): """ Provides access to the details of an opaque endpoint. @@ -241,6 +257,7 @@ class OpaqueEndpointInfo(_M_Ice.EndpointInfo): rawEncoding -- The encoding version of the opaque endpoint (to decode or encode the rawBytes). rawBytes -- The raw encoding of the opaque endpoint. """ + def __init__(self, underlying=None, timeout=0, compress=False, rawEncoding=Ice._struct_marker, rawBytes=None): if Ice.getType(self) == _M_Ice.OpaqueEndpointInfo: raise RuntimeError('Ice.OpaqueEndpointInfo is an abstract class') diff --git a/python/python/Ice/FacetMap_local.py b/python/python/Ice/FacetMap_local.py index febb7d7530e..579959d7b19 100644 --- a/python/python/Ice/FacetMap_local.py +++ b/python/python/Ice/FacetMap_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/ImplicitContextF_local.py b/python/python/Ice/ImplicitContextF_local.py index 5e017c52e16..0c718f690a7 100644 --- a/python/python/Ice/ImplicitContextF_local.py +++ b/python/python/Ice/ImplicitContextF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/ImplicitContext_local.py b/python/python/Ice/ImplicitContext_local.py index 634325382d5..518e0f0e2e1 100644 --- a/python/python/Ice/ImplicitContext_local.py +++ b/python/python/Ice/ImplicitContext_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.LocalException_local import Ice.Current_local @@ -26,6 +27,7 @@ if 'ImplicitContext' not in _M_Ice.__dict__: _M_Ice.ImplicitContext = Ice.createTempClass() + class ImplicitContext(object): """ An interface to associate implict contexts with communicators. When you make a remote invocation without an @@ -46,6 +48,7 @@ class ImplicitContext(object): of the java.util.Map methods, with java.lang.Object replaced by string and null replaced by the empty-string. """ + def __init__(self): if Ice.getType(self) == _M_Ice.ImplicitContext: raise RuntimeError('Ice.ImplicitContext is an abstract class') @@ -109,7 +112,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice._t_ImplicitContext = IcePy.defineValue('::Ice::ImplicitContext', ImplicitContext, -1, (), False, True, None, ()) + _M_Ice._t_ImplicitContext = IcePy.defineValue( + '::Ice::ImplicitContext', ImplicitContext, -1, (), False, True, None, ()) ImplicitContext._ice_type = _M_Ice._t_ImplicitContext _M_Ice.ImplicitContext = ImplicitContext diff --git a/python/python/Ice/InstrumentationF_local.py b/python/python/Ice/InstrumentationF_local.py index e3ca119a58e..cbef7d8b746 100644 --- a/python/python/Ice/InstrumentationF_local.py +++ b/python/python/Ice/InstrumentationF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Instrumentation_local.py b/python/python/Ice/Instrumentation_local.py index d254c9be229..d3a2a9e9efc 100644 --- a/python/python/Ice/Instrumentation_local.py +++ b/python/python/Ice/Instrumentation_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.EndpointF_local import Ice.ConnectionF_local import Ice.Current_local @@ -35,10 +36,12 @@ if 'Observer' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.Observer = Ice.createTempClass() + class Observer(object): """ The object observer interface used by instrumented objects to notify the observer of their existence. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.Observer: raise RuntimeError('Ice.Instrumentation.Observer is an abstract class') @@ -70,7 +73,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_Observer = IcePy.defineValue('::Ice::Instrumentation::Observer', Observer, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_Observer = IcePy.defineValue( + '::Ice::Instrumentation::Observer', Observer, -1, (), False, True, None, ()) Observer._ice_type = _M_Ice.Instrumentation._t_Observer _M_Ice.Instrumentation.Observer = Observer @@ -78,6 +82,7 @@ def __str__(self): if 'ThreadState' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ThreadState = Ice.createTempClass() + class ThreadState(Ice.EnumBase): """ The thread state enumeration keeps track of the different possible states of Ice threads. @@ -103,20 +108,24 @@ def valueOf(self, _n): ThreadState.ThreadStateInUseForIO = ThreadState("ThreadStateInUseForIO", 1) ThreadState.ThreadStateInUseForUser = ThreadState("ThreadStateInUseForUser", 2) ThreadState.ThreadStateInUseForOther = ThreadState("ThreadStateInUseForOther", 3) - ThreadState._enumerators = { 0:ThreadState.ThreadStateIdle, 1:ThreadState.ThreadStateInUseForIO, 2:ThreadState.ThreadStateInUseForUser, 3:ThreadState.ThreadStateInUseForOther } + ThreadState._enumerators = {0: ThreadState.ThreadStateIdle, 1: ThreadState.ThreadStateInUseForIO, + 2: ThreadState.ThreadStateInUseForUser, 3: ThreadState.ThreadStateInUseForOther} - _M_Ice.Instrumentation._t_ThreadState = IcePy.defineEnum('::Ice::Instrumentation::ThreadState', ThreadState, (), ThreadState._enumerators) + _M_Ice.Instrumentation._t_ThreadState = IcePy.defineEnum( + '::Ice::Instrumentation::ThreadState', ThreadState, (), ThreadState._enumerators) _M_Ice.Instrumentation.ThreadState = ThreadState del ThreadState if 'ThreadObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ThreadObserver = Ice.createTempClass() + class ThreadObserver(_M_Ice.Instrumentation.Observer): """ The thread observer interface to instrument Ice threads. This can be threads from the Ice thread pool or utility threads used by the Ice core. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.ThreadObserver: raise RuntimeError('Ice.Instrumentation.ThreadObserver is an abstract class') @@ -135,7 +144,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_ThreadObserver = IcePy.defineValue('::Ice::Instrumentation::ThreadObserver', ThreadObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_ThreadObserver = IcePy.defineValue( + '::Ice::Instrumentation::ThreadObserver', ThreadObserver, -1, (), False, True, None, ()) ThreadObserver._ice_type = _M_Ice.Instrumentation._t_ThreadObserver _M_Ice.Instrumentation.ThreadObserver = ThreadObserver @@ -143,6 +153,7 @@ def __str__(self): if 'ConnectionState' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ConnectionState = Ice.createTempClass() + class ConnectionState(Ice.EnumBase): """ The state of an Ice connection. @@ -169,19 +180,23 @@ def valueOf(self, _n): ConnectionState.ConnectionStateActive = ConnectionState("ConnectionStateActive", 2) ConnectionState.ConnectionStateClosing = ConnectionState("ConnectionStateClosing", 3) ConnectionState.ConnectionStateClosed = ConnectionState("ConnectionStateClosed", 4) - ConnectionState._enumerators = { 0:ConnectionState.ConnectionStateValidating, 1:ConnectionState.ConnectionStateHolding, 2:ConnectionState.ConnectionStateActive, 3:ConnectionState.ConnectionStateClosing, 4:ConnectionState.ConnectionStateClosed } + ConnectionState._enumerators = {0: ConnectionState.ConnectionStateValidating, 1: ConnectionState.ConnectionStateHolding, + 2: ConnectionState.ConnectionStateActive, 3: ConnectionState.ConnectionStateClosing, 4: ConnectionState.ConnectionStateClosed} - _M_Ice.Instrumentation._t_ConnectionState = IcePy.defineEnum('::Ice::Instrumentation::ConnectionState', ConnectionState, (), ConnectionState._enumerators) + _M_Ice.Instrumentation._t_ConnectionState = IcePy.defineEnum( + '::Ice::Instrumentation::ConnectionState', ConnectionState, (), ConnectionState._enumerators) _M_Ice.Instrumentation.ConnectionState = ConnectionState del ConnectionState if 'ConnectionObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ConnectionObserver = Ice.createTempClass() + class ConnectionObserver(_M_Ice.Instrumentation.Observer): """ The connection observer interface to instrument Ice connections. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.ConnectionObserver: raise RuntimeError('Ice.Instrumentation.ConnectionObserver is an abstract class') @@ -207,7 +222,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_ConnectionObserver = IcePy.defineValue('::Ice::Instrumentation::ConnectionObserver', ConnectionObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_ConnectionObserver = IcePy.defineValue( + '::Ice::Instrumentation::ConnectionObserver', ConnectionObserver, -1, (), False, True, None, ()) ConnectionObserver._ice_type = _M_Ice.Instrumentation._t_ConnectionObserver _M_Ice.Instrumentation.ConnectionObserver = ConnectionObserver @@ -215,10 +231,12 @@ def __str__(self): if 'DispatchObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.DispatchObserver = Ice.createTempClass() + class DispatchObserver(_M_Ice.Instrumentation.Observer): """ The dispatch observer to instrument servant dispatch. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.DispatchObserver: raise RuntimeError('Ice.Instrumentation.DispatchObserver is an abstract class') @@ -242,7 +260,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_DispatchObserver = IcePy.defineValue('::Ice::Instrumentation::DispatchObserver', DispatchObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_DispatchObserver = IcePy.defineValue( + '::Ice::Instrumentation::DispatchObserver', DispatchObserver, -1, (), False, True, None, ()) DispatchObserver._ice_type = _M_Ice.Instrumentation._t_DispatchObserver _M_Ice.Instrumentation.DispatchObserver = DispatchObserver @@ -250,10 +269,12 @@ def __str__(self): if 'ChildInvocationObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ChildInvocationObserver = Ice.createTempClass() + class ChildInvocationObserver(_M_Ice.Instrumentation.Observer): """ The child invocation observer to instrument remote or collocated invocations. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.ChildInvocationObserver: raise RuntimeError('Ice.Instrumentation.ChildInvocationObserver is an abstract class') @@ -271,7 +292,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_ChildInvocationObserver = IcePy.defineValue('::Ice::Instrumentation::ChildInvocationObserver', ChildInvocationObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_ChildInvocationObserver = IcePy.defineValue( + '::Ice::Instrumentation::ChildInvocationObserver', ChildInvocationObserver, -1, (), False, True, None, ()) ChildInvocationObserver._ice_type = _M_Ice.Instrumentation._t_ChildInvocationObserver _M_Ice.Instrumentation.ChildInvocationObserver = ChildInvocationObserver @@ -279,10 +301,12 @@ def __str__(self): if 'RemoteObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.RemoteObserver = Ice.createTempClass() + class RemoteObserver(_M_Ice.Instrumentation.ChildInvocationObserver): """ The remote observer to instrument invocations that are sent over the wire. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.RemoteObserver: raise RuntimeError('Ice.Instrumentation.RemoteObserver is an abstract class') @@ -292,7 +316,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_RemoteObserver = IcePy.defineValue('::Ice::Instrumentation::RemoteObserver', RemoteObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_RemoteObserver = IcePy.defineValue( + '::Ice::Instrumentation::RemoteObserver', RemoteObserver, -1, (), False, True, None, ()) RemoteObserver._ice_type = _M_Ice.Instrumentation._t_RemoteObserver _M_Ice.Instrumentation.RemoteObserver = RemoteObserver @@ -300,10 +325,12 @@ def __str__(self): if 'CollocatedObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.CollocatedObserver = Ice.createTempClass() + class CollocatedObserver(_M_Ice.Instrumentation.ChildInvocationObserver): """ The collocated observer to instrument invocations that are collocated. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.CollocatedObserver: raise RuntimeError('Ice.Instrumentation.CollocatedObserver is an abstract class') @@ -313,7 +340,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_CollocatedObserver = IcePy.defineValue('::Ice::Instrumentation::CollocatedObserver', CollocatedObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_CollocatedObserver = IcePy.defineValue( + '::Ice::Instrumentation::CollocatedObserver', CollocatedObserver, -1, (), False, True, None, ()) CollocatedObserver._ice_type = _M_Ice.Instrumentation._t_CollocatedObserver _M_Ice.Instrumentation.CollocatedObserver = CollocatedObserver @@ -321,11 +349,13 @@ def __str__(self): if 'InvocationObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.InvocationObserver = Ice.createTempClass() + class InvocationObserver(_M_Ice.Instrumentation.Observer): """ The invocation observer to instrument invocations on proxies. A proxy invocation can either result in a collocated or remote invocation. If it results in a remote invocation, a sub-observer is requested for the remote invocation. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.InvocationObserver: raise RuntimeError('Ice.Instrumentation.InvocationObserver is an abstract class') @@ -370,7 +400,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_InvocationObserver = IcePy.defineValue('::Ice::Instrumentation::InvocationObserver', InvocationObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_InvocationObserver = IcePy.defineValue( + '::Ice::Instrumentation::InvocationObserver', InvocationObserver, -1, (), False, True, None, ()) InvocationObserver._ice_type = _M_Ice.Instrumentation._t_InvocationObserver _M_Ice.Instrumentation.InvocationObserver = InvocationObserver @@ -378,6 +409,7 @@ def __str__(self): if 'ObserverUpdater' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.ObserverUpdater = Ice.createTempClass() + class ObserverUpdater(object): """ The observer updater interface. This interface is implemented by the Ice run-time and an instance of this interface @@ -387,6 +419,7 @@ class ObserverUpdater(object): This interface can be used by add-ins implementing the CommunicatorObserver interface to update the observers of connections and threads. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.ObserverUpdater: raise RuntimeError('Ice.Instrumentation.ObserverUpdater is an abstract class') @@ -415,7 +448,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_ObserverUpdater = IcePy.defineValue('::Ice::Instrumentation::ObserverUpdater', ObserverUpdater, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_ObserverUpdater = IcePy.defineValue( + '::Ice::Instrumentation::ObserverUpdater', ObserverUpdater, -1, (), False, True, None, ()) ObserverUpdater._ice_type = _M_Ice.Instrumentation._t_ObserverUpdater _M_Ice.Instrumentation.ObserverUpdater = ObserverUpdater @@ -423,6 +457,7 @@ def __str__(self): if 'CommunicatorObserver' not in _M_Ice.Instrumentation.__dict__: _M_Ice.Instrumentation.CommunicatorObserver = Ice.createTempClass() + class CommunicatorObserver(object): """ The communicator observer interface used by the Ice run-time to obtain and update observers for its observable @@ -430,6 +465,7 @@ class CommunicatorObserver(object): statistics. An instance of this interface can be provided to the Ice run-time through the Ice communicator initialization data. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Instrumentation.CommunicatorObserver: raise RuntimeError('Ice.Instrumentation.CommunicatorObserver is an abstract class') @@ -521,7 +557,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice.Instrumentation._t_CommunicatorObserver = IcePy.defineValue('::Ice::Instrumentation::CommunicatorObserver', CommunicatorObserver, -1, (), False, True, None, ()) + _M_Ice.Instrumentation._t_CommunicatorObserver = IcePy.defineValue( + '::Ice::Instrumentation::CommunicatorObserver', CommunicatorObserver, -1, (), False, True, None, ()) CommunicatorObserver._ice_type = _M_Ice.Instrumentation._t_CommunicatorObserver _M_Ice.Instrumentation.CommunicatorObserver = CommunicatorObserver diff --git a/python/python/Ice/LocalException_local.py b/python/python/Ice/LocalException_local.py index 99e0f15bb2e..388589b7442 100644 --- a/python/python/Ice/LocalException_local.py +++ b/python/python/Ice/LocalException_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.Identity_ice import Ice.Version_ice import Ice.BuiltinSequences_ice @@ -27,12 +28,14 @@ if 'InitializationException' not in _M_Ice.__dict__: _M_Ice.InitializationException = Ice.createTempClass() + class InitializationException(Ice.LocalException): """ This exception is raised when a failure occurs during initialization. Members: reason -- The reason for the failure. """ + def __init__(self, reason=''): self.reason = reason @@ -43,7 +46,8 @@ def __str__(self): _ice_id = '::Ice::InitializationException' - _M_Ice._t_InitializationException = IcePy.defineException('::Ice::InitializationException', InitializationException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_Ice._t_InitializationException = IcePy.defineException( + '::Ice::InitializationException', InitializationException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) InitializationException._ice_type = _M_Ice._t_InitializationException _M_Ice.InitializationException = InitializationException @@ -51,12 +55,14 @@ def __str__(self): if 'PluginInitializationException' not in _M_Ice.__dict__: _M_Ice.PluginInitializationException = Ice.createTempClass() + class PluginInitializationException(Ice.LocalException): """ This exception indicates that a failure occurred while initializing a plug-in. Members: reason -- The reason for the failure. """ + def __init__(self, reason=''): self.reason = reason @@ -67,7 +73,8 @@ def __str__(self): _ice_id = '::Ice::PluginInitializationException' - _M_Ice._t_PluginInitializationException = IcePy.defineException('::Ice::PluginInitializationException', PluginInitializationException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_Ice._t_PluginInitializationException = IcePy.defineException( + '::Ice::PluginInitializationException', PluginInitializationException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) PluginInitializationException._ice_type = _M_Ice._t_PluginInitializationException _M_Ice.PluginInitializationException = PluginInitializationException @@ -75,10 +82,12 @@ def __str__(self): if 'CollocationOptimizationException' not in _M_Ice.__dict__: _M_Ice.CollocationOptimizationException = Ice.createTempClass() + class CollocationOptimizationException(Ice.LocalException): """ This exception is raised if a feature is requested that is not supported with collocation optimization. """ + def __init__(self): pass @@ -89,7 +98,8 @@ def __str__(self): _ice_id = '::Ice::CollocationOptimizationException' - _M_Ice._t_CollocationOptimizationException = IcePy.defineException('::Ice::CollocationOptimizationException', CollocationOptimizationException, (), False, None, ()) + _M_Ice._t_CollocationOptimizationException = IcePy.defineException( + '::Ice::CollocationOptimizationException', CollocationOptimizationException, (), False, None, ()) CollocationOptimizationException._ice_type = _M_Ice._t_CollocationOptimizationException _M_Ice.CollocationOptimizationException = CollocationOptimizationException @@ -97,6 +107,7 @@ def __str__(self): if 'AlreadyRegisteredException' not in _M_Ice.__dict__: _M_Ice.AlreadyRegisteredException = Ice.createTempClass() + class AlreadyRegisteredException(Ice.LocalException): """ An attempt was made to register something more than once with the Ice run time. This exception is raised if an @@ -107,6 +118,7 @@ class AlreadyRegisteredException(Ice.LocalException): "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". id -- The ID (or name) of the object that is registered already. """ + def __init__(self, kindOfObject='', id=''): self.kindOfObject = kindOfObject self.id = id @@ -129,6 +141,7 @@ def __str__(self): if 'NotRegisteredException' not in _M_Ice.__dict__: _M_Ice.NotRegisteredException = Ice.createTempClass() + class NotRegisteredException(Ice.LocalException): """ An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. @@ -141,6 +154,7 @@ class NotRegisteredException(Ice.LocalException): "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". id -- The ID (or name) of the object that could not be removed. """ + def __init__(self, kindOfObject='', id=''): self.kindOfObject = kindOfObject self.id = id @@ -163,6 +177,7 @@ def __str__(self): if 'TwowayOnlyException' not in _M_Ice.__dict__: _M_Ice.TwowayOnlyException = Ice.createTempClass() + class TwowayOnlyException(Ice.LocalException): """ The operation can only be invoked with a twoway request. This exception is raised if an attempt is made to invoke @@ -171,6 +186,7 @@ class TwowayOnlyException(Ice.LocalException): Members: operation -- The name of the operation that was invoked. """ + def __init__(self, operation=''): self.operation = operation @@ -181,7 +197,8 @@ def __str__(self): _ice_id = '::Ice::TwowayOnlyException' - _M_Ice._t_TwowayOnlyException = IcePy.defineException('::Ice::TwowayOnlyException', TwowayOnlyException, (), False, None, (('operation', (), IcePy._t_string, False, 0),)) + _M_Ice._t_TwowayOnlyException = IcePy.defineException( + '::Ice::TwowayOnlyException', TwowayOnlyException, (), False, None, (('operation', (), IcePy._t_string, False, 0),)) TwowayOnlyException._ice_type = _M_Ice._t_TwowayOnlyException _M_Ice.TwowayOnlyException = TwowayOnlyException @@ -189,6 +206,7 @@ def __str__(self): if 'CloneNotImplementedException' not in _M_Ice.__dict__: _M_Ice.CloneNotImplementedException = Ice.createTempClass() + class CloneNotImplementedException(Ice.LocalException): """ An attempt was made to clone a class that does not support cloning. This exception is raised if @@ -196,6 +214,7 @@ class CloneNotImplementedException(Ice.LocalException): containing operations), and the derived class does not provide an implementation of the ice_clone operation (C++ only). """ + def __init__(self): pass @@ -206,7 +225,8 @@ def __str__(self): _ice_id = '::Ice::CloneNotImplementedException' - _M_Ice._t_CloneNotImplementedException = IcePy.defineException('::Ice::CloneNotImplementedException', CloneNotImplementedException, (), False, None, ()) + _M_Ice._t_CloneNotImplementedException = IcePy.defineException( + '::Ice::CloneNotImplementedException', CloneNotImplementedException, (), False, None, ()) CloneNotImplementedException._ice_type = _M_Ice._t_CloneNotImplementedException _M_Ice.CloneNotImplementedException = CloneNotImplementedException @@ -214,6 +234,7 @@ def __str__(self): if 'UnknownException' not in _M_Ice.__dict__: _M_Ice.UnknownException = Ice.createTempClass() + class UnknownException(Ice.LocalException): """ This exception is raised if an operation call on a server raises an unknown exception. For example, for C++, this @@ -222,6 +243,7 @@ class UnknownException(Ice.LocalException): Members: unknown -- This field is set to the textual representation of the unknown exception if available. """ + def __init__(self, unknown=''): self.unknown = unknown @@ -232,7 +254,8 @@ def __str__(self): _ice_id = '::Ice::UnknownException' - _M_Ice._t_UnknownException = IcePy.defineException('::Ice::UnknownException', UnknownException, (), False, None, (('unknown', (), IcePy._t_string, False, 0),)) + _M_Ice._t_UnknownException = IcePy.defineException( + '::Ice::UnknownException', UnknownException, (), False, None, (('unknown', (), IcePy._t_string, False, 0),)) UnknownException._ice_type = _M_Ice._t_UnknownException _M_Ice.UnknownException = UnknownException @@ -240,6 +263,7 @@ def __str__(self): if 'UnknownLocalException' not in _M_Ice.__dict__: _M_Ice.UnknownLocalException = Ice.createTempClass() + class UnknownLocalException(_M_Ice.UnknownException): """ This exception is raised if an operation call on a server raises a local exception. Because local exceptions are @@ -248,6 +272,7 @@ class UnknownLocalException(_M_Ice.UnknownException): RequestFailedException, which are transmitted by the Ice protocol even though they are declared local. """ + def __init__(self, unknown=''): _M_Ice.UnknownException.__init__(self, unknown) @@ -258,7 +283,8 @@ def __str__(self): _ice_id = '::Ice::UnknownLocalException' - _M_Ice._t_UnknownLocalException = IcePy.defineException('::Ice::UnknownLocalException', UnknownLocalException, (), False, _M_Ice._t_UnknownException, ()) + _M_Ice._t_UnknownLocalException = IcePy.defineException( + '::Ice::UnknownLocalException', UnknownLocalException, (), False, _M_Ice._t_UnknownException, ()) UnknownLocalException._ice_type = _M_Ice._t_UnknownLocalException _M_Ice.UnknownLocalException = UnknownLocalException @@ -266,6 +292,7 @@ def __str__(self): if 'UnknownUserException' not in _M_Ice.__dict__: _M_Ice.UnknownUserException = Ice.createTempClass() + class UnknownUserException(_M_Ice.UnknownException): """ An operation raised an incorrect user exception. This exception is raised if an operation raises a user exception @@ -274,6 +301,7 @@ class UnknownUserException(_M_Ice.UnknownException): This is necessary in order to not violate the contract established by an operation's signature: Only local exceptions and user exceptions declared in the throws clause can be raised. """ + def __init__(self, unknown=''): _M_Ice.UnknownException.__init__(self, unknown) @@ -284,7 +312,8 @@ def __str__(self): _ice_id = '::Ice::UnknownUserException' - _M_Ice._t_UnknownUserException = IcePy.defineException('::Ice::UnknownUserException', UnknownUserException, (), False, _M_Ice._t_UnknownException, ()) + _M_Ice._t_UnknownUserException = IcePy.defineException( + '::Ice::UnknownUserException', UnknownUserException, (), False, _M_Ice._t_UnknownException, ()) UnknownUserException._ice_type = _M_Ice._t_UnknownUserException _M_Ice.UnknownUserException = UnknownUserException @@ -292,10 +321,12 @@ def __str__(self): if 'VersionMismatchException' not in _M_Ice.__dict__: _M_Ice.VersionMismatchException = Ice.createTempClass() + class VersionMismatchException(Ice.LocalException): """ This exception is raised if the Ice library version does not match the version in the Ice header files. """ + def __init__(self): pass @@ -306,7 +337,8 @@ def __str__(self): _ice_id = '::Ice::VersionMismatchException' - _M_Ice._t_VersionMismatchException = IcePy.defineException('::Ice::VersionMismatchException', VersionMismatchException, (), False, None, ()) + _M_Ice._t_VersionMismatchException = IcePy.defineException( + '::Ice::VersionMismatchException', VersionMismatchException, (), False, None, ()) VersionMismatchException._ice_type = _M_Ice._t_VersionMismatchException _M_Ice.VersionMismatchException = VersionMismatchException @@ -314,10 +346,12 @@ def __str__(self): if 'CommunicatorDestroyedException' not in _M_Ice.__dict__: _M_Ice.CommunicatorDestroyedException = Ice.createTempClass() + class CommunicatorDestroyedException(Ice.LocalException): """ This exception is raised if the Communicator has been destroyed. """ + def __init__(self): pass @@ -328,7 +362,8 @@ def __str__(self): _ice_id = '::Ice::CommunicatorDestroyedException' - _M_Ice._t_CommunicatorDestroyedException = IcePy.defineException('::Ice::CommunicatorDestroyedException', CommunicatorDestroyedException, (), False, None, ()) + _M_Ice._t_CommunicatorDestroyedException = IcePy.defineException( + '::Ice::CommunicatorDestroyedException', CommunicatorDestroyedException, (), False, None, ()) CommunicatorDestroyedException._ice_type = _M_Ice._t_CommunicatorDestroyedException _M_Ice.CommunicatorDestroyedException = CommunicatorDestroyedException @@ -336,12 +371,14 @@ def __str__(self): if 'ObjectAdapterDeactivatedException' not in _M_Ice.__dict__: _M_Ice.ObjectAdapterDeactivatedException = Ice.createTempClass() + class ObjectAdapterDeactivatedException(Ice.LocalException): """ This exception is raised if an attempt is made to use a deactivated ObjectAdapter. Members: name -- Name of the adapter. """ + def __init__(self, name=''): self.name = name @@ -352,7 +389,8 @@ def __str__(self): _ice_id = '::Ice::ObjectAdapterDeactivatedException' - _M_Ice._t_ObjectAdapterDeactivatedException = IcePy.defineException('::Ice::ObjectAdapterDeactivatedException', ObjectAdapterDeactivatedException, (), False, None, (('name', (), IcePy._t_string, False, 0),)) + _M_Ice._t_ObjectAdapterDeactivatedException = IcePy.defineException( + '::Ice::ObjectAdapterDeactivatedException', ObjectAdapterDeactivatedException, (), False, None, (('name', (), IcePy._t_string, False, 0),)) ObjectAdapterDeactivatedException._ice_type = _M_Ice._t_ObjectAdapterDeactivatedException _M_Ice.ObjectAdapterDeactivatedException = ObjectAdapterDeactivatedException @@ -360,6 +398,7 @@ def __str__(self): if 'ObjectAdapterIdInUseException' not in _M_Ice.__dict__: _M_Ice.ObjectAdapterIdInUseException = Ice.createTempClass() + class ObjectAdapterIdInUseException(Ice.LocalException): """ This exception is raised if an ObjectAdapter cannot be activated. This happens if the Locator @@ -367,6 +406,7 @@ class ObjectAdapterIdInUseException(Ice.LocalException): Members: id -- Adapter ID. """ + def __init__(self, id=''): self.id = id @@ -377,7 +417,8 @@ def __str__(self): _ice_id = '::Ice::ObjectAdapterIdInUseException' - _M_Ice._t_ObjectAdapterIdInUseException = IcePy.defineException('::Ice::ObjectAdapterIdInUseException', ObjectAdapterIdInUseException, (), False, None, (('id', (), IcePy._t_string, False, 0),)) + _M_Ice._t_ObjectAdapterIdInUseException = IcePy.defineException( + '::Ice::ObjectAdapterIdInUseException', ObjectAdapterIdInUseException, (), False, None, (('id', (), IcePy._t_string, False, 0),)) ObjectAdapterIdInUseException._ice_type = _M_Ice._t_ObjectAdapterIdInUseException _M_Ice.ObjectAdapterIdInUseException = ObjectAdapterIdInUseException @@ -385,12 +426,14 @@ def __str__(self): if 'NoEndpointException' not in _M_Ice.__dict__: _M_Ice.NoEndpointException = Ice.createTempClass() + class NoEndpointException(Ice.LocalException): """ This exception is raised if no suitable endpoint is available. Members: proxy -- The stringified proxy for which no suitable endpoint is available. """ + def __init__(self, proxy=''): self.proxy = proxy @@ -401,7 +444,8 @@ def __str__(self): _ice_id = '::Ice::NoEndpointException' - _M_Ice._t_NoEndpointException = IcePy.defineException('::Ice::NoEndpointException', NoEndpointException, (), False, None, (('proxy', (), IcePy._t_string, False, 0),)) + _M_Ice._t_NoEndpointException = IcePy.defineException( + '::Ice::NoEndpointException', NoEndpointException, (), False, None, (('proxy', (), IcePy._t_string, False, 0),)) NoEndpointException._ice_type = _M_Ice._t_NoEndpointException _M_Ice.NoEndpointException = NoEndpointException @@ -409,12 +453,14 @@ def __str__(self): if 'EndpointParseException' not in _M_Ice.__dict__: _M_Ice.EndpointParseException = Ice.createTempClass() + class EndpointParseException(Ice.LocalException): """ This exception is raised if there was an error while parsing an endpoint. Members: str -- Describes the failure and includes the string that could not be parsed. """ + def __init__(self, str=''): self.str = str @@ -425,7 +471,8 @@ def __str__(self): _ice_id = '::Ice::EndpointParseException' - _M_Ice._t_EndpointParseException = IcePy.defineException('::Ice::EndpointParseException', EndpointParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) + _M_Ice._t_EndpointParseException = IcePy.defineException( + '::Ice::EndpointParseException', EndpointParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) EndpointParseException._ice_type = _M_Ice._t_EndpointParseException _M_Ice.EndpointParseException = EndpointParseException @@ -433,12 +480,14 @@ def __str__(self): if 'EndpointSelectionTypeParseException' not in _M_Ice.__dict__: _M_Ice.EndpointSelectionTypeParseException = Ice.createTempClass() + class EndpointSelectionTypeParseException(Ice.LocalException): """ This exception is raised if there was an error while parsing an endpoint selection type. Members: str -- Describes the failure and includes the string that could not be parsed. """ + def __init__(self, str=''): self.str = str @@ -449,7 +498,8 @@ def __str__(self): _ice_id = '::Ice::EndpointSelectionTypeParseException' - _M_Ice._t_EndpointSelectionTypeParseException = IcePy.defineException('::Ice::EndpointSelectionTypeParseException', EndpointSelectionTypeParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) + _M_Ice._t_EndpointSelectionTypeParseException = IcePy.defineException( + '::Ice::EndpointSelectionTypeParseException', EndpointSelectionTypeParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) EndpointSelectionTypeParseException._ice_type = _M_Ice._t_EndpointSelectionTypeParseException _M_Ice.EndpointSelectionTypeParseException = EndpointSelectionTypeParseException @@ -457,12 +507,14 @@ def __str__(self): if 'VersionParseException' not in _M_Ice.__dict__: _M_Ice.VersionParseException = Ice.createTempClass() + class VersionParseException(Ice.LocalException): """ This exception is raised if there was an error while parsing a version. Members: str -- Describes the failure and includes the string that could not be parsed. """ + def __init__(self, str=''): self.str = str @@ -473,7 +525,8 @@ def __str__(self): _ice_id = '::Ice::VersionParseException' - _M_Ice._t_VersionParseException = IcePy.defineException('::Ice::VersionParseException', VersionParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) + _M_Ice._t_VersionParseException = IcePy.defineException( + '::Ice::VersionParseException', VersionParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) VersionParseException._ice_type = _M_Ice._t_VersionParseException _M_Ice.VersionParseException = VersionParseException @@ -481,12 +534,14 @@ def __str__(self): if 'IdentityParseException' not in _M_Ice.__dict__: _M_Ice.IdentityParseException = Ice.createTempClass() + class IdentityParseException(Ice.LocalException): """ This exception is raised if there was an error while parsing a stringified identity. Members: str -- Describes the failure and includes the string that could not be parsed. """ + def __init__(self, str=''): self.str = str @@ -497,7 +552,8 @@ def __str__(self): _ice_id = '::Ice::IdentityParseException' - _M_Ice._t_IdentityParseException = IcePy.defineException('::Ice::IdentityParseException', IdentityParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) + _M_Ice._t_IdentityParseException = IcePy.defineException( + '::Ice::IdentityParseException', IdentityParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) IdentityParseException._ice_type = _M_Ice._t_IdentityParseException _M_Ice.IdentityParseException = IdentityParseException @@ -505,12 +561,14 @@ def __str__(self): if 'ProxyParseException' not in _M_Ice.__dict__: _M_Ice.ProxyParseException = Ice.createTempClass() + class ProxyParseException(Ice.LocalException): """ This exception is raised if there was an error while parsing a stringified proxy. Members: str -- Describes the failure and includes the string that could not be parsed. """ + def __init__(self, str=''): self.str = str @@ -521,7 +579,8 @@ def __str__(self): _ice_id = '::Ice::ProxyParseException' - _M_Ice._t_ProxyParseException = IcePy.defineException('::Ice::ProxyParseException', ProxyParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) + _M_Ice._t_ProxyParseException = IcePy.defineException( + '::Ice::ProxyParseException', ProxyParseException, (), False, None, (('str', (), IcePy._t_string, False, 0),)) ProxyParseException._ice_type = _M_Ice._t_ProxyParseException _M_Ice.ProxyParseException = ProxyParseException @@ -529,12 +588,14 @@ def __str__(self): if 'IllegalIdentityException' not in _M_Ice.__dict__: _M_Ice.IllegalIdentityException = Ice.createTempClass() + class IllegalIdentityException(Ice.LocalException): """ This exception is raised if an illegal identity is encountered. Members: id -- The illegal identity. """ + def __init__(self, id=Ice._struct_marker): if id is Ice._struct_marker: self.id = _M_Ice.Identity() @@ -548,7 +609,8 @@ def __str__(self): _ice_id = '::Ice::IllegalIdentityException' - _M_Ice._t_IllegalIdentityException = IcePy.defineException('::Ice::IllegalIdentityException', IllegalIdentityException, (), False, None, (('id', (), _M_Ice._t_Identity, False, 0),)) + _M_Ice._t_IllegalIdentityException = IcePy.defineException( + '::Ice::IllegalIdentityException', IllegalIdentityException, (), False, None, (('id', (), _M_Ice._t_Identity, False, 0),)) IllegalIdentityException._ice_type = _M_Ice._t_IllegalIdentityException _M_Ice.IllegalIdentityException = IllegalIdentityException @@ -556,12 +618,14 @@ def __str__(self): if 'IllegalServantException' not in _M_Ice.__dict__: _M_Ice.IllegalServantException = Ice.createTempClass() + class IllegalServantException(Ice.LocalException): """ This exception is raised to reject an illegal servant (typically a null servant). Members: reason -- Describes why this servant is illegal. """ + def __init__(self, reason=''): self.reason = reason @@ -572,7 +636,8 @@ def __str__(self): _ice_id = '::Ice::IllegalServantException' - _M_Ice._t_IllegalServantException = IcePy.defineException('::Ice::IllegalServantException', IllegalServantException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_Ice._t_IllegalServantException = IcePy.defineException( + '::Ice::IllegalServantException', IllegalServantException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) IllegalServantException._ice_type = _M_Ice._t_IllegalServantException _M_Ice.IllegalServantException = IllegalServantException @@ -580,6 +645,7 @@ def __str__(self): if 'RequestFailedException' not in _M_Ice.__dict__: _M_Ice.RequestFailedException = Ice.createTempClass() + class RequestFailedException(Ice.LocalException): """ This exception is raised if a request failed. This exception, and all exceptions derived from @@ -590,6 +656,7 @@ class RequestFailedException(Ice.LocalException): facet -- The facet to which the request was sent. operation -- The operation name of the request. """ + def __init__(self, id=Ice._struct_marker, facet='', operation=''): if id is Ice._struct_marker: self.id = _M_Ice.Identity() @@ -617,11 +684,13 @@ def __str__(self): if 'ObjectNotExistException' not in _M_Ice.__dict__: _M_Ice.ObjectNotExistException = Ice.createTempClass() + class ObjectNotExistException(_M_Ice.RequestFailedException): """ This exception is raised if an object does not exist on the server, that is, if no facets with the given identity exist. """ + def __init__(self, id=Ice._struct_marker, facet='', operation=''): _M_Ice.RequestFailedException.__init__(self, id, facet, operation) @@ -632,7 +701,8 @@ def __str__(self): _ice_id = '::Ice::ObjectNotExistException' - _M_Ice._t_ObjectNotExistException = IcePy.defineException('::Ice::ObjectNotExistException', ObjectNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) + _M_Ice._t_ObjectNotExistException = IcePy.defineException( + '::Ice::ObjectNotExistException', ObjectNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) ObjectNotExistException._ice_type = _M_Ice._t_ObjectNotExistException _M_Ice.ObjectNotExistException = ObjectNotExistException @@ -640,11 +710,13 @@ def __str__(self): if 'FacetNotExistException' not in _M_Ice.__dict__: _M_Ice.FacetNotExistException = Ice.createTempClass() + class FacetNotExistException(_M_Ice.RequestFailedException): """ This exception is raised if no facet with the given name exists, but at least one facet with the given identity exists. """ + def __init__(self, id=Ice._struct_marker, facet='', operation=''): _M_Ice.RequestFailedException.__init__(self, id, facet, operation) @@ -655,7 +727,8 @@ def __str__(self): _ice_id = '::Ice::FacetNotExistException' - _M_Ice._t_FacetNotExistException = IcePy.defineException('::Ice::FacetNotExistException', FacetNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) + _M_Ice._t_FacetNotExistException = IcePy.defineException( + '::Ice::FacetNotExistException', FacetNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) FacetNotExistException._ice_type = _M_Ice._t_FacetNotExistException _M_Ice.FacetNotExistException = FacetNotExistException @@ -663,11 +736,13 @@ def __str__(self): if 'OperationNotExistException' not in _M_Ice.__dict__: _M_Ice.OperationNotExistException = Ice.createTempClass() + class OperationNotExistException(_M_Ice.RequestFailedException): """ This exception is raised if an operation for a given object does not exist on the server. Typically this is caused by either the client or the server using an outdated Slice specification. """ + def __init__(self, id=Ice._struct_marker, facet='', operation=''): _M_Ice.RequestFailedException.__init__(self, id, facet, operation) @@ -678,7 +753,8 @@ def __str__(self): _ice_id = '::Ice::OperationNotExistException' - _M_Ice._t_OperationNotExistException = IcePy.defineException('::Ice::OperationNotExistException', OperationNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) + _M_Ice._t_OperationNotExistException = IcePy.defineException( + '::Ice::OperationNotExistException', OperationNotExistException, (), False, _M_Ice._t_RequestFailedException, ()) OperationNotExistException._ice_type = _M_Ice._t_OperationNotExistException _M_Ice.OperationNotExistException = OperationNotExistException @@ -686,6 +762,7 @@ def __str__(self): if 'SyscallException' not in _M_Ice.__dict__: _M_Ice.SyscallException = Ice.createTempClass() + class SyscallException(Ice.LocalException): """ This exception is raised if a system error occurred in the server or client process. There are many possible causes @@ -695,6 +772,7 @@ class SyscallException(Ice.LocalException): For C++ and Windows, this is the value returned by GetLastError() or WSAGetLastError(). """ + def __init__(self, error=0): self.error = error @@ -705,7 +783,8 @@ def __str__(self): _ice_id = '::Ice::SyscallException' - _M_Ice._t_SyscallException = IcePy.defineException('::Ice::SyscallException', SyscallException, (), False, None, (('error', (), IcePy._t_int, False, 0),)) + _M_Ice._t_SyscallException = IcePy.defineException( + '::Ice::SyscallException', SyscallException, (), False, None, (('error', (), IcePy._t_int, False, 0),)) SyscallException._ice_type = _M_Ice._t_SyscallException _M_Ice.SyscallException = SyscallException @@ -713,10 +792,12 @@ def __str__(self): if 'SocketException' not in _M_Ice.__dict__: _M_Ice.SocketException = Ice.createTempClass() + class SocketException(_M_Ice.SyscallException): """ This exception indicates socket errors. """ + def __init__(self, error=0): _M_Ice.SyscallException.__init__(self, error) @@ -727,7 +808,8 @@ def __str__(self): _ice_id = '::Ice::SocketException' - _M_Ice._t_SocketException = IcePy.defineException('::Ice::SocketException', SocketException, (), False, _M_Ice._t_SyscallException, ()) + _M_Ice._t_SocketException = IcePy.defineException( + '::Ice::SocketException', SocketException, (), False, _M_Ice._t_SyscallException, ()) SocketException._ice_type = _M_Ice._t_SocketException _M_Ice.SocketException = SocketException @@ -735,12 +817,14 @@ def __str__(self): if 'CFNetworkException' not in _M_Ice.__dict__: _M_Ice.CFNetworkException = Ice.createTempClass() + class CFNetworkException(_M_Ice.SocketException): """ This exception indicates CFNetwork errors. Members: domain -- The domain of the error. """ + def __init__(self, error=0, domain=''): _M_Ice.SocketException.__init__(self, error) self.domain = domain @@ -752,7 +836,8 @@ def __str__(self): _ice_id = '::Ice::CFNetworkException' - _M_Ice._t_CFNetworkException = IcePy.defineException('::Ice::CFNetworkException', CFNetworkException, (), False, _M_Ice._t_SocketException, (('domain', (), IcePy._t_string, False, 0),)) + _M_Ice._t_CFNetworkException = IcePy.defineException( + '::Ice::CFNetworkException', CFNetworkException, (), False, _M_Ice._t_SocketException, (('domain', (), IcePy._t_string, False, 0),)) CFNetworkException._ice_type = _M_Ice._t_CFNetworkException _M_Ice.CFNetworkException = CFNetworkException @@ -760,12 +845,14 @@ def __str__(self): if 'FileException' not in _M_Ice.__dict__: _M_Ice.FileException = Ice.createTempClass() + class FileException(_M_Ice.SyscallException): """ This exception indicates file errors. Members: path -- The path of the file responsible for the error. """ + def __init__(self, error=0, path=''): _M_Ice.SyscallException.__init__(self, error) self.path = path @@ -777,7 +864,8 @@ def __str__(self): _ice_id = '::Ice::FileException' - _M_Ice._t_FileException = IcePy.defineException('::Ice::FileException', FileException, (), False, _M_Ice._t_SyscallException, (('path', (), IcePy._t_string, False, 0),)) + _M_Ice._t_FileException = IcePy.defineException( + '::Ice::FileException', FileException, (), False, _M_Ice._t_SyscallException, (('path', (), IcePy._t_string, False, 0),)) FileException._ice_type = _M_Ice._t_FileException _M_Ice.FileException = FileException @@ -785,10 +873,12 @@ def __str__(self): if 'ConnectFailedException' not in _M_Ice.__dict__: _M_Ice.ConnectFailedException = Ice.createTempClass() + class ConnectFailedException(_M_Ice.SocketException): """ This exception indicates connection failures. """ + def __init__(self, error=0): _M_Ice.SocketException.__init__(self, error) @@ -799,7 +889,8 @@ def __str__(self): _ice_id = '::Ice::ConnectFailedException' - _M_Ice._t_ConnectFailedException = IcePy.defineException('::Ice::ConnectFailedException', ConnectFailedException, (), False, _M_Ice._t_SocketException, ()) + _M_Ice._t_ConnectFailedException = IcePy.defineException( + '::Ice::ConnectFailedException', ConnectFailedException, (), False, _M_Ice._t_SocketException, ()) ConnectFailedException._ice_type = _M_Ice._t_ConnectFailedException _M_Ice.ConnectFailedException = ConnectFailedException @@ -807,10 +898,12 @@ def __str__(self): if 'ConnectionRefusedException' not in _M_Ice.__dict__: _M_Ice.ConnectionRefusedException = Ice.createTempClass() + class ConnectionRefusedException(_M_Ice.ConnectFailedException): """ This exception indicates a connection failure for which the server host actively refuses a connection. """ + def __init__(self, error=0): _M_Ice.ConnectFailedException.__init__(self, error) @@ -821,7 +914,8 @@ def __str__(self): _ice_id = '::Ice::ConnectionRefusedException' - _M_Ice._t_ConnectionRefusedException = IcePy.defineException('::Ice::ConnectionRefusedException', ConnectionRefusedException, (), False, _M_Ice._t_ConnectFailedException, ()) + _M_Ice._t_ConnectionRefusedException = IcePy.defineException( + '::Ice::ConnectionRefusedException', ConnectionRefusedException, (), False, _M_Ice._t_ConnectFailedException, ()) ConnectionRefusedException._ice_type = _M_Ice._t_ConnectionRefusedException _M_Ice.ConnectionRefusedException = ConnectionRefusedException @@ -829,10 +923,12 @@ def __str__(self): if 'ConnectionLostException' not in _M_Ice.__dict__: _M_Ice.ConnectionLostException = Ice.createTempClass() + class ConnectionLostException(_M_Ice.SocketException): """ This exception indicates a lost connection. """ + def __init__(self, error=0): _M_Ice.SocketException.__init__(self, error) @@ -843,7 +939,8 @@ def __str__(self): _ice_id = '::Ice::ConnectionLostException' - _M_Ice._t_ConnectionLostException = IcePy.defineException('::Ice::ConnectionLostException', ConnectionLostException, (), False, _M_Ice._t_SocketException, ()) + _M_Ice._t_ConnectionLostException = IcePy.defineException( + '::Ice::ConnectionLostException', ConnectionLostException, (), False, _M_Ice._t_SocketException, ()) ConnectionLostException._ice_type = _M_Ice._t_ConnectionLostException _M_Ice.ConnectionLostException = ConnectionLostException @@ -851,6 +948,7 @@ def __str__(self): if 'DNSException' not in _M_Ice.__dict__: _M_Ice.DNSException = Ice.createTempClass() + class DNSException(Ice.LocalException): """ This exception indicates a DNS problem. For details on the cause, DNSException#error should be inspected. @@ -859,6 +957,7 @@ class DNSException(Ice.LocalException): C++ and Windows, this is the value returned by WSAGetLastError(). host -- The host name that could not be resolved. """ + def __init__(self, error=0, host=''): self.error = error self.host = host @@ -881,10 +980,12 @@ def __str__(self): if 'OperationInterruptedException' not in _M_Ice.__dict__: _M_Ice.OperationInterruptedException = Ice.createTempClass() + class OperationInterruptedException(Ice.LocalException): """ This exception indicates a request was interrupted. """ + def __init__(self): pass @@ -895,7 +996,8 @@ def __str__(self): _ice_id = '::Ice::OperationInterruptedException' - _M_Ice._t_OperationInterruptedException = IcePy.defineException('::Ice::OperationInterruptedException', OperationInterruptedException, (), False, None, ()) + _M_Ice._t_OperationInterruptedException = IcePy.defineException( + '::Ice::OperationInterruptedException', OperationInterruptedException, (), False, None, ()) OperationInterruptedException._ice_type = _M_Ice._t_OperationInterruptedException _M_Ice.OperationInterruptedException = OperationInterruptedException @@ -903,10 +1005,12 @@ def __str__(self): if 'TimeoutException' not in _M_Ice.__dict__: _M_Ice.TimeoutException = Ice.createTempClass() + class TimeoutException(Ice.LocalException): """ This exception indicates a timeout condition. """ + def __init__(self): pass @@ -925,10 +1029,12 @@ def __str__(self): if 'ConnectTimeoutException' not in _M_Ice.__dict__: _M_Ice.ConnectTimeoutException = Ice.createTempClass() + class ConnectTimeoutException(_M_Ice.TimeoutException): """ This exception indicates a connection establishment timeout condition. """ + def __init__(self): _M_Ice.TimeoutException.__init__(self) @@ -939,7 +1045,8 @@ def __str__(self): _ice_id = '::Ice::ConnectTimeoutException' - _M_Ice._t_ConnectTimeoutException = IcePy.defineException('::Ice::ConnectTimeoutException', ConnectTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) + _M_Ice._t_ConnectTimeoutException = IcePy.defineException( + '::Ice::ConnectTimeoutException', ConnectTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) ConnectTimeoutException._ice_type = _M_Ice._t_ConnectTimeoutException _M_Ice.ConnectTimeoutException = ConnectTimeoutException @@ -947,10 +1054,12 @@ def __str__(self): if 'CloseTimeoutException' not in _M_Ice.__dict__: _M_Ice.CloseTimeoutException = Ice.createTempClass() + class CloseTimeoutException(_M_Ice.TimeoutException): """ This exception indicates a connection closure timeout condition. """ + def __init__(self): _M_Ice.TimeoutException.__init__(self) @@ -961,7 +1070,8 @@ def __str__(self): _ice_id = '::Ice::CloseTimeoutException' - _M_Ice._t_CloseTimeoutException = IcePy.defineException('::Ice::CloseTimeoutException', CloseTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) + _M_Ice._t_CloseTimeoutException = IcePy.defineException( + '::Ice::CloseTimeoutException', CloseTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) CloseTimeoutException._ice_type = _M_Ice._t_CloseTimeoutException _M_Ice.CloseTimeoutException = CloseTimeoutException @@ -969,10 +1079,12 @@ def __str__(self): if 'ConnectionTimeoutException' not in _M_Ice.__dict__: _M_Ice.ConnectionTimeoutException = Ice.createTempClass() + class ConnectionTimeoutException(_M_Ice.TimeoutException): """ This exception indicates that a connection has been shut down because it has been idle for some time. """ + def __init__(self): _M_Ice.TimeoutException.__init__(self) @@ -983,7 +1095,8 @@ def __str__(self): _ice_id = '::Ice::ConnectionTimeoutException' - _M_Ice._t_ConnectionTimeoutException = IcePy.defineException('::Ice::ConnectionTimeoutException', ConnectionTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) + _M_Ice._t_ConnectionTimeoutException = IcePy.defineException( + '::Ice::ConnectionTimeoutException', ConnectionTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) ConnectionTimeoutException._ice_type = _M_Ice._t_ConnectionTimeoutException _M_Ice.ConnectionTimeoutException = ConnectionTimeoutException @@ -991,10 +1104,12 @@ def __str__(self): if 'InvocationTimeoutException' not in _M_Ice.__dict__: _M_Ice.InvocationTimeoutException = Ice.createTempClass() + class InvocationTimeoutException(_M_Ice.TimeoutException): """ This exception indicates that an invocation failed because it timed out. """ + def __init__(self): _M_Ice.TimeoutException.__init__(self) @@ -1005,7 +1120,8 @@ def __str__(self): _ice_id = '::Ice::InvocationTimeoutException' - _M_Ice._t_InvocationTimeoutException = IcePy.defineException('::Ice::InvocationTimeoutException', InvocationTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) + _M_Ice._t_InvocationTimeoutException = IcePy.defineException( + '::Ice::InvocationTimeoutException', InvocationTimeoutException, (), False, _M_Ice._t_TimeoutException, ()) InvocationTimeoutException._ice_type = _M_Ice._t_InvocationTimeoutException _M_Ice.InvocationTimeoutException = InvocationTimeoutException @@ -1013,10 +1129,12 @@ def __str__(self): if 'InvocationCanceledException' not in _M_Ice.__dict__: _M_Ice.InvocationCanceledException = Ice.createTempClass() + class InvocationCanceledException(Ice.LocalException): """ This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. """ + def __init__(self): pass @@ -1027,7 +1145,8 @@ def __str__(self): _ice_id = '::Ice::InvocationCanceledException' - _M_Ice._t_InvocationCanceledException = IcePy.defineException('::Ice::InvocationCanceledException', InvocationCanceledException, (), False, None, ()) + _M_Ice._t_InvocationCanceledException = IcePy.defineException( + '::Ice::InvocationCanceledException', InvocationCanceledException, (), False, None, ()) InvocationCanceledException._ice_type = _M_Ice._t_InvocationCanceledException _M_Ice.InvocationCanceledException = InvocationCanceledException @@ -1035,12 +1154,14 @@ def __str__(self): if 'ProtocolException' not in _M_Ice.__dict__: _M_Ice.ProtocolException = Ice.createTempClass() + class ProtocolException(Ice.LocalException): """ A generic exception base for all kinds of protocol error conditions. Members: reason -- The reason for the failure. """ + def __init__(self, reason=''): self.reason = reason @@ -1051,7 +1172,8 @@ def __str__(self): _ice_id = '::Ice::ProtocolException' - _M_Ice._t_ProtocolException = IcePy.defineException('::Ice::ProtocolException', ProtocolException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_Ice._t_ProtocolException = IcePy.defineException( + '::Ice::ProtocolException', ProtocolException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) ProtocolException._ice_type = _M_Ice._t_ProtocolException _M_Ice.ProtocolException = ProtocolException @@ -1059,12 +1181,14 @@ def __str__(self): if 'BadMagicException' not in _M_Ice.__dict__: _M_Ice.BadMagicException = Ice.createTempClass() + class BadMagicException(_M_Ice.ProtocolException): """ This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). Members: badMagic -- A sequence containing the first four bytes of the incorrect message. """ + def __init__(self, reason='', badMagic=None): _M_Ice.ProtocolException.__init__(self, reason) self.badMagic = badMagic @@ -1076,7 +1200,8 @@ def __str__(self): _ice_id = '::Ice::BadMagicException' - _M_Ice._t_BadMagicException = IcePy.defineException('::Ice::BadMagicException', BadMagicException, (), False, _M_Ice._t_ProtocolException, (('badMagic', (), _M_Ice._t_ByteSeq, False, 0),)) + _M_Ice._t_BadMagicException = IcePy.defineException( + '::Ice::BadMagicException', BadMagicException, (), False, _M_Ice._t_ProtocolException, (('badMagic', (), _M_Ice._t_ByteSeq, False, 0),)) BadMagicException._ice_type = _M_Ice._t_BadMagicException _M_Ice.BadMagicException = BadMagicException @@ -1084,6 +1209,7 @@ def __str__(self): if 'UnsupportedProtocolException' not in _M_Ice.__dict__: _M_Ice.UnsupportedProtocolException = Ice.createTempClass() + class UnsupportedProtocolException(_M_Ice.ProtocolException): """ This exception indicates an unsupported protocol version. @@ -1091,6 +1217,7 @@ class UnsupportedProtocolException(_M_Ice.ProtocolException): bad -- The version of the unsupported protocol. supported -- The version of the protocol that is supported. """ + def __init__(self, reason='', bad=Ice._struct_marker, supported=Ice._struct_marker): _M_Ice.ProtocolException.__init__(self, reason) if bad is Ice._struct_marker: @@ -1120,6 +1247,7 @@ def __str__(self): if 'UnsupportedEncodingException' not in _M_Ice.__dict__: _M_Ice.UnsupportedEncodingException = Ice.createTempClass() + class UnsupportedEncodingException(_M_Ice.ProtocolException): """ This exception indicates an unsupported data encoding version. @@ -1127,6 +1255,7 @@ class UnsupportedEncodingException(_M_Ice.ProtocolException): bad -- The version of the unsupported encoding. supported -- The version of the encoding that is supported. """ + def __init__(self, reason='', bad=Ice._struct_marker, supported=Ice._struct_marker): _M_Ice.ProtocolException.__init__(self, reason) if bad is Ice._struct_marker: @@ -1156,10 +1285,12 @@ def __str__(self): if 'UnknownMessageException' not in _M_Ice.__dict__: _M_Ice.UnknownMessageException = Ice.createTempClass() + class UnknownMessageException(_M_Ice.ProtocolException): """ This exception indicates that an unknown protocol message has been received. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1170,7 +1301,8 @@ def __str__(self): _ice_id = '::Ice::UnknownMessageException' - _M_Ice._t_UnknownMessageException = IcePy.defineException('::Ice::UnknownMessageException', UnknownMessageException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_UnknownMessageException = IcePy.defineException( + '::Ice::UnknownMessageException', UnknownMessageException, (), False, _M_Ice._t_ProtocolException, ()) UnknownMessageException._ice_type = _M_Ice._t_UnknownMessageException _M_Ice.UnknownMessageException = UnknownMessageException @@ -1178,10 +1310,12 @@ def __str__(self): if 'ConnectionNotValidatedException' not in _M_Ice.__dict__: _M_Ice.ConnectionNotValidatedException = Ice.createTempClass() + class ConnectionNotValidatedException(_M_Ice.ProtocolException): """ This exception is raised if a message is received over a connection that is not yet validated. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1192,7 +1326,8 @@ def __str__(self): _ice_id = '::Ice::ConnectionNotValidatedException' - _M_Ice._t_ConnectionNotValidatedException = IcePy.defineException('::Ice::ConnectionNotValidatedException', ConnectionNotValidatedException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_ConnectionNotValidatedException = IcePy.defineException( + '::Ice::ConnectionNotValidatedException', ConnectionNotValidatedException, (), False, _M_Ice._t_ProtocolException, ()) ConnectionNotValidatedException._ice_type = _M_Ice._t_ConnectionNotValidatedException _M_Ice.ConnectionNotValidatedException = ConnectionNotValidatedException @@ -1200,10 +1335,12 @@ def __str__(self): if 'UnknownRequestIdException' not in _M_Ice.__dict__: _M_Ice.UnknownRequestIdException = Ice.createTempClass() + class UnknownRequestIdException(_M_Ice.ProtocolException): """ This exception indicates that a response for an unknown request ID has been received. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1214,7 +1351,8 @@ def __str__(self): _ice_id = '::Ice::UnknownRequestIdException' - _M_Ice._t_UnknownRequestIdException = IcePy.defineException('::Ice::UnknownRequestIdException', UnknownRequestIdException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_UnknownRequestIdException = IcePy.defineException( + '::Ice::UnknownRequestIdException', UnknownRequestIdException, (), False, _M_Ice._t_ProtocolException, ()) UnknownRequestIdException._ice_type = _M_Ice._t_UnknownRequestIdException _M_Ice.UnknownRequestIdException = UnknownRequestIdException @@ -1222,10 +1360,12 @@ def __str__(self): if 'UnknownReplyStatusException' not in _M_Ice.__dict__: _M_Ice.UnknownReplyStatusException = Ice.createTempClass() + class UnknownReplyStatusException(_M_Ice.ProtocolException): """ This exception indicates that an unknown reply status has been received. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1236,7 +1376,8 @@ def __str__(self): _ice_id = '::Ice::UnknownReplyStatusException' - _M_Ice._t_UnknownReplyStatusException = IcePy.defineException('::Ice::UnknownReplyStatusException', UnknownReplyStatusException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_UnknownReplyStatusException = IcePy.defineException( + '::Ice::UnknownReplyStatusException', UnknownReplyStatusException, (), False, _M_Ice._t_ProtocolException, ()) UnknownReplyStatusException._ice_type = _M_Ice._t_UnknownReplyStatusException _M_Ice.UnknownReplyStatusException = UnknownReplyStatusException @@ -1244,6 +1385,7 @@ def __str__(self): if 'CloseConnectionException' not in _M_Ice.__dict__: _M_Ice.CloseConnectionException = Ice.createTempClass() + class CloseConnectionException(_M_Ice.ProtocolException): """ This exception indicates that the connection has been gracefully shut down by the server. The operation call that @@ -1252,6 +1394,7 @@ class CloseConnectionException(_M_Ice.ProtocolException): upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is propagated to the application code. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1262,7 +1405,8 @@ def __str__(self): _ice_id = '::Ice::CloseConnectionException' - _M_Ice._t_CloseConnectionException = IcePy.defineException('::Ice::CloseConnectionException', CloseConnectionException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_CloseConnectionException = IcePy.defineException( + '::Ice::CloseConnectionException', CloseConnectionException, (), False, _M_Ice._t_ProtocolException, ()) CloseConnectionException._ice_type = _M_Ice._t_CloseConnectionException _M_Ice.CloseConnectionException = CloseConnectionException @@ -1270,6 +1414,7 @@ def __str__(self): if 'ConnectionManuallyClosedException' not in _M_Ice.__dict__: _M_Ice.ConnectionManuallyClosedException = Ice.createTempClass() + class ConnectionManuallyClosedException(Ice.LocalException): """ This exception is raised by an operation call if the application closes the connection locally using @@ -1277,6 +1422,7 @@ class ConnectionManuallyClosedException(Ice.LocalException): Members: graceful -- True if the connection was closed gracefully, false otherwise. """ + def __init__(self, graceful=False): self.graceful = graceful @@ -1287,7 +1433,8 @@ def __str__(self): _ice_id = '::Ice::ConnectionManuallyClosedException' - _M_Ice._t_ConnectionManuallyClosedException = IcePy.defineException('::Ice::ConnectionManuallyClosedException', ConnectionManuallyClosedException, (), False, None, (('graceful', (), IcePy._t_bool, False, 0),)) + _M_Ice._t_ConnectionManuallyClosedException = IcePy.defineException( + '::Ice::ConnectionManuallyClosedException', ConnectionManuallyClosedException, (), False, None, (('graceful', (), IcePy._t_bool, False, 0),)) ConnectionManuallyClosedException._ice_type = _M_Ice._t_ConnectionManuallyClosedException _M_Ice.ConnectionManuallyClosedException = ConnectionManuallyClosedException @@ -1295,10 +1442,12 @@ def __str__(self): if 'IllegalMessageSizeException' not in _M_Ice.__dict__: _M_Ice.IllegalMessageSizeException = Ice.createTempClass() + class IllegalMessageSizeException(_M_Ice.ProtocolException): """ This exception indicates that a message size is less than the minimum required size. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1309,7 +1458,8 @@ def __str__(self): _ice_id = '::Ice::IllegalMessageSizeException' - _M_Ice._t_IllegalMessageSizeException = IcePy.defineException('::Ice::IllegalMessageSizeException', IllegalMessageSizeException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_IllegalMessageSizeException = IcePy.defineException( + '::Ice::IllegalMessageSizeException', IllegalMessageSizeException, (), False, _M_Ice._t_ProtocolException, ()) IllegalMessageSizeException._ice_type = _M_Ice._t_IllegalMessageSizeException _M_Ice.IllegalMessageSizeException = IllegalMessageSizeException @@ -1317,10 +1467,12 @@ def __str__(self): if 'CompressionException' not in _M_Ice.__dict__: _M_Ice.CompressionException = Ice.createTempClass() + class CompressionException(_M_Ice.ProtocolException): """ This exception indicates a problem with compressing or uncompressing data. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1331,7 +1483,8 @@ def __str__(self): _ice_id = '::Ice::CompressionException' - _M_Ice._t_CompressionException = IcePy.defineException('::Ice::CompressionException', CompressionException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_CompressionException = IcePy.defineException( + '::Ice::CompressionException', CompressionException, (), False, _M_Ice._t_ProtocolException, ()) CompressionException._ice_type = _M_Ice._t_CompressionException _M_Ice.CompressionException = CompressionException @@ -1339,11 +1492,13 @@ def __str__(self): if 'DatagramLimitException' not in _M_Ice.__dict__: _M_Ice.DatagramLimitException = Ice.createTempClass() + class DatagramLimitException(_M_Ice.ProtocolException): """ A datagram exceeds the configured size. This exception is raised if a datagram exceeds the configured send or receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1354,7 +1509,8 @@ def __str__(self): _ice_id = '::Ice::DatagramLimitException' - _M_Ice._t_DatagramLimitException = IcePy.defineException('::Ice::DatagramLimitException', DatagramLimitException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_DatagramLimitException = IcePy.defineException( + '::Ice::DatagramLimitException', DatagramLimitException, (), False, _M_Ice._t_ProtocolException, ()) DatagramLimitException._ice_type = _M_Ice._t_DatagramLimitException _M_Ice.DatagramLimitException = DatagramLimitException @@ -1362,10 +1518,12 @@ def __str__(self): if 'MarshalException' not in _M_Ice.__dict__: _M_Ice.MarshalException = Ice.createTempClass() + class MarshalException(_M_Ice.ProtocolException): """ This exception is raised for errors during marshaling or unmarshaling data. """ + def __init__(self, reason=''): _M_Ice.ProtocolException.__init__(self, reason) @@ -1376,7 +1534,8 @@ def __str__(self): _ice_id = '::Ice::MarshalException' - _M_Ice._t_MarshalException = IcePy.defineException('::Ice::MarshalException', MarshalException, (), False, _M_Ice._t_ProtocolException, ()) + _M_Ice._t_MarshalException = IcePy.defineException( + '::Ice::MarshalException', MarshalException, (), False, _M_Ice._t_ProtocolException, ()) MarshalException._ice_type = _M_Ice._t_MarshalException _M_Ice.MarshalException = MarshalException @@ -1384,10 +1543,12 @@ def __str__(self): if 'ProxyUnmarshalException' not in _M_Ice.__dict__: _M_Ice.ProxyUnmarshalException = Ice.createTempClass() + class ProxyUnmarshalException(_M_Ice.MarshalException): """ This exception is raised if inconsistent data is received while unmarshaling a proxy. """ + def __init__(self, reason=''): _M_Ice.MarshalException.__init__(self, reason) @@ -1398,7 +1559,8 @@ def __str__(self): _ice_id = '::Ice::ProxyUnmarshalException' - _M_Ice._t_ProxyUnmarshalException = IcePy.defineException('::Ice::ProxyUnmarshalException', ProxyUnmarshalException, (), False, _M_Ice._t_MarshalException, ()) + _M_Ice._t_ProxyUnmarshalException = IcePy.defineException( + '::Ice::ProxyUnmarshalException', ProxyUnmarshalException, (), False, _M_Ice._t_MarshalException, ()) ProxyUnmarshalException._ice_type = _M_Ice._t_ProxyUnmarshalException _M_Ice.ProxyUnmarshalException = ProxyUnmarshalException @@ -1406,10 +1568,12 @@ def __str__(self): if 'UnmarshalOutOfBoundsException' not in _M_Ice.__dict__: _M_Ice.UnmarshalOutOfBoundsException = Ice.createTempClass() + class UnmarshalOutOfBoundsException(_M_Ice.MarshalException): """ This exception is raised if an out-of-bounds condition occurs during unmarshaling. """ + def __init__(self, reason=''): _M_Ice.MarshalException.__init__(self, reason) @@ -1420,7 +1584,8 @@ def __str__(self): _ice_id = '::Ice::UnmarshalOutOfBoundsException' - _M_Ice._t_UnmarshalOutOfBoundsException = IcePy.defineException('::Ice::UnmarshalOutOfBoundsException', UnmarshalOutOfBoundsException, (), False, _M_Ice._t_MarshalException, ()) + _M_Ice._t_UnmarshalOutOfBoundsException = IcePy.defineException( + '::Ice::UnmarshalOutOfBoundsException', UnmarshalOutOfBoundsException, (), False, _M_Ice._t_MarshalException, ()) UnmarshalOutOfBoundsException._ice_type = _M_Ice._t_UnmarshalOutOfBoundsException _M_Ice.UnmarshalOutOfBoundsException = UnmarshalOutOfBoundsException @@ -1428,12 +1593,14 @@ def __str__(self): if 'NoValueFactoryException' not in _M_Ice.__dict__: _M_Ice.NoValueFactoryException = Ice.createTempClass() + class NoValueFactoryException(_M_Ice.MarshalException): """ This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. Members: type -- The Slice type ID of the class instance for which no factory could be found. """ + def __init__(self, reason='', type=''): _M_Ice.MarshalException.__init__(self, reason) self.type = type @@ -1445,7 +1612,8 @@ def __str__(self): _ice_id = '::Ice::NoValueFactoryException' - _M_Ice._t_NoValueFactoryException = IcePy.defineException('::Ice::NoValueFactoryException', NoValueFactoryException, (), False, _M_Ice._t_MarshalException, (('type', (), IcePy._t_string, False, 0),)) + _M_Ice._t_NoValueFactoryException = IcePy.defineException( + '::Ice::NoValueFactoryException', NoValueFactoryException, (), False, _M_Ice._t_MarshalException, (('type', (), IcePy._t_string, False, 0),)) NoValueFactoryException._ice_type = _M_Ice._t_NoValueFactoryException _M_Ice.NoValueFactoryException = NoValueFactoryException @@ -1453,6 +1621,7 @@ def __str__(self): if 'UnexpectedObjectException' not in _M_Ice.__dict__: _M_Ice.UnexpectedObjectException = Ice.createTempClass() + class UnexpectedObjectException(_M_Ice.MarshalException): """ This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. This @@ -1463,6 +1632,7 @@ class UnexpectedObjectException(_M_Ice.MarshalException): type -- The Slice type ID of the class instance that was unmarshaled. expectedType -- The Slice type ID that was expected by the receiving operation. """ + def __init__(self, reason='', type='', expectedType=''): _M_Ice.MarshalException.__init__(self, reason) self.type = type @@ -1486,11 +1656,13 @@ def __str__(self): if 'MemoryLimitException' not in _M_Ice.__dict__: _M_Ice.MemoryLimitException = Ice.createTempClass() + class MemoryLimitException(_M_Ice.MarshalException): """ This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the Ice.MessageSizeMax property. """ + def __init__(self, reason=''): _M_Ice.MarshalException.__init__(self, reason) @@ -1501,7 +1673,8 @@ def __str__(self): _ice_id = '::Ice::MemoryLimitException' - _M_Ice._t_MemoryLimitException = IcePy.defineException('::Ice::MemoryLimitException', MemoryLimitException, (), False, _M_Ice._t_MarshalException, ()) + _M_Ice._t_MemoryLimitException = IcePy.defineException( + '::Ice::MemoryLimitException', MemoryLimitException, (), False, _M_Ice._t_MarshalException, ()) MemoryLimitException._ice_type = _M_Ice._t_MemoryLimitException _M_Ice.MemoryLimitException = MemoryLimitException @@ -1509,10 +1682,12 @@ def __str__(self): if 'StringConversionException' not in _M_Ice.__dict__: _M_Ice.StringConversionException = Ice.createTempClass() + class StringConversionException(_M_Ice.MarshalException): """ This exception is raised when a string conversion to or from UTF-8 fails during marshaling or unmarshaling. """ + def __init__(self, reason=''): _M_Ice.MarshalException.__init__(self, reason) @@ -1523,7 +1698,8 @@ def __str__(self): _ice_id = '::Ice::StringConversionException' - _M_Ice._t_StringConversionException = IcePy.defineException('::Ice::StringConversionException', StringConversionException, (), False, _M_Ice._t_MarshalException, ()) + _M_Ice._t_StringConversionException = IcePy.defineException( + '::Ice::StringConversionException', StringConversionException, (), False, _M_Ice._t_MarshalException, ()) StringConversionException._ice_type = _M_Ice._t_StringConversionException _M_Ice.StringConversionException = StringConversionException @@ -1531,10 +1707,12 @@ def __str__(self): if 'EncapsulationException' not in _M_Ice.__dict__: _M_Ice.EncapsulationException = Ice.createTempClass() + class EncapsulationException(_M_Ice.MarshalException): """ This exception indicates a malformed data encapsulation. """ + def __init__(self, reason=''): _M_Ice.MarshalException.__init__(self, reason) @@ -1545,7 +1723,8 @@ def __str__(self): _ice_id = '::Ice::EncapsulationException' - _M_Ice._t_EncapsulationException = IcePy.defineException('::Ice::EncapsulationException', EncapsulationException, (), False, _M_Ice._t_MarshalException, ()) + _M_Ice._t_EncapsulationException = IcePy.defineException( + '::Ice::EncapsulationException', EncapsulationException, (), False, _M_Ice._t_MarshalException, ()) EncapsulationException._ice_type = _M_Ice._t_EncapsulationException _M_Ice.EncapsulationException = EncapsulationException @@ -1553,6 +1732,7 @@ def __str__(self): if 'FeatureNotSupportedException' not in _M_Ice.__dict__: _M_Ice.FeatureNotSupportedException = Ice.createTempClass() + class FeatureNotSupportedException(Ice.LocalException): """ This exception is raised if an unsupported feature is used. The unsupported feature string contains the name of the @@ -1560,6 +1740,7 @@ class FeatureNotSupportedException(Ice.LocalException): Members: unsupportedFeature -- The name of the unsupported feature. """ + def __init__(self, unsupportedFeature=''): self.unsupportedFeature = unsupportedFeature @@ -1570,7 +1751,8 @@ def __str__(self): _ice_id = '::Ice::FeatureNotSupportedException' - _M_Ice._t_FeatureNotSupportedException = IcePy.defineException('::Ice::FeatureNotSupportedException', FeatureNotSupportedException, (), False, None, (('unsupportedFeature', (), IcePy._t_string, False, 0),)) + _M_Ice._t_FeatureNotSupportedException = IcePy.defineException( + '::Ice::FeatureNotSupportedException', FeatureNotSupportedException, (), False, None, (('unsupportedFeature', (), IcePy._t_string, False, 0),)) FeatureNotSupportedException._ice_type = _M_Ice._t_FeatureNotSupportedException _M_Ice.FeatureNotSupportedException = FeatureNotSupportedException @@ -1578,12 +1760,14 @@ def __str__(self): if 'SecurityException' not in _M_Ice.__dict__: _M_Ice.SecurityException = Ice.createTempClass() + class SecurityException(Ice.LocalException): """ This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. Members: reason -- The reason for the failure. """ + def __init__(self, reason=''): self.reason = reason @@ -1594,7 +1778,8 @@ def __str__(self): _ice_id = '::Ice::SecurityException' - _M_Ice._t_SecurityException = IcePy.defineException('::Ice::SecurityException', SecurityException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_Ice._t_SecurityException = IcePy.defineException( + '::Ice::SecurityException', SecurityException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) SecurityException._ice_type = _M_Ice._t_SecurityException _M_Ice.SecurityException = SecurityException @@ -1602,10 +1787,12 @@ def __str__(self): if 'FixedProxyException' not in _M_Ice.__dict__: _M_Ice.FixedProxyException = Ice.createTempClass() + class FixedProxyException(Ice.LocalException): """ This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. """ + def __init__(self): pass @@ -1616,7 +1803,8 @@ def __str__(self): _ice_id = '::Ice::FixedProxyException' - _M_Ice._t_FixedProxyException = IcePy.defineException('::Ice::FixedProxyException', FixedProxyException, (), False, None, ()) + _M_Ice._t_FixedProxyException = IcePy.defineException( + '::Ice::FixedProxyException', FixedProxyException, (), False, None, ()) FixedProxyException._ice_type = _M_Ice._t_FixedProxyException _M_Ice.FixedProxyException = FixedProxyException @@ -1624,10 +1812,12 @@ def __str__(self): if 'ResponseSentException' not in _M_Ice.__dict__: _M_Ice.ResponseSentException = Ice.createTempClass() + class ResponseSentException(Ice.LocalException): """ Indicates that the response to a request has already been sent; re-dispatching such a request is not possible. """ + def __init__(self): pass @@ -1638,7 +1828,8 @@ def __str__(self): _ice_id = '::Ice::ResponseSentException' - _M_Ice._t_ResponseSentException = IcePy.defineException('::Ice::ResponseSentException', ResponseSentException, (), False, None, ()) + _M_Ice._t_ResponseSentException = IcePy.defineException( + '::Ice::ResponseSentException', ResponseSentException, (), False, None, ()) ResponseSentException._ice_type = _M_Ice._t_ResponseSentException _M_Ice.ResponseSentException = ResponseSentException diff --git a/python/python/Ice/LoggerF_local.py b/python/python/Ice/LoggerF_local.py index fe5ad03f137..baeff98b517 100644 --- a/python/python/Ice/LoggerF_local.py +++ b/python/python/Ice/LoggerF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Logger_local.py b/python/python/Ice/Logger_local.py index 554d71735c4..39e09d1f135 100644 --- a/python/python/Ice/Logger_local.py +++ b/python/python/Ice/Logger_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') @@ -22,11 +23,13 @@ if 'Logger' not in _M_Ice.__dict__: _M_Ice.Logger = Ice.createTempClass() + class Logger(object): """ The Ice message logger. Applications can provide their own logger by implementing this interface and installing it in a communicator. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Logger: raise RuntimeError('Ice.Logger is an abstract class') diff --git a/python/python/Ice/ObjectAdapterF_local.py b/python/python/Ice/ObjectAdapterF_local.py index 2a94fecb33d..a6604c74d0d 100644 --- a/python/python/Ice/ObjectAdapterF_local.py +++ b/python/python/Ice/ObjectAdapterF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/ObjectAdapter_local.py b/python/python/Ice/ObjectAdapter_local.py index 6c6a7a0b7d0..85444741613 100644 --- a/python/python/Ice/ObjectAdapter_local.py +++ b/python/python/Ice/ObjectAdapter_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.CommunicatorF_local import Ice.ServantLocatorF_local import Ice.Locator_ice @@ -29,12 +30,14 @@ if 'ObjectAdapter' not in _M_Ice.__dict__: _M_Ice.ObjectAdapter = Ice.createTempClass() + class ObjectAdapter(object): """ The object adapter provides an up-call interface from the Ice run time to the implementation of Ice objects. The object adapter is responsible for receiving requests from endpoints, and for mapping between servants, identities, and proxies. """ + def __init__(self): if Ice.getType(self) == _M_Ice.ObjectAdapter: raise RuntimeError('Ice.ObjectAdapter is an abstract class') diff --git a/python/python/Ice/PluginF_local.py b/python/python/Ice/PluginF_local.py index b15979baf8b..c68aa8a230d 100644 --- a/python/python/Ice/PluginF_local.py +++ b/python/python/Ice/PluginF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Plugin_local.py b/python/python/Ice/Plugin_local.py index a1c1e97ec43..850a818e8a5 100644 --- a/python/python/Ice/Plugin_local.py +++ b/python/python/Ice/Plugin_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.LoggerF_local import Ice.BuiltinSequences_ice @@ -26,12 +27,14 @@ if 'Plugin' not in _M_Ice.__dict__: _M_Ice.Plugin = Ice.createTempClass() + class Plugin(object): """ A communicator plug-in. A plug-in generally adds a feature to a communicator, such as support for a protocol. The communicator loads its plug-ins in two stages: the first stage creates the plug-ins, and the second stage invokes Plugin#initialize on each one. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Plugin: raise RuntimeError('Ice.Plugin is an abstract class') @@ -61,10 +64,12 @@ def __str__(self): if 'PluginManager' not in _M_Ice.__dict__: _M_Ice.PluginManager = Ice.createTempClass() + class PluginManager(object): """ Each communicator has a plug-in manager to administer the set of plug-ins. """ + def __init__(self): if Ice.getType(self) == _M_Ice.PluginManager: raise RuntimeError('Ice.PluginManager is an abstract class') diff --git a/python/python/Ice/PropertiesF_local.py b/python/python/Ice/PropertiesF_local.py index 38ed7dc7ada..f309ed89038 100644 --- a/python/python/Ice/PropertiesF_local.py +++ b/python/python/Ice/PropertiesF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/Properties_local.py b/python/python/Ice/Properties_local.py index 2095302d058..2a0c709e482 100644 --- a/python/python/Ice/Properties_local.py +++ b/python/python/Ice/Properties_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.BuiltinSequences_ice import Ice.PropertyDict_ice @@ -26,12 +27,14 @@ if 'Properties' not in _M_Ice.__dict__: _M_Ice.Properties = Ice.createTempClass() + class Properties(object): """ A property set used to configure Ice and Ice applications. Properties are key/value pairs, with both keys and values being strings. By convention, property keys should have the form application-name[.category[.sub-category]].name. """ + def __init__(self): if Ice.getType(self) == _M_Ice.Properties: raise RuntimeError('Ice.Properties is an abstract class') diff --git a/python/python/Ice/ServantLocatorF_local.py b/python/python/Ice/ServantLocatorF_local.py index 5edf8599104..2ccffacf5d3 100644 --- a/python/python/Ice/ServantLocatorF_local.py +++ b/python/python/Ice/ServantLocatorF_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') diff --git a/python/python/Ice/ServantLocator_local.py b/python/python/Ice/ServantLocator_local.py index 99cdf6dc4e4..31ad8bf4581 100644 --- a/python/python/Ice/ServantLocator_local.py +++ b/python/python/Ice/ServantLocator_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.ObjectAdapterF_local import Ice.Current_local @@ -26,10 +27,12 @@ if 'ServantLocator' not in _M_Ice.__dict__: _M_Ice.ServantLocator = Ice.createTempClass() + class ServantLocator(object): """ A servant locator is called by an object adapter to locate a servant that is not found in its active servant map. """ + def __init__(self): if Ice.getType(self) == _M_Ice.ServantLocator: raise RuntimeError('Ice.ServantLocator is an abstract class') diff --git a/python/python/Ice/ValueFactory_local.py b/python/python/Ice/ValueFactory_local.py index 211c2f7a859..b030bb61754 100644 --- a/python/python/Ice/ValueFactory_local.py +++ b/python/python/Ice/ValueFactory_local.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy # Start of module Ice _M_Ice = Ice.openModule('Ice') @@ -22,12 +23,14 @@ if 'ValueFactory' not in _M_Ice.__dict__: _M_Ice.ValueFactory = Ice.createTempClass() + class ValueFactory(object): """ A factory for values. Value factories are used in several places, such as when Ice receives a class instance and when Freeze restores a persistent value. Value factories must be implemented by the application writer and registered with the communicator. """ + def __init__(self): if Ice.getType(self) == _M_Ice.ValueFactory: raise RuntimeError('Ice.ValueFactory is an abstract class') @@ -57,11 +60,13 @@ def __str__(self): if 'ValueFactoryManager' not in _M_Ice.__dict__: _M_Ice.ValueFactoryManager = Ice.createTempClass() + class ValueFactoryManager(object): """ A value factory manager maintains a collection of value factories. An application can supply a custom implementation during communicator initialization, otherwise Ice provides a default implementation. """ + def __init__(self): if Ice.getType(self) == _M_Ice.ValueFactoryManager: raise RuntimeError('Ice.ValueFactoryManager is an abstract class') @@ -104,7 +109,8 @@ def __str__(self): __repr__ = __str__ - _M_Ice._t_ValueFactoryManager = IcePy.defineValue('::Ice::ValueFactoryManager', ValueFactoryManager, -1, (), False, True, None, ()) + _M_Ice._t_ValueFactoryManager = IcePy.defineValue( + '::Ice::ValueFactoryManager', ValueFactoryManager, -1, (), False, True, None, ()) ValueFactoryManager._ice_type = _M_Ice._t_ValueFactoryManager _M_Ice.ValueFactoryManager = ValueFactoryManager diff --git a/python/python/Ice/__init__.py b/python/python/Ice/__init__.py index 600b2c48994..192a1d89e94 100644 --- a/python/python/Ice/__init__.py +++ b/python/python/Ice/__init__.py @@ -6,7 +6,18 @@ Ice module """ -import sys, string, os, threading, warnings, datetime, logging, time, inspect, traceback, types, array +import sys +import string +import os +import threading +import warnings +import datetime +import logging +import time +import inspect +import traceback +import types +import array # # RTTI problems can occur in C++ code unless we modify Python's dlopen flags. @@ -20,7 +31,7 @@ try: import dl - sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) + sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) except ImportError: # # If the dl module is not available and we're running on a Linux @@ -201,12 +212,13 @@ def _warn(self, msg): StateCancelled = 'cancelled' StateDone = 'done' + class InvocationFuture(Future): def __init__(self, operation, asyncResult): Future.__init__(self) - assert(asyncResult) + assert (asyncResult) self._operation = operation - self._asyncResult = asyncResult # May be None for a batch invocation. + self._asyncResult = asyncResult # May be None for a batch invocation. self._sent = False self._sentSynchronously = False self._sentCallbacks = [] @@ -305,6 +317,7 @@ def _warn(self, msg): else: logging.getLogger("Ice.Future").exception(msg) + # # This value is used as the default value for struct types in the constructors # of user-defined types. It allows us to determine whether the application has @@ -315,6 +328,8 @@ def _warn(self, msg): # # Core Ice types. # + + class Value(object): def ice_id(self): @@ -336,10 +351,10 @@ def ice_staticId(): # # Do not define these here. They will be invoked if defined by a subclass. # - #def ice_preMarshal(self): + # def ice_preMarshal(self): # pass # - #def ice_postUnmarshal(self): + # def ice_postUnmarshal(self): # pass def ice_getSlicedData(self): @@ -348,7 +363,8 @@ def ice_getSlicedData(self): Returns: The sliced data or null. ''' - return getattr(self, "_ice_slicedData", None); + return getattr(self, "_ice_slicedData", None) + class InterfaceByValue(Value): @@ -358,6 +374,7 @@ def __init__(self, id): def ice_id(self): return self.id + class Object(object): def ice_isA(self, id, current=None): @@ -380,7 +397,7 @@ def ice_ids(self, current=None): Returns: A list of type ids. ''' - return [ self.ice_id(current) ] + return [self.ice_id(current)] def ice_id(self, current=None): '''Obtains the type id corresponding to the most-derived Slice @@ -442,6 +459,7 @@ def handler(future): except: cb.exception(sys.exc_info()[1]) + class Blobject(Object): '''Special-purpose servant base class that allows a subclass to handle synchronous Ice invocations as "blobs" of bytes.''' @@ -457,6 +475,7 @@ def ice_invoke(self, bytes, current): ''' pass + class BlobjectAsync(Object): '''Special-purpose servant base class that allows a subclass to handle asynchronous Ice invocations as "blobs" of bytes.''' @@ -476,8 +495,11 @@ def ice_invoke(self, bytes, current): # # Exceptions. # + + class Exception(Exception): # Derives from built-in base 'Exception' class. '''The base class for all Ice exceptions.''' + def __str__(self): return self.__class__.__name__ @@ -489,11 +511,14 @@ def ice_id(self): '''Returns the type id of this exception.''' return self._ice_id + class LocalException(Exception): '''The base class for all Ice run-time exceptions.''' + def __init__(self, args=''): self.args = args + class UserException(Exception): '''The base class for all user-defined exceptions.''' @@ -503,7 +528,8 @@ def ice_getSlicedData(self): Returns: The sliced data or null. ''' - return getattr(self, "_ice_slicedData", None); + return getattr(self, "_ice_slicedData", None) + class EnumBase(object): def __init__(self, _n, _v): @@ -548,7 +574,7 @@ def __ne__(self, other): def __gt__(self, other): if isinstance(other, self.__class__): - return self._value > other._value; + return self._value > other._value elif other == None: return False return NotImplemented @@ -569,6 +595,7 @@ def _getValue(self): name = property(_getName) value = property(_getValue) + class SlicedData(object): # # Members: @@ -577,6 +604,7 @@ class SlicedData(object): # pass + class SliceInfo(object): # # Members: @@ -589,11 +617,13 @@ class SliceInfo(object): # isLastSlice - boolean pass + # # Native PropertiesAdmin admin facet. # NativePropertiesAdmin = IcePy.NativePropertiesAdmin + class PropertiesAdminUpdateCallback(object): '''Callback class to get notifications of property updates passed through the Properties admin facet''' @@ -601,6 +631,7 @@ class PropertiesAdminUpdateCallback(object): def updated(self, props): pass + class UnknownSlicedValue(Value): # # Members: @@ -610,6 +641,7 @@ class UnknownSlicedValue(Value): def ice_id(self): return self.unknownTypeId + def getSliceDir(): '''Convenience function for locating the directory containing the Slice files.''' @@ -655,7 +687,7 @@ def getSliceDir(): # # Check the default macOS homebrew location. # - dir = os.path.join("/", "usr", "local", "share", "ice", "slice") + dir = os.path.join("/", "usr", "local", "share", "ice", "slice") if os.path.exists(dir): return dir @@ -665,8 +697,10 @@ def getSliceDir(): # Utilities for use by generated code. # + _pendingModules = {} + def openModule(name): global _pendingModules if name in sys.modules: @@ -678,6 +712,7 @@ def openModule(name): return result + def createModule(name): global _pendingModules l = name.split(".") @@ -700,6 +735,7 @@ def createModule(name): return mod + def updateModule(name): global _pendingModules if name in _pendingModules: @@ -708,6 +744,7 @@ def updateModule(name): mod.__dict__.update(pendingModule.__dict__) del _pendingModules[name] + def updateModules(): global _pendingModules for name in _pendingModules.keys(): @@ -717,15 +754,19 @@ def updateModules(): sys.modules[name] = _pendingModules[name] _pendingModules = {} + def createTempClass(): - class __temp: pass + class __temp: + pass return __temp + class FormatType(object): def __init__(self, val): - assert(val >= 0 and val < 3) + assert (val >= 0 and val < 3) self.value = val + FormatType.DefaultFormat = FormatType(0) FormatType.CompactFormat = FormatType(1) FormatType.SlicedFormat = FormatType(2) @@ -769,17 +810,17 @@ def __init__(self, val): # Replace EndpointInfo with our implementation. # del EndpointInfo -EndpointInfo = IcePy.EndpointInfo +EndpointInfo = IcePy.EndpointInfo del IPEndpointInfo -IPEndpointInfo = IcePy.IPEndpointInfo +IPEndpointInfo = IcePy.IPEndpointInfo del TCPEndpointInfo -TCPEndpointInfo = IcePy.TCPEndpointInfo +TCPEndpointInfo = IcePy.TCPEndpointInfo del UDPEndpointInfo -UDPEndpointInfo = IcePy.UDPEndpointInfo +UDPEndpointInfo = IcePy.UDPEndpointInfo del WSEndpointInfo -WSEndpointInfo = IcePy.WSEndpointInfo +WSEndpointInfo = IcePy.WSEndpointInfo del OpaqueEndpointInfo -OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo +OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo SSLEndpointInfo = IcePy.SSLEndpointInfo @@ -787,17 +828,18 @@ def __init__(self, val): # Replace ConnectionInfo with our implementation. # del ConnectionInfo -ConnectionInfo = IcePy.ConnectionInfo +ConnectionInfo = IcePy.ConnectionInfo del IPConnectionInfo -IPConnectionInfo = IcePy.IPConnectionInfo +IPConnectionInfo = IcePy.IPConnectionInfo del TCPConnectionInfo -TCPConnectionInfo = IcePy.TCPConnectionInfo +TCPConnectionInfo = IcePy.TCPConnectionInfo del UDPConnectionInfo -UDPConnectionInfo = IcePy.UDPConnectionInfo +UDPConnectionInfo = IcePy.UDPConnectionInfo del WSConnectionInfo -WSConnectionInfo = IcePy.WSConnectionInfo +WSConnectionInfo = IcePy.WSConnectionInfo + +SSLConnectionInfo = IcePy.SSLConnectionInfo -SSLConnectionInfo = IcePy.SSLConnectionInfo class ThreadNotification(object): '''Base class for thread notification callbacks. A subclass must @@ -815,6 +857,7 @@ def stop(): to terminate.''' pass + class BatchRequestInterceptor(object): '''Base class for batch request interceptor. A subclass must define the enqueue method.''' @@ -829,6 +872,8 @@ def enqueue(self, request, queueCount, queueSize): # # Initialization data. # + + class InitializationData(object): '''The attributes of this class are used to initialize a new communicator instance. The supported attributes are as follows: @@ -854,10 +899,11 @@ class InitializationData(object): valueFactoryManager: An object that implements ValueFactoryManager. ''' + def __init__(self): self.properties = None self.logger = None - self.threadHook = None # Deprecated. + self.threadHook = None # Deprecated. self.threadStart = None self.threadStop = None self.dispatcher = None @@ -867,6 +913,8 @@ def __init__(self): # # Communicator wrapper. # + + class CommunicatorI(Communicator): def __init__(self, impl): self._impl = impl @@ -935,7 +983,7 @@ def getValueFactoryManager(self): def getImplicitContext(self): context = self._impl.getImplicitContext() if context == None: - return None; + return None else: return ImplicitContextI(context) @@ -995,6 +1043,8 @@ def removeAdminFacet(self, facet): # # Ice.initialize() # + + def initialize(args=None, data=None): '''Initializes a new communicator. The optional arguments represent an argument list (such as sys.argv) and an instance of InitializationData. @@ -1014,18 +1064,24 @@ def initialize(args=None, data=None): # # Ice.identityToString # + + def identityToString(id, toStringMode=None): return IcePy.identityToString(id, toStringMode) # # Ice.stringToIdentity # + + def stringToIdentity(str): return IcePy.stringToIdentity(str) # # ObjectAdapter wrapper. # + + class ObjectAdapterI(ObjectAdapter): def __init__(self, impl): self._impl = impl @@ -1154,6 +1210,8 @@ def setPublishedEndpoints(self, newEndpoints): # # Logger wrapper. # + + class LoggerI(Logger): def __init__(self, impl): self._impl = impl @@ -1180,6 +1238,8 @@ def cloneWithPrefix(self, prefix): # # Properties wrapper. # + + class PropertiesI(Properties): def __init__(self, impl): self._impl = impl @@ -1234,6 +1294,8 @@ def __str__(self): # # Ice.createProperties() # + + def createProperties(args=None, defaults=None): '''Creates a new property set. The optional arguments represent an argument list (such as sys.argv) and a property set that supplies @@ -1255,6 +1317,8 @@ def createProperties(args=None, defaults=None): # Ice.getProcessLogger() # Ice.setProcessLogger() # + + def getProcessLogger(): '''Returns the default logger object.''' logger = IcePy.getProcessLogger() @@ -1263,6 +1327,7 @@ def getProcessLogger(): else: return LoggerI(logger) + def setProcessLogger(logger): '''Sets the default logger object.''' IcePy.setProcessLogger(logger) @@ -1270,6 +1335,8 @@ def setProcessLogger(logger): # # ImplicitContext wrapper # + + class ImplicitContextI(ImplicitContext): def __init__(self, impl): self._impl = impl @@ -1301,6 +1368,8 @@ def remove(self, key): # Note the interface is the same as the C++ CtrlCHandler # implementation, however, the implementation is different. # + + class CtrlCHandler(threading.Thread): # Class variable referring to the one and only handler for use # from the signal handling callback. @@ -1392,6 +1461,8 @@ def signalHandler(self, sig, frame): # # Application logger. # + + class _ApplicationLoggerI(Logger): def __init__(self, prefix): if len(prefix) > 0: @@ -1428,17 +1499,20 @@ def error(self, message): sys.stderr.write(str(datetime.datetime.now()) + " " + self._prefix + "error: " + message + "\n") self._outputMutex.release() + # # Application class. # import signal + + class Application(object): '''Convenience class that initializes a communicator and reacts gracefully to signals. An application must define a subclass of this class and supply an implementation of the run method. ''' - def __init__(self, signalPolicy=0): # HandleSignals=0 + def __init__(self, signalPolicy=0): # HandleSignals=0 '''The constructor accepts an optional argument indicating whether to handle signals. The value should be either Application.HandleSignals (the default) or @@ -1596,8 +1670,8 @@ def destroyOnInterrupt(self): self._ctrlCHandler.setCallback(self._destroyOnInterruptCallback) self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") destroyOnInterrupt = classmethod(destroyOnInterrupt) def shutdownOnInterrupt(self): @@ -1611,8 +1685,8 @@ def shutdownOnInterrupt(self): self._ctrlCHandler.setCallback(self._shutdownOnInterruptCallback) self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") shutdownOnInterrupt = classmethod(shutdownOnInterrupt) def ignoreInterrupt(self): @@ -1625,8 +1699,8 @@ def ignoreInterrupt(self): self._ctrlCHandler.setCallback(None) self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") ignoreInterrupt = classmethod(ignoreInterrupt) def callbackOnInterrupt(self): @@ -1640,8 +1714,8 @@ def callbackOnInterrupt(self): self._ctrlCHandler.setCallback(self._callbackOnInterruptCallback) self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") callbackOnInterrupt = classmethod(callbackOnInterrupt) def holdInterrupt(self): @@ -1656,8 +1730,8 @@ def holdInterrupt(self): # else, we were already holding signals self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") holdInterrupt = classmethod(holdInterrupt) def releaseInterrupt(self): @@ -1677,8 +1751,8 @@ def releaseInterrupt(self): # Else nothing to release. self._condVar.release() else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") + getProcessLogger().error(Application._appName + + ": warning: interrupt method called on Application configured to not handle interrupts.") releaseInterrupt = classmethod(releaseInterrupt) def interrupted(self): @@ -1723,7 +1797,7 @@ def _destroyOnInterruptCallback(self, sig): try: self._communicator.destroy() except: - getProcessLogger().error(self._appName + " (while destroying in response to signal " + str(sig) + "):" + \ + getProcessLogger().error(self._appName + " (while destroying in response to signal " + str(sig) + "):" + traceback.format_exc()) self._condVar.acquire() @@ -1748,7 +1822,7 @@ def _shutdownOnInterruptCallback(self, sig): try: self._communicator.shutdown() except: - getProcessLogger().error(self._appName + " (while shutting down in response to signal " + str(sig) + \ + getProcessLogger().error(self._appName + " (while shutting down in response to signal " + str(sig) + "):" + traceback.format_exc()) self._condVar.acquire() @@ -1775,7 +1849,7 @@ def _callbackOnInterruptCallback(self, sig): try: self._application.interruptCallback(sig) except: - getProcessLogger().error(self._appName + " (while interrupting in response to signal " + str(sig) + \ + getProcessLogger().error(self._appName + " (while interrupting in response to signal " + str(sig) + "):" + traceback.format_exc()) self._condVar.acquire() @@ -1800,6 +1874,7 @@ def _callbackOnInterruptCallback(self, sig): _condVar = threading.Condition() _signalPolicy = HandleSignals + # # Define Ice::Value and Ice::ObjectPrx. # @@ -1808,54 +1883,78 @@ def _callbackOnInterruptCallback(self, sig): IcePy._t_ObjectPrx = IcePy.defineProxy('::Ice::Object', ObjectPrx) Object._ice_type = IcePy._t_Object -Object._op_ice_isA = IcePy.Operation('ice_isA', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (((), IcePy._t_string, False, 0),), (), ((), IcePy._t_bool, False, 0), ()) -Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), None, ()) -Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), _t_StringSeq, False, 0), ()) -Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), IcePy._t_string, False, 0), ()) +Object._op_ice_isA = IcePy.Operation('ice_isA', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (( + (), IcePy._t_string, False, 0),), (), ((), IcePy._t_bool, False, 0), ()) +Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Idempotent, + OperationMode.Nonmutating, False, None, (), (), (), None, ()) +Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Idempotent, + OperationMode.Nonmutating, False, None, (), (), (), ((), _t_StringSeq, False, 0), ()) +Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Idempotent, OperationMode.Nonmutating, + False, None, (), (), (), ((), IcePy._t_string, False, 0), ()) IcePy._t_LocalObject = IcePy.defineValue('::Ice::LocalObject', object, -1, (), False, False, None, ()) -IcePy._t_UnknownSlicedValue = IcePy.defineValue('::Ice::UnknownSlicedValue', UnknownSlicedValue, -1, (), True, False, None, ()) +IcePy._t_UnknownSlicedValue = IcePy.defineValue( + '::Ice::UnknownSlicedValue', UnknownSlicedValue, -1, (), True, False, None, ()) UnknownSlicedValue._ice_type = IcePy._t_UnknownSlicedValue # # Annotate some exceptions. # + + def SyscallException__str__(self): return "Ice.SyscallException:\n" + os.strerror(self.error) + + SyscallException.__str__ = SyscallException__str__ del SyscallException__str__ + def SocketException__str__(self): return "Ice.SocketException:\n" + os.strerror(self.error) + + SocketException.__str__ = SocketException__str__ del SocketException__str__ + def ConnectFailedException__str__(self): return "Ice.ConnectFailedException:\n" + os.strerror(self.error) + + ConnectFailedException.__str__ = ConnectFailedException__str__ del ConnectFailedException__str__ + def ConnectionRefusedException__str__(self): return "Ice.ConnectionRefusedException:\n" + os.strerror(self.error) + + ConnectionRefusedException.__str__ = ConnectionRefusedException__str__ del ConnectionRefusedException__str__ + def ConnectionLostException__str__(self): if self.error == 0: return "Ice.ConnectionLostException:\nrecv() returned zero" else: return "Ice.ConnectionLostException:\n" + os.strerror(self.error) + + ConnectionLostException.__str__ = ConnectionLostException__str__ del ConnectionLostException__str__ # # Proxy comparison functions. # + + def proxyIdentityEqual(lhs, rhs): '''Determines whether the identities of two proxies are equal.''' return proxyIdentityCompare(lhs, rhs) == 0 + def proxyIdentityCompare(lhs, rhs): '''Compares the identities of two proxies.''' if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): @@ -1871,11 +1970,13 @@ def proxyIdentityCompare(lhs, rhs): rid = rhs.ice_getIdentity() return (lid > rid) - (lid < rid) + def proxyIdentityAndFacetEqual(lhs, rhs): '''Determines whether the identities and facets of two proxies are equal.''' return proxyIdentityAndFacetCompare(lhs, rhs) == 0 + def proxyIdentityAndFacetCompare(lhs, rhs): '''Compares the identities and facets of two proxies.''' if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): @@ -1901,6 +2002,8 @@ def proxyIdentityAndFacetCompare(lhs, rhs): # names. Since the functions are in the __builtin__ module (for Python 2.x) and the # builtins module (for Python 3.x), it's easier to define them here. # + + def getType(o): return type(o) @@ -1910,9 +2013,12 @@ def getType(o): # the function is in the __builtin__ module (for Python 2.x) and the builtins # module (for Python 3.x), it's easier to define it here. # + + def getHash(o): return hash(o) + Protocol_1_0 = ProtocolVersion(1, 0) Encoding_1_0 = EncodingVersion(1, 0) Encoding_1_1 = EncodingVersion(1, 1) @@ -1929,6 +2035,7 @@ def getHash(o): BuiltinTypes = [BuiltinBool, BuiltinByte, BuiltinShort, BuiltinInt, BuiltinLong, BuiltinFloat, BuiltinDouble] BuiltinArrayTypes = ["b", "b", "h", "i", "q", "f", "d"] + def createArray(view, t, copy): if t not in BuiltinTypes: raise ValueError("`{0}' is not an array builtin type".format(t)) @@ -1936,6 +2043,7 @@ def createArray(view, t, copy): a.frombytes(view) return a + try: import numpy diff --git a/python/python/IceBox/Service.py b/python/python/IceBox/Service.py index 508d95e8e1b..ebecfdf7d9c 100644 --- a/python/python/IceBox/Service.py +++ b/python/python/IceBox/Service.py @@ -14,7 +14,8 @@ # # -import Ice, IcePy +import Ice +import IcePy import Ice.BuiltinSequences_ice import Ice.CommunicatorF_ice @@ -31,6 +32,7 @@ if 'FailureException' not in _M_IceBox.__dict__: _M_IceBox.FailureException = Ice.createTempClass() + class FailureException(Ice.LocalException): """ This exception is a general failure notification. It is thrown for errors such as a service encountering an error @@ -38,6 +40,7 @@ class FailureException(Ice.LocalException): Members: reason -- The reason for the failure. """ + def __init__(self, reason=''): self.reason = reason @@ -48,7 +51,8 @@ def __str__(self): _ice_id = '::IceBox::FailureException' - _M_IceBox._t_FailureException = IcePy.defineException('::IceBox::FailureException', FailureException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) + _M_IceBox._t_FailureException = IcePy.defineException( + '::IceBox::FailureException', FailureException, (), False, None, (('reason', (), IcePy._t_string, False, 0),)) FailureException._ice_type = _M_IceBox._t_FailureException _M_IceBox.FailureException = FailureException @@ -56,10 +60,12 @@ def __str__(self): if 'Service' not in _M_IceBox.__dict__: _M_IceBox.Service = Ice.createTempClass() + class Service(object): """ An application service managed by a ServiceManager. """ + def __init__(self): if Ice.getType(self) == _M_IceBox.Service: raise RuntimeError('IceBox.Service is an abstract class') diff --git a/python/test/Glacier2/application/Client.py b/python/test/Glacier2/application/Client.py index e76292b2169..0f08a85f60b 100644 --- a/python/test/Glacier2/application/Client.py +++ b/python/test/Glacier2/application/Client.py @@ -33,7 +33,7 @@ def waitForCallback(self): with self._cond: while not self._received: self._cond.wait() - self._received = False; + self._received = False class Application(Glacier2.Application): @@ -50,16 +50,16 @@ def createSession(self): def runWithSession(self, args): - test(self.router()); - test(self.categoryForClient()); - test(self.objectAdapter()); + test(self.router()) + test(self.categoryForClient()) + test(self.objectAdapter()) if self._restart == 0: sys.stdout.write("testing Glacier2::Application restart... ") sys.stdout.flush() base = self.communicator().stringToProxy("callback:{0}".format( - self._helper.getTestEndpoint(properties=self.communicator().getProperties()))); + self._helper.getTestEndpoint(properties=self.communicator().getProperties()))) callback = Test.CallbackPrx.uncheckedCast(base) self._restart += 1 if self._restart < 5: diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py index 0dd2c11b71e..3b27dfae515 100644 --- a/python/test/Ice/acm/AllTests.py +++ b/python/test/Ice/acm/AllTests.py @@ -2,12 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading, time, traceback +import Ice +import Test +import sys +import threading +import time +import traceback + def test(b): if not b: raise RuntimeError('test assertion failed') + class LoggerI(Ice.Logger): def __init__(self): self._started = False @@ -54,6 +61,7 @@ def dump(self): print(p) self._messages = [] + class TestCase(threading.Thread): def __init__(self, name, com): threading.Thread.__init__(self) @@ -106,7 +114,7 @@ def joinWithThread(self): def run(self): proxy = Test.TestIntfPrx.uncheckedCast(self._communicator.stringToProxy( - self._adapter.getTestIntf().ice_toString())) + self._adapter.getTestIntf().ice_toString())) try: proxy.ice_getConnection().setCloseCallback(lambda conn: self.closed(conn)) proxy.ice_getConnection().setHeartbeatCallback(lambda conn: self.heartbeat(conn)) @@ -128,7 +136,7 @@ def waitForClosed(self): with self.m: while not self._closed: now = time.time() - self.m.wait(30.0) # Wait 30s + self.m.wait(30.0) # Wait 30s if time.time() - now > 30.0: test(False) @@ -145,6 +153,7 @@ def setServerACM(self, timeout, close, heartbeat): self._serverACMClose = close self._serverACMHeartbeat = heartbeat + def allTests(helper, communicator): ref = "communicator:{0}".format(helper.getTestEndpoint(num=0)) com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref)) @@ -154,7 +163,7 @@ def allTests(helper, communicator): class InvocationHeartbeatTest(TestCase): def __init__(self, com): TestCase.__init__(self, "invocation heartbeat", com) - self.setServerACM(1, -1, -1) # Faster ACM to make sure we receive enough ACM heartbeats + self.setServerACM(1, -1, -1) # Faster ACM to make sure we receive enough ACM heartbeats def runTestCase(self, adapter, proxy): proxy.sleep(4) @@ -182,7 +191,7 @@ def runTestCase(self, adapter, proxy): class InvocationNoHeartbeatTest(TestCase): def __init__(self, com): TestCase.__init__(self, "invocation with no heartbeat", com) - self.setServerACM(2, 2, 0) # Disable heartbeat on invocations + self.setServerACM(2, 2, 0) # Disable heartbeat on invocations def runTestCase(self, adapter, proxy): try: @@ -201,8 +210,8 @@ def runTestCase(self, adapter, proxy): class InvocationHeartbeatCloseOnIdleTest(TestCase): def __init__(self, com): TestCase.__init__(self, "invocation with no heartbeat and close on idle", com) - self.setClientACM(1, 1, 0) # Only close on idle. - self.setServerACM(1, 2, 0) # Disable heartbeat on invocations + self.setClientACM(1, 1, 0) # Only close on idle. + self.setServerACM(1, 2, 0) # Disable heartbeat on invocations def runTestCase(self, adapter, proxy): # No close on invocation, the call should succeed this time. @@ -215,7 +224,7 @@ def runTestCase(self, adapter, proxy): class CloseOnIdleTest(TestCase): def __init__(self, com): TestCase.__init__(self, "close on idle", com) - self.setClientACM(1, 1, 0) # Only close on idle. + self.setClientACM(1, 1, 0) # Only close on idle. def runTestCase(self, adapter, proxy): self.waitForClosed() @@ -226,10 +235,10 @@ def runTestCase(self, adapter, proxy): class CloseOnInvocationTest(TestCase): def __init__(self, com): TestCase.__init__(self, "close on invocation", com) - self.setClientACM(1, 2, 0) # Only close on invocation. + self.setClientACM(1, 2, 0) # Only close on invocation. def runTestCase(self, adapter, proxy): - time.sleep(3) # Idle for 3 seconds + time.sleep(3) # Idle for 3 seconds with self.m: test(self._heartbeat == 0) @@ -238,7 +247,7 @@ def runTestCase(self, adapter, proxy): class CloseOnIdleAndInvocationTest(TestCase): def __init__(self, com): TestCase.__init__(self, "close on idle and invocation", com) - self.setClientACM(3, 3, 0) # Only close on idle and invocation. + self.setClientACM(3, 3, 0) # Only close on idle and invocation. def runTestCase(self, adapter, proxy): # @@ -247,11 +256,11 @@ def runTestCase(self, adapter, proxy): # the close is graceful or forceful. # adapter.hold() - time.sleep(5) # Idle for 5 seconds + time.sleep(5) # Idle for 5 seconds with self.m: test(self._heartbeat == 0) - test(not self._closed) # Not closed yet because of graceful close. + test(not self._closed) # Not closed yet because of graceful close. adapter.activate() self.waitForClosed() @@ -259,7 +268,7 @@ def runTestCase(self, adapter, proxy): class ForcefulCloseOnIdleAndInvocationTest(TestCase): def __init__(self, com): TestCase.__init__(self, "forceful close on idle and invocation", com) - self.setClientACM(1, 4, 0) # Only close on idle and invocation. + self.setClientACM(1, 4, 0) # Only close on idle and invocation. def runTestCase(self, adapter, proxy): adapter.hold() @@ -271,7 +280,7 @@ def runTestCase(self, adapter, proxy): class HeartbeatOnIdleTest(TestCase): def __init__(self, com): TestCase.__init__(self, "heartbeat on idle", com) - self.setServerACM(1, -1, 2) # Enable server heartbeats. + self.setServerACM(1, -1, 2) # Enable server heartbeats. def runTestCase(self, adapter, proxy): time.sleep(3) @@ -282,7 +291,7 @@ def runTestCase(self, adapter, proxy): class HeartbeatAlwaysTest(TestCase): def __init__(self, com): TestCase.__init__(self, "heartbeat always", com) - self.setServerACM(1, -1, 3) # Enable server heartbeats. + self.setServerACM(1, -1, 3) # Enable server heartbeats. def runTestCase(self, adapter, proxy): for i in range(0, 10): diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py index c344d4b6d90..5beaed7a837 100644 --- a/python/test/Ice/acm/TestI.py +++ b/python/test/Ice/acm/TestI.py @@ -2,7 +2,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, threading +import Ice +import Test +import threading + class ConnectionCallbackI(): def __init__(self): @@ -19,11 +22,12 @@ def waitForCount(self, count): while self.count < count: self.m.wait() + class RemoteCommunicatorI(Test.RemoteCommunicator): def createObjectAdapter(self, timeout, close, heartbeat, current=None): com = current.adapter.getCommunicator() properties = com.getProperties() - protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); + protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp") name = Ice.generateUUID() if timeout >= 0: @@ -39,6 +43,7 @@ def createObjectAdapter(self, timeout, close, heartbeat, current=None): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() + class RemoteObjectAdapterI(Test.RemoteObjectAdapter): def __init__(self, adapter): self._adapter = adapter @@ -61,6 +66,7 @@ def deactivate(self, current=None): except Ice.ObjectAdapterDeactivatedException: pass + class TestIntfI(Test.TestIntf): def __init__(self): self.m = threading.Condition() diff --git a/python/test/Ice/adapterDeactivation/AllTests.py b/python/test/Ice/adapterDeactivation/AllTests.py index 8d3059a401f..d92f34706ba 100644 --- a/python/test/Ice/adapterDeactivation/AllTests.py +++ b/python/test/Ice/adapterDeactivation/AllTests.py @@ -2,12 +2,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, Ice, Test +import sys +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -57,13 +61,13 @@ def allTests(helper, communicator): communicator.getProperties().setProperty("PAdapter.PublishedEndpoints", "tcp -h localhost -p 12345 -t 30000") adapter = communicator.createObjectAdapter("PAdapter") test(len(adapter.getPublishedEndpoints()) == 1) - endpt = adapter.getPublishedEndpoints()[0]; + endpt = adapter.getPublishedEndpoints()[0] test(str(endpt) == "tcp -h localhost -p 12345 -t 30000") prx = communicator.stringToProxy("dummy:tcp -h localhost -p 12346 -t 20000:tcp -h localhost -p 12347 -t 10000") adapter.setPublishedEndpoints(prx.ice_getEndpoints()) test(len(adapter.getPublishedEndpoints()) == 2) ident = Ice.Identity() - ident.name = "dummy"; + ident.name = "dummy" test(adapter.createProxy(ident).ice_getEndpoints() == prx.ice_getEndpoints()) test(adapter.getPublishedEndpoints() == prx.ice_getEndpoints()) adapter.refreshPublishedEndpoints() @@ -95,7 +99,7 @@ def allTests(helper, communicator): sys.stdout.write("testing object adapter with router... ") sys.stdout.flush() routerId = Ice.Identity() - routerId.name = "router"; + routerId.name = "router" router = Ice.RouterPrx.uncheckedCast(base.ice_identity(routerId).ice_connectionId("rc")) adapter = communicator.createObjectAdapterWithRouter("", router) test(len(adapter.getPublishedEndpoints()) == 1) @@ -112,7 +116,7 @@ def allTests(helper, communicator): adapter.destroy() try: - routerId.name = "test"; + routerId.name = "test" router = Ice.RouterPrx.uncheckedCast(base.ice_identity(routerId)) communicator.createObjectAdapterWithRouter("", router) test(False) @@ -129,7 +133,7 @@ def allTests(helper, communicator): sys.stdout.write("testing whether server is gone... ") sys.stdout.flush() try: - obj.ice_timeout(100).ice_ping() # Use timeout to speed up testing on Windows + obj.ice_timeout(100).ice_ping() # Use timeout to speed up testing on Windows test(False) except Ice.LocalException: print("ok") diff --git a/python/test/Ice/adapterDeactivation/TestI.py b/python/test/Ice/adapterDeactivation/TestI.py index c9a10c3e7ed..ded6d82df60 100644 --- a/python/test/Ice/adapterDeactivation/TestI.py +++ b/python/test/Ice/adapterDeactivation/TestI.py @@ -2,13 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, time -import Ice, Test +import os +import sys +import traceback +import time +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class TestI(Test.TestIntf): def transient(self, current=None): communicator = current.adapter.getCommunicator() @@ -20,10 +26,11 @@ def deactivate(self, current=None): current.adapter.deactivate() time.sleep(0.1) + class RouterI(Ice.Router): def __init__(self): - self._nextPort = 23456; + self._nextPort = 23456 def getClientProxy(self, c): return (None, False) @@ -36,10 +43,12 @@ def getServerProxy(self, c): def addProxies(self, proxies, c): return [] + class Cookie: def message(self): return 'blahblah' + class ServantLocatorI(Ice.ServantLocator): def __init__(self): diff --git a/python/test/Ice/admin/AllTests.py b/python/test/Ice/admin/AllTests.py index a6ac1fcb2f8..54a6a586c55 100644 --- a/python/test/Ice/admin/AllTests.py +++ b/python/test/Ice/admin/AllTests.py @@ -2,13 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, TestI +import Ice +import Test +import sys +import TestI + def test(b): if not b: raise RuntimeError('test assertion failed') -def testFacets(com, builtInFacets = True): + +def testFacets(com, builtInFacets=True): if builtInFacets: test(com.findAdminFacet("Properties") != None) @@ -38,7 +43,7 @@ def testFacets(com, builtInFacets = True): test("Logger" in facetMap) test("Metrics" in facetMap) - test(len(facetMap) >=3) + test(len(facetMap) >= 3) test("Facet1" in facetMap) test("Facet2" in facetMap) @@ -48,13 +53,13 @@ def testFacets(com, builtInFacets = True): com.addAdminFacet(f1, "Facet1") test(False) except Ice.AlreadyRegisteredException: - pass # Expected + pass # Expected try: com.removeAdminFacet("Bogus") test(False) except Ice.NotRegisteredException: - pass # Expected + pass # Expected com.removeAdminFacet("Facet1") com.removeAdminFacet("Facet2") @@ -64,7 +69,8 @@ def testFacets(com, builtInFacets = True): com.removeAdminFacet("Facet1") test(False) except Ice.NotRegisteredException: - pass # Expected + pass # Expected + def allTests(helper, communicator): sys.stdout.write("testing communicator operations... ") @@ -198,11 +204,11 @@ def allTests(helper, communicator): # Test: PropertiesAdmin::setProperties() # setProps = {} - setProps["Prop1"] = "10" # Changed - setProps["Prop2"] = "20" # Changed - setProps["Prop3"] = "" # Removed - setProps["Prop4"] = "4" # Added - setProps["Prop5"] = "5" # Added + setProps["Prop1"] = "10" # Changed + setProps["Prop2"] = "20" # Changed + setProps["Prop3"] = "" # Removed + setProps["Prop4"] = "4" # Added + setProps["Prop5"] = "5" # Added pa.setProperties(setProps) test(pa.getProperty("Prop1") == "10") test(pa.getProperty("Prop2") == "20") diff --git a/python/test/Ice/admin/TestI.py b/python/test/Ice/admin/TestI.py index acc23288681..399942bc0b6 100644 --- a/python/test/Ice/admin/TestI.py +++ b/python/test/Ice/admin/TestI.py @@ -2,26 +2,31 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, threading +import Ice +import Test +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + class TestFacetI(Test.TestFacet): - def op(self, current = None): + def op(self, current=None): return + class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCallback): def __init__(self, communicator): self.communicator = communicator self.called = False self.m = threading.Condition() - def getAdmin(self, current = None): + def getAdmin(self, current=None): return self.communicator.getAdmin() - def getChanges(self, current = None): + def getChanges(self, current=None): with self.m: # # The client calls PropertiesAdmin::setProperties() and then invokes @@ -37,17 +42,17 @@ def getChanges(self, current = None): return self.changes - def shutdown(self, current = None): + def shutdown(self, current=None): self.communicator.shutdown() - def waitForShutdown(self, current = None): + def waitForShutdown(self, current=None): # # Note that we are executing in a thread of the *main* communicator, # not the one that is being shut down. # self.communicator.waitForShutdown() - def destroy(self, current = None): + def destroy(self, current=None): self.communicator.destroy() def updated(self, changes): @@ -56,9 +61,10 @@ def updated(self, changes): self.called = True self.m.notify() + class RemoteCommunicatorFactoryI(Test.RemoteCommunicatorFactory): - def createCommunicator(self, props, current = None): + def createCommunicator(self, props, current=None): # # Prepare the property set using the given properties. # @@ -89,5 +95,5 @@ def createCommunicator(self, props, current = None): proxy = current.adapter.addWithUUID(servant) return Test.RemoteCommunicatorPrx.uncheckedCast(proxy) - def shutdown(self, current = None): + def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index e629f9858bd..fecd21cae0e 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -2,21 +2,27 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading, random +import Ice +import Test +import sys +import threading +import random + def test(b): if not b: raise RuntimeError('test assertion failed') + class PingReplyI(Test.PingReply): - def __init__(self): - self._received = False + def __init__(self): + self._received = False - def reply(self, current=None): - self._received = True + def reply(self, current=None): + self._received = True - def checkReceived(self): - return self._received + def checkReceived(self): + return self._received class CallbackBase: @@ -38,6 +44,7 @@ def called(self): def exception(self, ex): test(False) + class ResponseCallback(CallbackBase): def isA(self, r): test(r) @@ -76,6 +83,7 @@ def opWithUE(self, ex): def ex(self, ex): pass + class ResponseCallbackWC(CallbackBase): def __init__(self, cookie): CallbackBase.__init__(self) @@ -126,6 +134,7 @@ def opWithUE(self, ex, cookie): def ex(self, ex, cookie): pass + class ExceptionCallback(CallbackBase): def response(self, *args): test(False) @@ -144,6 +153,7 @@ def ex(self, ex): def noEx(self, ex): test(False) + class ExceptionCallbackWC(CallbackBase): def __init__(self, cookie): CallbackBase.__init__(self) @@ -168,6 +178,7 @@ def ex(self, ex, cookie): def noEx(self, ex, cookie): test(False) + class SentCallback(CallbackBase): def __init__(self): CallbackBase.__init__(self) @@ -180,10 +191,11 @@ def ex(self, ex): pass def sent(self, sentSynchronously): - test((sentSynchronously and self._thread == threading.currentThread()) or \ + test((sentSynchronously and self._thread == threading.currentThread()) or (not sentSynchronously and self._thread != threading.currentThread())) self.called() + class SentCallbackWC(CallbackBase): def __init__(self, cookie): CallbackBase.__init__(self) @@ -198,10 +210,11 @@ def ex(self, ex, cookie): def sent(self, sentSynchronously, cookie): test(cookie == self._cookie) - test((sentSynchronously and self._thread == threading.currentThread()) or \ + test((sentSynchronously and self._thread == threading.currentThread()) or (not sentSynchronously and self._thread != threading.currentThread())) self.called() + class FlushCallback(CallbackBase): def __init__(self, cookie=None): CallbackBase.__init__(self) @@ -215,16 +228,17 @@ def exceptionWC(self, ex, cookie): test(False) def sent(self, sentSynchronously): - test((sentSynchronously and self._thread == threading.currentThread()) or \ + test((sentSynchronously and self._thread == threading.currentThread()) or (not sentSynchronously and self._thread != threading.currentThread())) self.called() def sentWC(self, sentSynchronously, cookie): - test((sentSynchronously and self._thread == threading.currentThread()) or \ + test((sentSynchronously and self._thread == threading.currentThread()) or (not sentSynchronously and self._thread != threading.currentThread())) test(cookie == self._cookie) self.called() + class FlushExCallback(CallbackBase): def __init__(self, cookie=None): CallbackBase.__init__(self) @@ -243,6 +257,7 @@ def sent(self, sentSynchronously): def sentWC(self, sentSynchronously, cookie): test(False) + class FutureDoneCallback(CallbackBase): def isA(self, f): test(f.result()) @@ -279,6 +294,7 @@ def opWithUE(self, f): except: test(False) + class FutureExceptionCallback(CallbackBase): def opWithUE(self, f): test(isinstance(f.exception(), Test.TestIntfException)) @@ -291,6 +307,7 @@ def ex(self, f): def noEx(self, f): test(f.exception() is None) + class FutureSentCallback(CallbackBase): def __init__(self): CallbackBase.__init__(self) @@ -303,6 +320,7 @@ def sentAsync(self, f, sentSynchronously): test(self._thread != threading.currentThread()) self.called() + class FutureFlushCallback(CallbackBase): def __init__(self, cookie=None): CallbackBase.__init__(self) @@ -316,6 +334,7 @@ def sentAsync(self, f, sentSynchronously): test(self._thread != threading.currentThread()) self.called() + class FutureFlushExCallback(CallbackBase): def __init__(self, cookie=None): CallbackBase.__init__(self) @@ -327,10 +346,12 @@ def exception(self, f): def sent(self, f, sentSynchronously): test(False) + LocalException = 0 UserException = 1 OtherException = 2 + def throwEx(t): if t == LocalException: raise Ice.ObjectNotExistException() @@ -341,6 +362,7 @@ def throwEx(t): else: test(False) + class Thrower(CallbackBase): def __init__(self, t): CallbackBase.__init__(self) @@ -382,6 +404,7 @@ def sentWC(self, ss, cookie): self.called() throwEx(self._t) + def allTests(helper, communicator, collocated): sref = "test:{0}".format(helper.getTestEndpoint(num=0)) obj = communicator.stringToProxy(sref) @@ -405,10 +428,10 @@ def allTests(helper, communicator, collocated): # without waiting for the pending invocation to complete. There will be no retry and we expect the # invocation to fail with ConnectionManuallyClosedException. # - p = p.ice_connectionId("CloseGracefully") # Start with a new connection. + p = p.ice_connectionId("CloseGracefully") # Start with a new connection. con = p.ice_getConnection() f = p.startDispatchAsync() - f.sent() # Ensure the request was sent before we close the connection. + f.sent() # Ensure the request was sent before we close the connection. con.close(Ice.ConnectionClose.Gracefully) try: f.result() @@ -425,8 +448,8 @@ def allTests(helper, communicator, collocated): cb = CallbackBase() con.setCloseCallback(lambda c: cb.called()) f = p.sleepAsync(100) - p.close(Test.CloseMode.Gracefully) # Close is delayed until sleep completes. - cb.check() # Ensure connection was closed. + p.close(Test.CloseMode.Gracefully) # Close is delayed until sleep completes. + cb.check() # Ensure connection was closed. try: f.result() except: @@ -444,7 +467,7 @@ def allTests(helper, communicator, collocated): p.ice_ping() con = p.ice_getConnection() f = p.startDispatchAsync() - f.sent() # Ensure the request was sent before we close the connection. + f.sent() # Ensure the request was sent before we close the connection. con.close(Ice.ConnectionClose.Forcefully) try: f.result() @@ -467,6 +490,7 @@ def allTests(helper, communicator, collocated): print("ok") + def allTestsFuture(helper, communicator, collocated): sref = "test:{0}".format(helper.getTestEndpoint(num=0)) obj = communicator.stringToProxy(sref) @@ -606,7 +630,7 @@ def allTestsFuture(helper, communicator, collocated): ic = Ice.initialize(initData) obj = ic.stringToProxy(p.ice_toString()) p2 = Test.TestIntfPrx.checkedCast(obj) - ic.destroy(); + ic.destroy() try: p2.opAsync() @@ -731,7 +755,7 @@ def allTestsFuture(helper, communicator, collocated): test(f.done()) test(p.waitForBatch(2)) - if p.ice_getConnection(): # No collocation optimization + if p.ice_getConnection(): # No collocation optimization test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() @@ -740,14 +764,14 @@ def allTestsFuture(helper, communicator, collocated): f = b1.ice_flushBatchRequestsAsync() f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. + f.result() # Wait until finished. test(f.is_sent()) test(f.done()) test(p.waitForBatch(1)) print("ok") - if p.ice_getConnection(): # No collocation optimization + if p.ice_getConnection(): # No collocation optimization sys.stdout.write("testing batch requests with connection... ") sys.stdout.flush() @@ -759,7 +783,7 @@ def allTestsFuture(helper, communicator, collocated): f = b1.ice_getConnection().flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. + f.result() # Wait until finished. test(f.is_sent()) test(f.done()) test(p.waitForBatch(2)) @@ -793,7 +817,7 @@ def allTestsFuture(helper, communicator, collocated): f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. + f.result() # Wait until finished. test(f.is_sent()) test(f.done()) test(p.waitForBatch(2)) @@ -809,8 +833,8 @@ def allTestsFuture(helper, communicator, collocated): f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. - test(f.is_sent()) # Exceptions are ignored! + f.result() # Wait until finished. + test(f.is_sent()) # Exceptions are ignored! test(f.done()) test(p.opBatchCount() == 0) @@ -821,7 +845,7 @@ def allTestsFuture(helper, communicator, collocated): b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. + b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b1.opBatch() b2.opBatch() @@ -830,7 +854,7 @@ def allTestsFuture(helper, communicator, collocated): f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. + f.result() # Wait until finished. test(f.is_sent()) test(f.done()) test(p.waitForBatch(4)) @@ -845,7 +869,7 @@ def allTestsFuture(helper, communicator, collocated): b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. + b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) @@ -853,8 +877,8 @@ def allTestsFuture(helper, communicator, collocated): f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. - test(f.is_sent()) # Exceptions are ignored! + f.result() # Wait until finished. + test(f.is_sent()) # Exceptions are ignored! test(f.done()) test(p.waitForBatch(1)) @@ -867,7 +891,7 @@ def allTestsFuture(helper, communicator, collocated): b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()) - b2.ice_getConnection() # Ensure connection is established. + b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) @@ -876,8 +900,8 @@ def allTestsFuture(helper, communicator, collocated): f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) cb.check() - f.result() # Wait until finished. - test(f.is_sent()) # Exceptions are ignored! + f.result() # Wait until finished. + test(f.is_sent()) # Exceptions are ignored! test(f.done()) test(p.opBatchCount() == 0) @@ -901,7 +925,7 @@ def allTestsFuture(helper, communicator, collocated): f1 = p.opAsync() b = [random.randint(0, 255) for x in range(0, 1024)] seq = bytes(b) - while(True): + while (True): f2 = p.opWithPayloadAsync(seq) if not f2.is_sent_synchronously(): break @@ -939,7 +963,7 @@ def allTestsFuture(helper, communicator, collocated): # f = p.ice_pingAsync() test(f.operation() == "ice_ping") - test(f.connection() == None) # Expected + test(f.connection() == None) # Expected test(f.communicator() == communicator) test(f.proxy() == p) f.result() @@ -950,7 +974,7 @@ def allTestsFuture(helper, communicator, collocated): p2 = p.ice_oneway() f = p2.ice_pingAsync() test(f.operation() == "ice_ping") - test(f.connection() == None) # Expected + test(f.connection() == None) # Expected test(f.communicator() == communicator) test(f.proxy() == p2) @@ -960,7 +984,7 @@ def allTestsFuture(helper, communicator, collocated): p2 = p.ice_batchOneway() p2.ice_ping() f = p2.ice_flushBatchRequestsAsync() - test(f.connection() == None) # Expected + test(f.connection() == None) # Expected test(f.communicator() == communicator) test(f.proxy() == p2) f.result() @@ -975,7 +999,7 @@ def allTestsFuture(helper, communicator, collocated): f = con.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) test(f.connection() == con) test(f.communicator() == communicator) - test(f.proxy() == None) # Expected + test(f.proxy() == None) # Expected f.result() # @@ -984,12 +1008,12 @@ def allTestsFuture(helper, communicator, collocated): p2 = p.ice_batchOneway() p2.ice_ping() f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) - test(f.connection() == None) # Expected + test(f.connection() == None) # Expected test(f.communicator() == communicator) - test(f.proxy() == None) # Expected + test(f.proxy() == None) # Expected f.result() - if(p.ice_getConnection()): + if (p.ice_getConnection()): f1 = None f2 = None @@ -998,7 +1022,7 @@ def allTestsFuture(helper, communicator, collocated): testController.holdAdapter() - for x in range(0, 200): # 2MB + for x in range(0, 200): # 2MB f = p.opWithPayloadAsync(seq) test(not f.is_sent()) @@ -1010,13 +1034,13 @@ def allTestsFuture(helper, communicator, collocated): try: f1.result() test(False) - except(Ice.InvocationCanceledException): + except (Ice.InvocationCanceledException): pass try: f2.result() test(False) - except(Ice.InvocationCanceledException): + except (Ice.InvocationCanceledException): pass testController.resumeAdapter() diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index 560dd6b3241..71389287856 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -2,7 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, threading, time +import Ice +import Test +import threading +import time + class TestIntfI(Test.TestIntf): def __init__(self): @@ -63,7 +67,7 @@ def finishDispatch(self, current=None): with self._cond: if self._shutdown: return - elif self._pending: # Pending might not be set yet if startDispatch is dispatch out-of-order + elif self._pending: # Pending might not be set yet if startDispatch is dispatch out-of-order self._pending.set_result(None) self._pending = None @@ -85,10 +89,12 @@ def pingBiDir(self, reply, current=None): # TODO: verify correct thread with add_done_callback_async reply.ice_fixed(current.con).replyAsync().result() + class TestIntfII(Test.Outer.Inner.TestIntf): def op(self, i, current): return (i, i) + class TestIntfControllerI(Test.TestIntfController): def __init__(self, adapter): self._adapter = adapter diff --git a/python/test/Ice/application/Client.py b/python/test/Ice/application/Client.py index 36f37988bc4..40077eedec7 100755 --- a/python/test/Ice/application/Client.py +++ b/python/test/Ice/application/Client.py @@ -3,7 +3,10 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, Ice, time +import sys +import Ice +import time + class Client(Ice.Application): def interruptCallback(self, sig): @@ -49,5 +52,6 @@ def run(self, args): print("ok") return False + app = Client() sys.exit(app.main(sys.argv)) diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py index c81e84b6106..f0ce612b758 100644 --- a/python/test/Ice/binding/AllTests.py +++ b/python/test/Ice/binding/AllTests.py @@ -2,12 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, random, threading +import Ice +import Test +import sys +import random +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + class GetAdapterNameCB: def __init__(self): self._name = "" @@ -27,11 +33,13 @@ def getResult(self): else: return "" + def getAdapterNameWithAMI(proxy): cb = GetAdapterNameCB() proxy.getAdapterNameAsync().add_done_callback(cb.response) return cb.getResult() + def createTestIntfPrx(adapters): endpoints = [] test = None @@ -41,10 +49,12 @@ def createTestIntfPrx(adapters): endpoints.extend(edpts) return Test.TestIntfPrx.uncheckedCast(test.ice_endpoints(endpoints)) + def deactivate(com, adapters): for p in adapters: com.deactivateObjectAdapter(p) + def allTests(helper, communicator): ref = "communicator:{0}".format(helper.getTestEndpoint()) com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref)) @@ -602,7 +612,7 @@ def allTests(helper, communicator): print("ok") - if(len(communicator.getProperties().getProperty("Ice.Plugin.IceSSL")) > 0): + if (len(communicator.getProperties().getProperty("Ice.Plugin.IceSSL")) > 0): sys.stdout.write("testing unsecure vs. secure endpoints... ") sys.stdout.flush() @@ -629,7 +639,7 @@ def allTests(helper, communicator): test(t.getAdapterName() == "Adapter81") t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) - com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. + com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. for i in range(0, 5): test(t.getAdapterName() == "Adapter83") diff --git a/python/test/Ice/binding/TestI.py b/python/test/Ice/binding/TestI.py index aa037b790c7..8a358b77a67 100644 --- a/python/test/Ice/binding/TestI.py +++ b/python/test/Ice/binding/TestI.py @@ -2,7 +2,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test + class RemoteCommunicatorI(Test.RemoteCommunicator): @@ -27,6 +29,7 @@ def deactivateObjectAdapter(self, adapter, current=None): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() + class RemoteObjectAdapterI(Test.RemoteObjectAdapter): def __init__(self, adapter): self._adapter = adapter @@ -42,6 +45,7 @@ def deactivate(self, current=None): except Ice.ObjectAdapterDeactivatedException: pass + class TestI(Test.TestIntf): def getAdapterName(self, current=None): return current.adapter.getName() diff --git a/python/test/Ice/blobject/RouterI.py b/python/test/Ice/blobject/RouterI.py index 4b845066165..913591f8b12 100644 --- a/python/test/Ice/blobject/RouterI.py +++ b/python/test/Ice/blobject/RouterI.py @@ -2,7 +2,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import threading, Ice +import threading +import Ice + class CallQueue(threading.Thread): def __init__(self): @@ -31,6 +33,7 @@ def run(self): call = self._queue.pop() call.execute() + class BlobjectCall(object): def __init__(self, proxy, future, inParams, curr): self._proxy = proxy @@ -61,6 +64,7 @@ def done(self, future): except Exception as ex: self._future.set_exception(ex) + class BlobjectAsyncI(Ice.BlobjectAsync): def __init__(self): self._queue = CallQueue() @@ -85,6 +89,7 @@ def destroy(self): self._queue.destroy() self._queue.join() + class BlobjectI(Ice.Blobject): def __init__(self): self._objects = {} @@ -113,12 +118,13 @@ def add(self, proxy): def destroy(self): pass + class ServantLocatorI(Ice.ServantLocator): def __init__(self, blobject): self._blobject = blobject def locate(self, current): - return self._blobject # and the cookie + return self._blobject # and the cookie def finished(self, current, object, cookie): pass @@ -126,6 +132,7 @@ def finished(self, current, object, cookie): def deactivate(self, s): pass + class RouterI(Ice.Router): def __init__(self, communicator, sync): self._adapter = communicator.createObjectAdapterWithEndpoints("forward", "default -h 127.0.0.1") @@ -146,7 +153,7 @@ def getClientProxy(self, current): return (self._blobjectProxy, True) def getServerProxy(self, current): - assert(False) + assert (False) def addProxies(self, proxies, current): for p in proxies: diff --git a/python/test/Ice/blobject/test.py b/python/test/Ice/blobject/test.py index f492ae61d29..b2e5338876b 100644 --- a/python/test/Ice/blobject/test.py +++ b/python/test/Ice/blobject/test.py @@ -6,4 +6,4 @@ # This test doesn't support running with IceSSL, the Router object in the client process uses # the client certificate and fails with "unsupported certificate purpose" -TestSuite(__name__, options = { "protocol" : ["tcp"] }) +TestSuite(__name__, options={"protocol": ["tcp"]}) diff --git a/python/test/Ice/custom/AllTests.py b/python/test/Ice/custom/AllTests.py index e3ac244640e..eaf0afdd2be 100644 --- a/python/test/Ice/custom/AllTests.py +++ b/python/test/Ice/custom/AllTests.py @@ -2,7 +2,13 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, string, re, traceback, Ice, Test, array +import sys +import string +import re +import traceback +import Ice +import Test +import array def test(b): @@ -79,25 +85,25 @@ def allTests(helper, communicator): test(b2 == stringList) s = Test.S() - s.b1 = byteList; - s.b2 = byteList; - s.b3 = byteList; - s.b4 = byteList; - s.s1 = stringList; - s.s2 = stringList; - s.s3 = stringList; - s.s4 = stringList; + s.b1 = byteList + s.b2 = byteList + s.b3 = byteList + s.b4 = byteList + s.s1 = stringList + s.s2 = stringList + s.s3 = stringList + s.s4 = stringList custom.sendS(s) c = Test.C() - c.b1 = byteList; - c.b2 = byteList; - c.b3 = byteList; - c.b4 = byteList; - c.s1 = stringList; - c.s2 = stringList; - c.s3 = stringList; - c.s4 = stringList; + c.b1 = byteList + c.b2 = byteList + c.b3 = byteList + c.b4 = byteList + c.s1 = stringList + c.s2 = stringList + c.s3 = stringList + c.s4 = stringList custom.sendC(c) print("ok") @@ -224,7 +230,6 @@ def allTests(helper, communicator): test(len(v1) == 0) test(len(v2) == 0) - d = Test.D() d.boolSeq = array.array("b", [True, False, True, False, True]) d.byteSeq = array.array("b", [0, 2, 4, 8, 16, 32, 64, 127]) @@ -345,7 +350,7 @@ def allTests(helper, communicator): custom.opBogusArrayNoCallableFactory() test(False) except RuntimeError: - pass + pass print("ok") diff --git a/python/test/Ice/custom/Custom.py b/python/test/Ice/custom/Custom.py index 2e58ec70213..fa86599a7bd 100644 --- a/python/test/Ice/custom/Custom.py +++ b/python/test/Ice/custom/Custom.py @@ -10,6 +10,7 @@ except ImportError: hasNumPy = False + def myBoolSeq(buffer, type, copy): return Ice.createArray(buffer, type, copy) @@ -37,41 +38,34 @@ def myFloatSeq(buffer, type, copy): def myDoubleSeq(buffer, type, copy): return Ice.createArray(buffer, type, copy) + if hasNumPy: def myNumPyBoolSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyByteSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyShortSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyIntSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyLongSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyFloatSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyDoubleSeq(buffer, type, copy): return Ice.createNumPyArray(buffer, type, copy) - def myNumPyComplex128Seq(buffer, type, copy): import numpy return numpy.frombuffer(buffer.tobytes() if copy else buffer, numpy.complex128) - def myNumPyMatrix3x3(buffer, type, copy): a = Ice.createNumPyArray(buffer, type, copy) a.shape = (3, 3) diff --git a/python/test/Ice/custom/Server.py b/python/test/Ice/custom/Server.py index d2751f32dc8..1a48dd5edeb 100755 --- a/python/test/Ice/custom/Server.py +++ b/python/test/Ice/custom/Server.py @@ -28,10 +28,12 @@ import Ice import array + def test(b): if not b: raise RuntimeError('test assertion failed') + class CustomI(Test.Custom): def opByteString1(self, b1, current=None): test(isinstance(b1, bytes)) @@ -137,6 +139,7 @@ def opD(self, d, current): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() + if hasNumPy: class NumPyCustomI(Test.NumPy.Custom): diff --git a/python/test/Ice/defaultServant/AllTests.py b/python/test/Ice/defaultServant/AllTests.py index 78121639762..53423c7e0ca 100644 --- a/python/test/Ice/defaultServant/AllTests.py +++ b/python/test/Ice/defaultServant/AllTests.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, MyObjectI, sys +import Ice +import Test +import MyObjectI +import sys + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost") @@ -31,7 +36,7 @@ def allTests(helper, communicator): identity = Ice.Identity() identity.category = "foo" - names = ( "foo", "bar", "x", "y", "abcdefg" ) + names = ("foo", "bar", "x", "y", "abcdefg") for idx in range(0, 5): identity.name = names[idx] diff --git a/python/test/Ice/defaultServant/MyObjectI.py b/python/test/Ice/defaultServant/MyObjectI.py index 93d05fb57f6..447c0daa194 100644 --- a/python/test/Ice/defaultServant/MyObjectI.py +++ b/python/test/Ice/defaultServant/MyObjectI.py @@ -2,7 +2,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test + class MyObjectI(Test.MyObject): def ice_ping(self, current=None): diff --git a/python/test/Ice/defaultValue/AllTests.py b/python/test/Ice/defaultValue/AllTests.py index 9b0bf6906d2..c22b8d4a906 100644 --- a/python/test/Ice/defaultValue/AllTests.py +++ b/python/test/Ice/defaultValue/AllTests.py @@ -2,12 +2,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys +import Ice +import Test +import sys + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(): sys.stdout.write("testing default values... ") @@ -159,21 +163,21 @@ def allTests(): test(v.c1 == Test.Color.red) test(v.bs is None) test(v.iseq is None) - test(isinstance(v.st, Test.InnerStruct)); - test(v.dict is None); + test(isinstance(v.st, Test.InnerStruct)) + test(v.dict is None) e = Test.ExceptionNoDefaults() test(e.str == '') test(e.c1 == Test.Color.red) test(e.bs is None) - test(isinstance(e.st, Test.InnerStruct)); - test(e.dict is None); + test(isinstance(e.st, Test.InnerStruct)) + test(e.dict is None) c = Test.ClassNoDefaults() test(c.str == '') test(c.c1 == Test.Color.red) test(c.bs is None) - test(isinstance(c.st, Test.InnerStruct)); - test(c.dict is None); + test(isinstance(c.st, Test.InnerStruct)) + test(c.dict is None) print("ok") diff --git a/python/test/Ice/dispatcher/AllTests.py b/python/test/Ice/dispatcher/AllTests.py index ccdb2d53949..ba89dfa7061 100644 --- a/python/test/Ice/dispatcher/AllTests.py +++ b/python/test/Ice/dispatcher/AllTests.py @@ -2,12 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, Dispatcher, sys, threading, random +import Ice +import Test +import Dispatcher +import sys +import threading +import random + def test(b): if not b: raise RuntimeError('test assertion failed') + class Callback: def __init__(self): self._called = False @@ -46,6 +53,7 @@ def payload(self, f): else: test(Dispatcher.Dispatcher.isDispatcherThread()) + def allTests(helper, communicator): sref = "test:{0}".format(helper.getTestEndpoint()) obj = communicator.stringToProxy(sref) @@ -79,7 +87,7 @@ def allTests(helper, communicator): # # Expect InvocationTimeoutException. # - to = p.ice_invocationTimeout(10); + to = p.ice_invocationTimeout(10) to.sleepAsync(500).add_done_callback_async(cb.exceptionEx) cb.check() diff --git a/python/test/Ice/dispatcher/Dispatcher.py b/python/test/Ice/dispatcher/Dispatcher.py index b096aeb6292..fea1d893bb1 100755 --- a/python/test/Ice/dispatcher/Dispatcher.py +++ b/python/test/Ice/dispatcher/Dispatcher.py @@ -3,12 +3,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, os, sys, traceback, time, threading +import Ice +import os +import sys +import traceback +import time +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + class Dispatcher: def __init__(self): self._calls = [] diff --git a/python/test/Ice/dispatcher/TestI.py b/python/test/Ice/dispatcher/TestI.py index da3ed0a5093..8463bc336a1 100644 --- a/python/test/Ice/dispatcher/TestI.py +++ b/python/test/Ice/dispatcher/TestI.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, Dispatcher, time +import Ice +import Test +import Dispatcher +import time + def test(b): if not b: raise RuntimeError('test assertion failed') + class TestIntfI(Test.TestIntf): def op(self, current=None): test(Dispatcher.Dispatcher.isDispatcherThread()) @@ -22,6 +27,7 @@ def shutdown(self, current=None): test(Dispatcher.Dispatcher.isDispatcherThread()) current.adapter.getCommunicator().shutdown() + class TestIntfControllerI(Test.TestIntfController): def __init__(self, adapter): self._adapter = adapter diff --git a/python/test/Ice/enums/AllTests.py b/python/test/Ice/enums/AllTests.py index 1152b38ff84..5cabba45404 100644 --- a/python/test/Ice/enums/AllTests.py +++ b/python/test/Ice/enums/AllTests.py @@ -2,12 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, string, re, traceback, Ice, Test +import sys +import string +import re +import traceback +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): ref = "test:{0}".format(helper.getTestEndpoint()) base = communicator.stringToProxy(ref) @@ -19,113 +26,113 @@ def allTests(helper, communicator): sys.stdout.write("testing enum values... ") sys.stdout.flush() - test(Test.ByteEnum.benum1.value == 0); - test(Test.ByteEnum.benum2.value == 1); - test(Test.ByteEnum.benum3.value == Test.ByteConst1); - test(Test.ByteEnum.benum4.value == Test.ByteConst1 + 1); - test(Test.ByteEnum.benum5.value == Test.ShortConst1); - test(Test.ByteEnum.benum6.value == Test.ShortConst1 + 1); - test(Test.ByteEnum.benum7.value == Test.IntConst1); - test(Test.ByteEnum.benum8.value == Test.IntConst1 + 1); - test(Test.ByteEnum.benum9.value == Test.LongConst1); - test(Test.ByteEnum.benum10.value == Test.LongConst1 + 1); - test(Test.ByteEnum.benum11.value == Test.ByteConst2); - - test(Test.ByteEnum.valueOf(0) == Test.ByteEnum.benum1); - test(Test.ByteEnum.valueOf(1) == Test.ByteEnum.benum2); - test(Test.ByteEnum.valueOf(Test.ByteConst1) == Test.ByteEnum.benum3); - test(Test.ByteEnum.valueOf(Test.ByteConst1 + 1) == Test.ByteEnum.benum4); - test(Test.ByteEnum.valueOf(Test.ShortConst1) == Test.ByteEnum.benum5); - test(Test.ByteEnum.valueOf(Test.ShortConst1 + 1) == Test.ByteEnum.benum6); - test(Test.ByteEnum.valueOf(Test.IntConst1) == Test.ByteEnum.benum7); - test(Test.ByteEnum.valueOf(Test.IntConst1 + 1) == Test.ByteEnum.benum8); - test(Test.ByteEnum.valueOf(Test.LongConst1) == Test.ByteEnum.benum9); - test(Test.ByteEnum.valueOf(Test.LongConst1 + 1) == Test.ByteEnum.benum10); - test(Test.ByteEnum.valueOf(Test.ByteConst2) == Test.ByteEnum.benum11); - - test(Test.ShortEnum.senum1.value == 3); - test(Test.ShortEnum.senum2.value == 4); - test(Test.ShortEnum.senum3.value == Test.ByteConst1); - test(Test.ShortEnum.senum4.value == Test.ByteConst1 + 1); - test(Test.ShortEnum.senum5.value == Test.ShortConst1); - test(Test.ShortEnum.senum6.value == Test.ShortConst1 + 1); - test(Test.ShortEnum.senum7.value == Test.IntConst1); - test(Test.ShortEnum.senum8.value == Test.IntConst1 + 1); - test(Test.ShortEnum.senum9.value == Test.LongConst1); - test(Test.ShortEnum.senum10.value == Test.LongConst1 + 1); - test(Test.ShortEnum.senum11.value == Test.ShortConst2); - - test(Test.ShortEnum.valueOf(3) == Test.ShortEnum.senum1); - test(Test.ShortEnum.valueOf(4) == Test.ShortEnum.senum2); - test(Test.ShortEnum.valueOf(Test.ByteConst1) == Test.ShortEnum.senum3); - test(Test.ShortEnum.valueOf(Test.ByteConst1 + 1) == Test.ShortEnum.senum4); - test(Test.ShortEnum.valueOf(Test.ShortConst1) == Test.ShortEnum.senum5); - test(Test.ShortEnum.valueOf(Test.ShortConst1 + 1) == Test.ShortEnum.senum6); - test(Test.ShortEnum.valueOf(Test.IntConst1) == Test.ShortEnum.senum7); - test(Test.ShortEnum.valueOf(Test.IntConst1 + 1) == Test.ShortEnum.senum8); - test(Test.ShortEnum.valueOf(Test.LongConst1) == Test.ShortEnum.senum9); - test(Test.ShortEnum.valueOf(Test.LongConst1 + 1) == Test.ShortEnum.senum10); - test(Test.ShortEnum.valueOf(Test.ShortConst2) == Test.ShortEnum.senum11); - - test(Test.IntEnum.ienum1.value == 0); - test(Test.IntEnum.ienum2.value == 1); - test(Test.IntEnum.ienum3.value == Test.ByteConst1); - test(Test.IntEnum.ienum4.value == Test.ByteConst1 + 1); - test(Test.IntEnum.ienum5.value == Test.ShortConst1); - test(Test.IntEnum.ienum6.value == Test.ShortConst1 + 1); - test(Test.IntEnum.ienum7.value == Test.IntConst1); - test(Test.IntEnum.ienum8.value == Test.IntConst1 + 1); - test(Test.IntEnum.ienum9.value == Test.LongConst1); - test(Test.IntEnum.ienum10.value == Test.LongConst1 + 1); - test(Test.IntEnum.ienum11.value == Test.IntConst2); - test(Test.IntEnum.ienum12.value == Test.LongConst2); - - test(Test.IntEnum.valueOf(0) == Test.IntEnum.ienum1); - test(Test.IntEnum.valueOf(1) == Test.IntEnum.ienum2); - test(Test.IntEnum.valueOf(Test.ByteConst1) == Test.IntEnum.ienum3); - test(Test.IntEnum.valueOf(Test.ByteConst1 + 1) == Test.IntEnum.ienum4); - test(Test.IntEnum.valueOf(Test.ShortConst1) == Test.IntEnum.ienum5); - test(Test.IntEnum.valueOf(Test.ShortConst1 + 1) == Test.IntEnum.ienum6); - test(Test.IntEnum.valueOf(Test.IntConst1) == Test.IntEnum.ienum7); - test(Test.IntEnum.valueOf(Test.IntConst1 + 1) == Test.IntEnum.ienum8); - test(Test.IntEnum.valueOf(Test.LongConst1) == Test.IntEnum.ienum9); - test(Test.IntEnum.valueOf(Test.LongConst1 + 1) == Test.IntEnum.ienum10); - test(Test.IntEnum.valueOf(Test.IntConst2) == Test.IntEnum.ienum11); - test(Test.IntEnum.valueOf(Test.LongConst2) == Test.IntEnum.ienum12); - - test(Test.SimpleEnum.red.value == 0); - test(Test.SimpleEnum.green.value == 1); - test(Test.SimpleEnum.blue.value == 2); - - test(Test.SimpleEnum.valueOf(0) == Test.SimpleEnum.red); - test(Test.SimpleEnum.valueOf(1) == Test.SimpleEnum.green); - test(Test.SimpleEnum.valueOf(2) == Test.SimpleEnum.blue); + test(Test.ByteEnum.benum1.value == 0) + test(Test.ByteEnum.benum2.value == 1) + test(Test.ByteEnum.benum3.value == Test.ByteConst1) + test(Test.ByteEnum.benum4.value == Test.ByteConst1 + 1) + test(Test.ByteEnum.benum5.value == Test.ShortConst1) + test(Test.ByteEnum.benum6.value == Test.ShortConst1 + 1) + test(Test.ByteEnum.benum7.value == Test.IntConst1) + test(Test.ByteEnum.benum8.value == Test.IntConst1 + 1) + test(Test.ByteEnum.benum9.value == Test.LongConst1) + test(Test.ByteEnum.benum10.value == Test.LongConst1 + 1) + test(Test.ByteEnum.benum11.value == Test.ByteConst2) + + test(Test.ByteEnum.valueOf(0) == Test.ByteEnum.benum1) + test(Test.ByteEnum.valueOf(1) == Test.ByteEnum.benum2) + test(Test.ByteEnum.valueOf(Test.ByteConst1) == Test.ByteEnum.benum3) + test(Test.ByteEnum.valueOf(Test.ByteConst1 + 1) == Test.ByteEnum.benum4) + test(Test.ByteEnum.valueOf(Test.ShortConst1) == Test.ByteEnum.benum5) + test(Test.ByteEnum.valueOf(Test.ShortConst1 + 1) == Test.ByteEnum.benum6) + test(Test.ByteEnum.valueOf(Test.IntConst1) == Test.ByteEnum.benum7) + test(Test.ByteEnum.valueOf(Test.IntConst1 + 1) == Test.ByteEnum.benum8) + test(Test.ByteEnum.valueOf(Test.LongConst1) == Test.ByteEnum.benum9) + test(Test.ByteEnum.valueOf(Test.LongConst1 + 1) == Test.ByteEnum.benum10) + test(Test.ByteEnum.valueOf(Test.ByteConst2) == Test.ByteEnum.benum11) + + test(Test.ShortEnum.senum1.value == 3) + test(Test.ShortEnum.senum2.value == 4) + test(Test.ShortEnum.senum3.value == Test.ByteConst1) + test(Test.ShortEnum.senum4.value == Test.ByteConst1 + 1) + test(Test.ShortEnum.senum5.value == Test.ShortConst1) + test(Test.ShortEnum.senum6.value == Test.ShortConst1 + 1) + test(Test.ShortEnum.senum7.value == Test.IntConst1) + test(Test.ShortEnum.senum8.value == Test.IntConst1 + 1) + test(Test.ShortEnum.senum9.value == Test.LongConst1) + test(Test.ShortEnum.senum10.value == Test.LongConst1 + 1) + test(Test.ShortEnum.senum11.value == Test.ShortConst2) + + test(Test.ShortEnum.valueOf(3) == Test.ShortEnum.senum1) + test(Test.ShortEnum.valueOf(4) == Test.ShortEnum.senum2) + test(Test.ShortEnum.valueOf(Test.ByteConst1) == Test.ShortEnum.senum3) + test(Test.ShortEnum.valueOf(Test.ByteConst1 + 1) == Test.ShortEnum.senum4) + test(Test.ShortEnum.valueOf(Test.ShortConst1) == Test.ShortEnum.senum5) + test(Test.ShortEnum.valueOf(Test.ShortConst1 + 1) == Test.ShortEnum.senum6) + test(Test.ShortEnum.valueOf(Test.IntConst1) == Test.ShortEnum.senum7) + test(Test.ShortEnum.valueOf(Test.IntConst1 + 1) == Test.ShortEnum.senum8) + test(Test.ShortEnum.valueOf(Test.LongConst1) == Test.ShortEnum.senum9) + test(Test.ShortEnum.valueOf(Test.LongConst1 + 1) == Test.ShortEnum.senum10) + test(Test.ShortEnum.valueOf(Test.ShortConst2) == Test.ShortEnum.senum11) + + test(Test.IntEnum.ienum1.value == 0) + test(Test.IntEnum.ienum2.value == 1) + test(Test.IntEnum.ienum3.value == Test.ByteConst1) + test(Test.IntEnum.ienum4.value == Test.ByteConst1 + 1) + test(Test.IntEnum.ienum5.value == Test.ShortConst1) + test(Test.IntEnum.ienum6.value == Test.ShortConst1 + 1) + test(Test.IntEnum.ienum7.value == Test.IntConst1) + test(Test.IntEnum.ienum8.value == Test.IntConst1 + 1) + test(Test.IntEnum.ienum9.value == Test.LongConst1) + test(Test.IntEnum.ienum10.value == Test.LongConst1 + 1) + test(Test.IntEnum.ienum11.value == Test.IntConst2) + test(Test.IntEnum.ienum12.value == Test.LongConst2) + + test(Test.IntEnum.valueOf(0) == Test.IntEnum.ienum1) + test(Test.IntEnum.valueOf(1) == Test.IntEnum.ienum2) + test(Test.IntEnum.valueOf(Test.ByteConst1) == Test.IntEnum.ienum3) + test(Test.IntEnum.valueOf(Test.ByteConst1 + 1) == Test.IntEnum.ienum4) + test(Test.IntEnum.valueOf(Test.ShortConst1) == Test.IntEnum.ienum5) + test(Test.IntEnum.valueOf(Test.ShortConst1 + 1) == Test.IntEnum.ienum6) + test(Test.IntEnum.valueOf(Test.IntConst1) == Test.IntEnum.ienum7) + test(Test.IntEnum.valueOf(Test.IntConst1 + 1) == Test.IntEnum.ienum8) + test(Test.IntEnum.valueOf(Test.LongConst1) == Test.IntEnum.ienum9) + test(Test.IntEnum.valueOf(Test.LongConst1 + 1) == Test.IntEnum.ienum10) + test(Test.IntEnum.valueOf(Test.IntConst2) == Test.IntEnum.ienum11) + test(Test.IntEnum.valueOf(Test.LongConst2) == Test.IntEnum.ienum12) + + test(Test.SimpleEnum.red.value == 0) + test(Test.SimpleEnum.green.value == 1) + test(Test.SimpleEnum.blue.value == 2) + + test(Test.SimpleEnum.valueOf(0) == Test.SimpleEnum.red) + test(Test.SimpleEnum.valueOf(1) == Test.SimpleEnum.green) + test(Test.SimpleEnum.valueOf(2) == Test.SimpleEnum.blue) print("ok") sys.stdout.write("testing enum operations... ") sys.stdout.flush() - test(proxy.opByte(Test.ByteEnum.benum1) == (Test.ByteEnum.benum1, Test.ByteEnum.benum1)); - test(proxy.opByte(Test.ByteEnum.benum11) == (Test.ByteEnum.benum11, Test.ByteEnum.benum11)); + test(proxy.opByte(Test.ByteEnum.benum1) == (Test.ByteEnum.benum1, Test.ByteEnum.benum1)) + test(proxy.opByte(Test.ByteEnum.benum11) == (Test.ByteEnum.benum11, Test.ByteEnum.benum11)) - test(proxy.opShort(Test.ShortEnum.senum1) == (Test.ShortEnum.senum1, Test.ShortEnum.senum1)); - test(proxy.opShort(Test.ShortEnum.senum11) == (Test.ShortEnum.senum11, Test.ShortEnum.senum11)); + test(proxy.opShort(Test.ShortEnum.senum1) == (Test.ShortEnum.senum1, Test.ShortEnum.senum1)) + test(proxy.opShort(Test.ShortEnum.senum11) == (Test.ShortEnum.senum11, Test.ShortEnum.senum11)) - test(proxy.opInt(Test.IntEnum.ienum1) == (Test.IntEnum.ienum1, Test.IntEnum.ienum1)); - test(proxy.opInt(Test.IntEnum.ienum11) == (Test.IntEnum.ienum11, Test.IntEnum.ienum11)); - test(proxy.opInt(Test.IntEnum.ienum12) == (Test.IntEnum.ienum12, Test.IntEnum.ienum12)); + test(proxy.opInt(Test.IntEnum.ienum1) == (Test.IntEnum.ienum1, Test.IntEnum.ienum1)) + test(proxy.opInt(Test.IntEnum.ienum11) == (Test.IntEnum.ienum11, Test.IntEnum.ienum11)) + test(proxy.opInt(Test.IntEnum.ienum12) == (Test.IntEnum.ienum12, Test.IntEnum.ienum12)) - test(proxy.opSimple(Test.SimpleEnum.green) == (Test.SimpleEnum.green, Test.SimpleEnum.green)); + test(proxy.opSimple(Test.SimpleEnum.green) == (Test.SimpleEnum.green, Test.SimpleEnum.green)) print("ok") sys.stdout.write("testing enum sequences operations... ") sys.stdout.flush() - b1 = [ Test.ByteEnum.benum1, Test.ByteEnum.benum2, Test.ByteEnum.benum3, Test.ByteEnum.benum4, Test.ByteEnum.benum5, - Test.ByteEnum.benum6, Test.ByteEnum.benum7, Test.ByteEnum.benum8, Test.ByteEnum.benum9, Test.ByteEnum.benum10, - Test.ByteEnum.benum11 ] + b1 = [Test.ByteEnum.benum1, Test.ByteEnum.benum2, Test.ByteEnum.benum3, Test.ByteEnum.benum4, Test.ByteEnum.benum5, + Test.ByteEnum.benum6, Test.ByteEnum.benum7, Test.ByteEnum.benum8, Test.ByteEnum.benum9, Test.ByteEnum.benum10, + Test.ByteEnum.benum11] (b2, b3) = proxy.opByteSeq(b1) @@ -133,9 +140,9 @@ def allTests(helper, communicator): test(b1[i] == b2[i]) test(b1[i] == b3[i]) - s1 = [ Test.ShortEnum.senum1, Test.ShortEnum.senum2, Test.ShortEnum.senum3, Test.ShortEnum.senum4, - Test.ShortEnum.senum5, Test.ShortEnum.senum6, Test.ShortEnum.senum7, Test.ShortEnum.senum8, - Test.ShortEnum.senum9, Test.ShortEnum.senum10, Test.ShortEnum.senum11 ] + s1 = [Test.ShortEnum.senum1, Test.ShortEnum.senum2, Test.ShortEnum.senum3, Test.ShortEnum.senum4, + Test.ShortEnum.senum5, Test.ShortEnum.senum6, Test.ShortEnum.senum7, Test.ShortEnum.senum8, + Test.ShortEnum.senum9, Test.ShortEnum.senum10, Test.ShortEnum.senum11] (s2, s3) = proxy.opShortSeq(s1) @@ -143,9 +150,9 @@ def allTests(helper, communicator): test(s1[i] == s2[i]) test(s1[i] == s3[i]) - i1 = [ Test.IntEnum.ienum1, Test.IntEnum.ienum2, Test.IntEnum.ienum3, Test.IntEnum.ienum4, - Test.IntEnum.ienum5, Test.IntEnum.ienum6, Test.IntEnum.ienum7, Test.IntEnum.ienum8, - Test.IntEnum.ienum9, Test.IntEnum.ienum10, Test.IntEnum.ienum11 ] + i1 = [Test.IntEnum.ienum1, Test.IntEnum.ienum2, Test.IntEnum.ienum3, Test.IntEnum.ienum4, + Test.IntEnum.ienum5, Test.IntEnum.ienum6, Test.IntEnum.ienum7, Test.IntEnum.ienum8, + Test.IntEnum.ienum9, Test.IntEnum.ienum10, Test.IntEnum.ienum11] (i2, i3) = proxy.opIntSeq(i1) @@ -153,7 +160,7 @@ def allTests(helper, communicator): test(i1[i] == i2[i]) test(i1[i] == i3[i]) - s1 = [ Test.SimpleEnum.red, Test.SimpleEnum.green, Test.SimpleEnum.blue ] + s1 = [Test.SimpleEnum.red, Test.SimpleEnum.green, Test.SimpleEnum.blue] (s2, s3) = proxy.opSimpleSeq(s1) diff --git a/python/test/Ice/exceptions/AllTests.py b/python/test/Ice/exceptions/AllTests.py index 5cd26055c08..720cef42f9a 100644 --- a/python/test/Ice/exceptions/AllTests.py +++ b/python/test/Ice/exceptions/AllTests.py @@ -2,15 +2,22 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, threading, sys, array +import Ice +import Test +import threading +import sys +import array + def test(b): if not b: raise RuntimeError('test assertion failed') + class EmptyI(Test.Empty): pass + class ServantLocatorI(Ice.ServantLocator): def locate(self, current): return None @@ -21,9 +28,11 @@ def finished(self, current, servant, cookie): def deactivate(self, category): pass + def ValueFactory(type): return None + class CallbackBase: def __init__(self): self._called = False @@ -40,6 +49,7 @@ def called(self): self._called = True self._cond.notify() + class Callback(CallbackBase): def __init__(self, communicator=None): CallbackBase.__init__(self) @@ -207,6 +217,7 @@ def exception_NonIceException(self, ex): test(False) self.called() + def allTests(helper, communicator): sys.stdout.write("testing servant registration exceptions... ") sys.stdout.flush() @@ -459,11 +470,11 @@ def allTests(helper, communicator): print("ok") if thrower.ice_getConnection(): - sys.stdout.write("testing memory limit marshal exception..."); - sys.stdout.flush(); + sys.stdout.write("testing memory limit marshal exception...") + sys.stdout.flush() try: - thrower.throwMemoryLimitException(array.array('B')); + thrower.throwMemoryLimitException(array.array('B')) test(False) except Ice.MemoryLimitException: pass @@ -472,7 +483,7 @@ def allTests(helper, communicator): test(False) try: - thrower.throwMemoryLimitException(bytearray(20 * 1024)) # 20KB + thrower.throwMemoryLimitException(bytearray(20 * 1024)) # 20KB test(False) except Ice.ConnectionLostException: pass @@ -481,7 +492,7 @@ def allTests(helper, communicator): except: test(False) - print("ok"); + print("ok") sys.stdout.write("catching object not exist exception... ") sys.stdout.flush() @@ -817,11 +828,11 @@ def allTests(helper, communicator): sys.stdout.flush() try: try: - thrower.throwMarshalException(context={"response":""}) + thrower.throwMarshalException(context={"response": ""}) except Ice.UnknownLocalException as ex: test("::Ice::MarshalException" in str(ex)) try: - thrower.throwMarshalException(context={"param":""}) + thrower.throwMarshalException(context={"param": ""}) except Ice.UnknownLocalException as ex: test("::Ice::MarshalException" in str(ex)) try: diff --git a/python/test/Ice/exceptions/ServerAMD.py b/python/test/Ice/exceptions/ServerAMD.py index 1e249503f34..97df8a6a0ce 100755 --- a/python/test/Ice/exceptions/ServerAMD.py +++ b/python/test/Ice/exceptions/ServerAMD.py @@ -143,6 +143,7 @@ def throwMarshalException(self, current): return Ice.Future.completed((0, "")) return Ice.Future.completed(None) + class ServerAMD(TestHelper): def run(self, args): diff --git a/python/test/Ice/exceptions/TestI.py b/python/test/Ice/exceptions/TestI.py index 65860b6cad6..22f3b2642a0 100644 --- a/python/test/Ice/exceptions/TestI.py +++ b/python/test/Ice/exceptions/TestI.py @@ -2,7 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, array, sys +import Ice +import Test +import array +import sys + class ThrowerI(Test.Thrower): def shutdown(self, current=None): diff --git a/python/test/Ice/facets/AllTests.py b/python/test/Ice/facets/AllTests.py index 4a15def5a5c..00582037726 100644 --- a/python/test/Ice/facets/AllTests.py +++ b/python/test/Ice/facets/AllTests.py @@ -2,37 +2,42 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys +import Ice +import Test +import sys + def test(b): if not b: raise RuntimeError('test assertion failed') + class EmptyI(Test.Empty): pass + def allTests(helper, communicator): sys.stdout.write("testing Ice.Admin.Facets property... ") sys.stdout.flush() test(len(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")) == 0) - communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar"); - facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); - test(len(facetFilter) == 1 and facetFilter[0] == "foobar"); - communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar"); - facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); - test(len(facetFilter) == 1 and facetFilter[0] == "foo'bar"); - communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'"); - facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); + communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar") + facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets") + test(len(facetFilter) == 1 and facetFilter[0] == "foobar") + communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar") + facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets") + test(len(facetFilter) == 1 and facetFilter[0] == "foo'bar") + communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'") + facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets") test(len(facetFilter) == 3 and facetFilter[0] == "foo bar" and facetFilter[1] == "toto" - and facetFilter[2] == "titi"); - communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'"); - facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); - test(len(facetFilter) == 2 and facetFilter[0] == "foo bar' toto" and facetFilter[1] == "titi"); + and facetFilter[2] == "titi") + communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'") + facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets") + test(len(facetFilter) == 2 and facetFilter[0] == "foo bar' toto" and facetFilter[1] == "titi") # communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi"); # facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); # test(len(facetFilter) == 0); - communicator.getProperties().setProperty("Ice.Admin.Facets", ""); + communicator.getProperties().setProperty("Ice.Admin.Facets", "") print("ok") sys.stdout.write("testing facet registration exceptions... ") diff --git a/python/test/Ice/facets/TestI.py b/python/test/Ice/facets/TestI.py index 3c5333ebb0f..9401e015b3c 100644 --- a/python/test/Ice/facets/TestI.py +++ b/python/test/Ice/facets/TestI.py @@ -4,30 +4,37 @@ import Test + class AI(Test.A): def callA(self, current=None): return "A" + class BI(Test.B, AI): def callB(self, current=None): return "B" + class CI(Test.C, AI): def callC(self, current=None): return "C" + class DI(Test.D, BI, CI): def callD(self, current=None): return "D" + class EI(Test.E): def callE(self, current=None): return "E" + class FI(Test.F, EI): def callF(self, current=None): return "F" + class GI(Test.G): def __init__(self, communicator): self._communicator = communicator @@ -38,6 +45,7 @@ def shutdown(self, current=None): def callG(self, current=None): return "G" + class HI(Test.H, GI): def __init__(self, communicator): GI.__init__(self, communicator) diff --git a/python/test/Ice/faultTolerance/AllTests.py b/python/test/Ice/faultTolerance/AllTests.py index 59dd70609ef..f3eff3363a5 100644 --- a/python/test/Ice/faultTolerance/AllTests.py +++ b/python/test/Ice/faultTolerance/AllTests.py @@ -2,15 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, sys, threading +import Ice +import sys +import threading Ice.loadSlice('Test.ice') import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class CallbackBase: def __init__(self): self._called = False @@ -27,6 +31,7 @@ def called(self): self._called = True self._cond.notify() + class Callback(CallbackBase): def opPidI(self, f): try: @@ -55,6 +60,7 @@ def exceptAbortI(self, f): def pid(self): return self._pid + def allTests(helper, communicator, ports): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -151,7 +157,7 @@ def allTests(helper, communicator, ports): i = i + 1 else: - assert(False) + assert (False) i = i + 1 j = j + 1 diff --git a/python/test/Ice/info/AllTests.py b/python/test/Ice/info/AllTests.py index c03ca089e0d..9dc21fe8efb 100644 --- a/python/test/Ice/info/AllTests.py +++ b/python/test/Ice/info/AllTests.py @@ -2,30 +2,37 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading +import Ice +import Test +import sys +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + def getTCPEndpointInfo(info): - while(info): + while (info): if isinstance(info, Ice.TCPEndpointInfo): return info info = info.underlying + def getTCPConnectionInfo(info): - while(info): + while (info): if isinstance(info, Ice.TCPConnectionInfo): return info info = info.underlying + def allTests(helper, communicator): sys.stdout.write("testing proxy endpoint information... ") sys.stdout.flush() - p1 = communicator.stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" + \ - "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" + \ + p1 = communicator.stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" + + "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" + "opaque -e 1.8 -t 100 -v ABCD") endps = p1.ice_getEndpoints() @@ -40,9 +47,9 @@ def allTests(helper, communicator): test(tcpEndpoint.compress) test(not tcpEndpoint.datagram()) test((tcpEndpoint.type() == Ice.TCPEndpointType and not tcpEndpoint.secure()) or - (tcpEndpoint.type() == Ice.SSLEndpointType and tcpEndpoint.secure()) or # SSL - (tcpEndpoint.type() == Ice.WSEndpointType and not tcpEndpoint.secure()) or # WS - (tcpEndpoint.type() == Ice.WSSEndpointType and tcpEndpoint.secure())) # WS + (tcpEndpoint.type() == Ice.SSLEndpointType and tcpEndpoint.secure()) or # SSL + (tcpEndpoint.type() == Ice.WSEndpointType and not tcpEndpoint.secure()) or # WS + (tcpEndpoint.type() == Ice.WSSEndpointType and tcpEndpoint.secure())) # WS test((tcpEndpoint.type() == Ice.TCPEndpointType and isinstance(endpoint, Ice.TCPEndpointInfo)) or (tcpEndpoint.type() == Ice.SSLEndpointType and isinstance(endpoint, Ice.SSLEndpointInfo)) or (tcpEndpoint.type() == Ice.WSEndpointType and isinstance(endpoint, Ice.WSEndpointInfo)) or @@ -72,7 +79,7 @@ def allTests(helper, communicator): host = "::1" if communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 else "127.0.0.1" communicator.getProperties().setProperty("TestAdapter.Endpoints", "tcp -h \"" + host + - "\" -t 15000:udp -h \"" + host + "\"") + "\" -t 15000:udp -h \"" + host + "\"") adapter = communicator.createObjectAdapter("TestAdapter") endpoints = adapter.getEndpoints() test(len(endpoints) == 2) @@ -173,13 +180,13 @@ def allTests(helper, communicator): test(ctx["remotePort"] == str(tcpinfo.localPort)) test(ctx["localPort"] == str(tcpinfo.remotePort)) - if(base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"): + if (base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"): test(isinstance(info, Ice.WSConnectionInfo)) test(info.headers["Upgrade"] == "websocket") test(info.headers["Connection"] == "Upgrade") test(info.headers["Sec-WebSocket-Protocol"] == "ice.zeroc.com") - test("Sec-WebSocket-Accept" in info.headers); + test("Sec-WebSocket-Accept" in info.headers) test(ctx["ws.Upgrade"] == "websocket") test(ctx["ws.Connection"] == "Upgrade") diff --git a/python/test/Ice/info/TestI.py b/python/test/Ice/info/TestI.py index 1bd913e3630..f5c2371f53f 100644 --- a/python/test/Ice/info/TestI.py +++ b/python/test/Ice/info/TestI.py @@ -2,21 +2,25 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test import time + def getIPEndpointInfo(info): - while(info): + while (info): if isinstance(info, Ice.IPEndpointInfo): return info info = info.underlying + def getIPConnectionInfo(info): - while(info): + while (info): if isinstance(info, Ice.IPConnectionInfo): return info info = info.underlying + class MyDerivedClassI(Test.TestIntf): def __init__(self): self.ctx = None @@ -31,15 +35,15 @@ def getEndpointInfoAsContext(self, current): if info.compress: ctx["compress"] = "true" else: - ctx["compress"] ="false" + ctx["compress"] = "false" if info.datagram(): ctx["datagram"] = "true" else: - ctx["datagram"] ="false" + ctx["datagram"] = "false" if info.secure(): ctx["secure"] = "true" else: - ctx["secure"] ="false" + ctx["secure"] = "false" ctx["type"] = str(info.type()) ctx["host"] = info.host @@ -63,7 +67,7 @@ def getConnectionInfoAsContext(self, current): if info.incoming: ctx["incoming"] = "true" else: - ctx["incoming"] ="false" + ctx["incoming"] = "false" ctx["localAddress"] = ipinfo.localAddress ctx["localPort"] = str(ipinfo.localPort) diff --git a/python/test/Ice/inheritance/AllTests.py b/python/test/Ice/inheritance/AllTests.py index 3d63e0039c2..b3b05680e23 100644 --- a/python/test/Ice/inheritance/AllTests.py +++ b/python/test/Ice/inheritance/AllTests.py @@ -2,12 +2,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys +import Ice +import Test +import sys + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() diff --git a/python/test/Ice/inheritance/TestI.py b/python/test/Ice/inheritance/TestI.py index b569b745483..f6e2fce75c0 100644 --- a/python/test/Ice/inheritance/TestI.py +++ b/python/test/Ice/inheritance/TestI.py @@ -2,24 +2,30 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test + class IAI(Test.MA.IA): def iaop(self, p, current=None): return p + class IB1I(Test.MB.IB1, IAI): def ib1op(self, p, current=None): return p + class IB2I(Test.MB.IB2, IAI): def ib2op(self, p, current=None): return p + class ICI(Test.MA.IC, IB1I, IB2I): def icop(self, p, current=None): return p + class InitialI(Test.Initial): def __init__(self, adapter): self._ia = Test.MA.IAPrx.uncheckedCast(adapter.addWithUUID(IAI())) diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py index 1d58c08d817..769a8bfb0e1 100644 --- a/python/test/Ice/location/AllTests.py +++ b/python/test/Ice/location/AllTests.py @@ -2,16 +2,21 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys +import Ice +import Test +import sys + class HelloI(Test.Hello): def sayHello(self, current=None): pass + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): ref = "ServerManager:{0}".format(helper.getTestEndpoint()) manager = Test.ServerManagerPrx.checkedCast(communicator.stringToProxy(ref)) diff --git a/python/test/Ice/location/Server.py b/python/test/Ice/location/Server.py index 624e395d974..8c84e9c8925 100755 --- a/python/test/Ice/location/Server.py +++ b/python/test/Ice/location/Server.py @@ -75,7 +75,7 @@ def __init__(self, registry, initData, helper): self._communicators = [] self._initData = initData self._nextPort = 1 - self._helper = helper; + self._helper = helper self._initData.properties.setProperty("TestAdapter.AdapterId", "TestAdapter") self._initData.properties.setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter") self._initData.properties.setProperty("TestAdapter2.AdapterId", "TestAdapter2") diff --git a/python/test/Ice/objects/AllTests.py b/python/test/Ice/objects/AllTests.py index 83d1d1a91ef..0d6f099c8c3 100644 --- a/python/test/Ice/objects/AllTests.py +++ b/python/test/Ice/objects/AllTests.py @@ -2,7 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, TestI, sys +import Ice +import Test +import TestI +import sys + def MyValueFactory(type): if type == '::Test::B': @@ -19,12 +23,14 @@ def MyValueFactory(type): return TestI.II() elif type == '::Test::J': return TestI.JI() - assert(False) # Should never be reached + assert (False) # Should never be reached + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): communicator.getValueFactoryManager().add(MyValueFactory, '::Test::B') communicator.getValueFactoryManager().add(MyValueFactory, '::Test::C') @@ -101,7 +107,7 @@ def allTests(helper, communicator): test(v1[0].data == "l") test(v2[0].data == "l") - v1, v2 = initial.opValueMap({"l":Test.L("l")}) + v1, v2 = initial.opValueMap({"l": Test.L("l")}) test(v1["l"].data == "l") test(v2["l"].data == "l") print("ok") @@ -212,12 +218,12 @@ def allTests(helper, communicator): sys.stdout.write("testing recursive type... ") sys.stdout.flush() top = Test.Recursive() - p = top; - depth = 0; + p = top + depth = 0 try: while depth <= 700: p.v = Test.Recursive() - p = p.v; + p = p.v if (depth < 10 and (depth % 10) == 0) or \ (depth < 1000 and (depth % 100) == 0) or \ (depth < 10000 and (depth % 1000) == 0) or \ diff --git a/python/test/Ice/objects/Server.py b/python/test/Ice/objects/Server.py index ad621a7c812..e81ca98ad16 100755 --- a/python/test/Ice/objects/Server.py +++ b/python/test/Ice/objects/Server.py @@ -16,7 +16,7 @@ def MyValueFactory(type): return TestI.JI() elif type == '::Test::H': return TestI.HI() - assert(False) # Should never be reached + assert (False) # Should never be reached class Server(TestHelper): diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py index 9d73cbed18a..70114e05c64 100644 --- a/python/test/Ice/objects/TestI.py +++ b/python/test/Ice/objects/TestI.py @@ -2,7 +2,9 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test + class BI(Test.B): def __init__(self): @@ -15,6 +17,7 @@ def ice_preMarshal(self): def ice_postUnmarshal(self): self.postUnmarshalInvoked = True + class CI(Test.C): def __init__(self): self.preMarshalInvoked = False @@ -26,6 +29,7 @@ def ice_preMarshal(self): def ice_postUnmarshal(self): self.postUnmarshalInvoked = True + class DI(Test.D): def __init__(self): self.preMarshalInvoked = False @@ -37,6 +41,7 @@ def ice_preMarshal(self): def ice_postUnmarshal(self): self.postUnmarshalInvoked = True + class EI(Test.E): def __init__(self): Test.E.__init__(self, 1, "hello") @@ -44,6 +49,7 @@ def __init__(self): def checkValues(self, current=None): return self._i == 1 and self._s == "hello" + class FI(Test.F): def __init__(self, e=None): Test.F.__init__(self, e, e) @@ -51,14 +57,17 @@ def __init__(self, e=None): def checkValues(self, current=None): return self._e1 != None and self._e1 == self.e2 + class II(Ice.InterfaceByValue): def __init__(self): Ice.InterfaceByValue.__init__(self, "::Test::I") + class JI(Ice.InterfaceByValue): def __init__(self): Ice.InterfaceByValue.__init__(self, "::Test::J") + class InitialI(Test.Initial): def __init__(self, adapter): self._adapter = adapter @@ -69,12 +78,12 @@ def __init__(self, adapter): self._e = EI() self._f = FI(self._e) - self._b1.theA = self._b2 # Cyclic reference to another B - self._b1.theB = self._b1 # Self reference. + self._b1.theA = self._b2 # Cyclic reference to another B + self._b1.theB = self._b1 # Self reference. self._b1.theC = None # Null reference. - self._b2.theA = self._b2 # Self reference, using base. - self._b2.theB = self._b1 # Cyclic reference to another B + self._b2.theA = self._b2 # Self reference, using base. + self._b2.theB = self._b1 # Cyclic reference to another B self._b2.theC = self._c # Cyclic reference to a C. self._c.theB = self._b2 # Cyclic reference to a B. @@ -202,6 +211,7 @@ class UnexpectedObjectExceptionTestI(Test.UnexpectedObjectExceptionTest): def op(self, current=None): return Test.AlsoEmpty() + class F2I(Test.F2): def op(self, current=None): pass diff --git a/python/test/Ice/operations/AllTests.py b/python/test/Ice/operations/AllTests.py index e73b7d7022b..cf77ad99aa7 100644 --- a/python/test/Ice/operations/AllTests.py +++ b/python/test/Ice/operations/AllTests.py @@ -2,13 +2,22 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, Twoways, TwowaysFuture, Oneways, OnewaysFuture, BatchOneways, sys +import Ice +import Test +import Twoways +import TwowaysFuture +import Oneways +import OnewaysFuture +import BatchOneways +import sys import BatchOnewaysFuture + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): ref = "test:{0}".format(helper.getTestEndpoint()) base = communicator.stringToProxy(ref) diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py index 7c2ce9c019d..28fee177285 100644 --- a/python/test/Ice/operations/BatchOneways.py +++ b/python/test/Ice/operations/BatchOneways.py @@ -2,12 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, array, sys, time +import Ice +import Test +import array +import sys +import time + def test(b): if not b: raise RuntimeError('test assertion failed') + class BatchRequestInterceptorI(Ice.BatchRequestInterceptor): def __init__(self): @@ -29,7 +35,7 @@ def enqueue(self, request, count, size): if self._size + request.getSize() > 25000: f = request.getProxy().ice_flushBatchRequestsAsync() f.result() - self._size = 18 # header + self._size = 18 # header if self._enabled: self._lastRequestSize = request.getSize() @@ -42,6 +48,7 @@ def setEnabled(self, v): def count(self): return self._count + def batchOneways(p): bs1 = bytes([0 for x in range(0, 10 * 1024)]) @@ -53,18 +60,18 @@ def batchOneways(p): batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) - batch.ice_flushBatchRequests() # Empty flush + batch.ice_flushBatchRequests() # Empty flush if batch.ice_getConnection(): batch.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy) batch.ice_getCommunicator().flushBatchRequests(Ice.CompressBatch.BasedOnProxy) - p.opByteSOnewayCallCount() # Reset the call count + p.opByteSOnewayCallCount() # Reset the call count for i in range(30): batch.opByteSOneway(bs1) count = 0 - while count < 27: # 3 * 9 requests auto-flushed. + while count < 27: # 3 * 9 requests auto-flushed. count += p.opByteSOnewayCallCount() time.sleep(0.01) @@ -89,7 +96,7 @@ def batchOneways(p): batch2.ice_ping() identity = Ice.Identity() - identity.name = "invalid"; + identity.name = "invalid" batch3 = batch.ice_identity(identity) batch3.ice_ping() batch3.ice_flushBatchRequests() @@ -131,7 +138,7 @@ def batchOneways(p): batch.opByteSOneway(bs1) test(interceptor.count() == 3) - batch.opByteSOneway(bs1) # This should trigger the flush + batch.opByteSOneway(bs1) # This should trigger the flush batch.ice_ping() test(interceptor.count() == 2) diff --git a/python/test/Ice/operations/BatchOnewaysFuture.py b/python/test/Ice/operations/BatchOnewaysFuture.py index aad1179c801..186d667187a 100644 --- a/python/test/Ice/operations/BatchOnewaysFuture.py +++ b/python/test/Ice/operations/BatchOnewaysFuture.py @@ -2,12 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, array, sys, threading, time +import Ice +import Test +import array +import sys +import threading +import time + def test(b): if not b: raise RuntimeError('test assertion failed') + class Callback: def __init__(self): self._called = False @@ -24,23 +31,24 @@ def called(self): self._called = True self._cond.notify() + def batchOneways(p): bs1 = bytes([0 for x in range(0, 10 * 1024)]) batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) - f = batch.ice_flushBatchRequestsAsync() # Empty flush + f = batch.ice_flushBatchRequestsAsync() # Empty flush f.result() - test(batch.ice_flushBatchRequestsAsync().is_sent()) # Empty flush - test(batch.ice_flushBatchRequestsAsync().done()) # Empty flush - test(batch.ice_flushBatchRequestsAsync().is_sent_synchronously()) # Empty flush + test(batch.ice_flushBatchRequestsAsync().is_sent()) # Empty flush + test(batch.ice_flushBatchRequestsAsync().done()) # Empty flush + test(batch.ice_flushBatchRequestsAsync().is_sent_synchronously()) # Empty flush for i in range(30): batch.opByteSOnewayAsync(bs1) count = 0 - while count < 27: # 3 * 9 requests auto-flushed. + while count < 27: # 3 * 9 requests auto-flushed. count += p.opByteSOnewayCallCount() time.sleep(0.01) @@ -66,7 +74,7 @@ def batchOneways(p): test(batch2.ice_pingAsync().done() and not batch1.ice_pingAsync().exception()) identity = Ice.Identity() - identity.name = "invalid"; + identity.name = "invalid" batch3 = batch.ice_identity(identity) batch3.ice_ping() batch3.ice_flushBatchRequestsAsync().result() diff --git a/python/test/Ice/operations/Oneways.py b/python/test/Ice/operations/Oneways.py index bf6b9f232b6..c4ec71e3c93 100644 --- a/python/test/Ice/operations/Oneways.py +++ b/python/test/Ice/operations/Oneways.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, math, Test, array +import Ice +import math +import Test +import array + def test(b): if not b: raise RuntimeError('test assertion failed') + def oneways(helper, p): communicator = helper.communicator() p = Test.MyClassPrx.uncheckedCast(p.ice_oneway()) diff --git a/python/test/Ice/operations/OnewaysFuture.py b/python/test/Ice/operations/OnewaysFuture.py index 8abeaff871f..ff4367e194c 100644 --- a/python/test/Ice/operations/OnewaysFuture.py +++ b/python/test/Ice/operations/OnewaysFuture.py @@ -2,12 +2,15 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + def onewaysFuture(helper, proxy): communicator = helper.communicator() p = Test.MyClassPrx.uncheckedCast(proxy.ice_oneway()) diff --git a/python/test/Ice/operations/TestAMDCoroI.py b/python/test/Ice/operations/TestAMDCoroI.py index c2d67838904..055d43d0649 100755 --- a/python/test/Ice/operations/TestAMDCoroI.py +++ b/python/test/Ice/operations/TestAMDCoroI.py @@ -3,7 +3,12 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, threading, time, concurrent.futures +import os +import sys +import traceback +import threading +import time +import concurrent.futures import Ice slice_dir = Ice.getSliceDir() if not slice_dir: @@ -13,10 +18,12 @@ Ice.loadSlice("'-I" + slice_dir + "' Test.ice") import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class FutureThread(threading.Thread): def __init__(self, f, r): threading.Thread.__init__(self) @@ -27,6 +34,7 @@ def run(self): time.sleep(0.05) self.future.set_result(self.result) + class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.threads = [] @@ -123,7 +131,7 @@ def opBoolS(self, p1, p2, current=None): p3 = p1[0:] p3.extend(p2) r = p1[0:] - r.reverse(); + r.reverse() return Ice.Future.completed((r, p3)) def opShortIntLongS(self, p1, p2, p3, current=None): @@ -346,7 +354,7 @@ def opByteSOnewayCallCount(self, current=None): return Ice.Future.completed(count) def opDoubleMarshaling(self, p1, p2, current=None): - d = 1278312346.0 / 13.0; + d = 1278312346.0 / 13.0 test(p1 == d) for i in p2: test(i == d) @@ -407,11 +415,11 @@ def opMyStruct1(self, value, current=None): def opStringLiterals(self, current=None): return Ice.Future.completed([ - Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10, - Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, - Test.sw10, - Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, - Test.su0, Test.su1, Test.su2]) + Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10, + Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, + Test.sw10, + Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, + Test.su0, Test.su1, Test.su2]) def opWStringLiterals(self, current=None): return self.opStringLiterals(current) diff --git a/python/test/Ice/operations/TestAMDI.py b/python/test/Ice/operations/TestAMDI.py index 0786f43bff6..bce0b0e8365 100755 --- a/python/test/Ice/operations/TestAMDI.py +++ b/python/test/Ice/operations/TestAMDI.py @@ -3,7 +3,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, threading, time +import os +import sys +import traceback +import threading +import time import Ice slice_dir = Ice.getSliceDir() if not slice_dir: @@ -11,12 +15,15 @@ sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") -import Test, M +import Test +import M + def test(b): if not b: raise RuntimeError('test assertion failed') + class FutureThread(threading.Thread): def __init__(self, f, r): threading.Thread.__init__(self) @@ -27,6 +34,7 @@ def run(self): time.sleep(0.01) self.future.set_result(self.result) + class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.threads = [] @@ -109,7 +117,7 @@ def opBoolS(self, p1, p2, current=None): p3 = p1[0:] p3.extend(p2) r = p1[0:] - r.reverse(); + r.reverse() return Ice.Future.completed((r, p3)) def opShortIntLongS(self, p1, p2, p3, current=None): @@ -332,7 +340,7 @@ def opByteSOnewayCallCount(self, current=None): return Ice.Future.completed(count) def opDoubleMarshaling(self, p1, p2, current=None): - d = 1278312346.0 / 13.0; + d = 1278312346.0 / 13.0 test(p1 == d) for i in p2: test(i == d) @@ -393,11 +401,11 @@ def opMyStruct1(self, value, current=None): def opStringLiterals(self, current=None): return Ice.Future.completed([ - Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10, - Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, - Test.sw10, - Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, - Test.su0, Test.su1, Test.su2]) + Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10, + Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, + Test.sw10, + Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, + Test.su0, Test.su1, Test.su2]) def opWStringLiterals(self, current=None): return self.opStringLiterals(current) diff --git a/python/test/Ice/operations/TestI.py b/python/test/Ice/operations/TestI.py index 4322db0be7c..d58d5ecdbcc 100644 --- a/python/test/Ice/operations/TestI.py +++ b/python/test/Ice/operations/TestI.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading +import Ice +import Test +import sys +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.lock = threading.Lock() diff --git a/python/test/Ice/operations/Twoways.py b/python/test/Ice/operations/Twoways.py index 6f9a3a83464..877c5ca3086 100644 --- a/python/test/Ice/operations/Twoways.py +++ b/python/test/Ice/operations/Twoways.py @@ -2,13 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, math, Test, array, sys +import Ice +import math +import Test +import array +import sys from sys import version_info + def test(b): if not b: raise RuntimeError('test assertion failed') + def twoways(helper, p): communicator = helper.communicator() @@ -186,7 +192,7 @@ def twoways(helper, p): pass try: - r, s, i, l = p.opShortIntLong(-32768 -1, 0, 0) + r, s, i, l = p.opShortIntLong(-32768 - 1, 0, 0) test(False) except ValueError: pass @@ -226,13 +232,13 @@ def twoways(helper, p): test(math.isnan(r) and math.isnan(f) and math.isnan(d)) try: - r, f, d = p.opFloatDouble(3.402823466E38*2, 0.0) + r, f, d = p.opFloatDouble(3.402823466E38 * 2, 0.0) test(False) except ValueError: pass try: - r, f, d = p.opFloatDouble(-3.402823466E38*2, 0.0) + r, f, d = p.opFloatDouble(-3.402823466E38 * 2, 0.0) test(False) except ValueError: pass @@ -571,7 +577,7 @@ def twoways(helper, p): # # opShortIntLongSS # - ssi = ((1,2,5), (13,), ()) + ssi = ((1, 2, 5), (13,), ()) isi = ((24, 98), (42,)) lsi = ((496, 1729),) @@ -813,8 +819,8 @@ def twoways(helper, p): # # opByteBoolDS # - dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True }) - dsi2 = ({ 100: False, 101: False },) + dsi1 = ({10: True, 100: False}, {10: True, 11: False, 101: True}) + dsi2 = ({100: False, 101: False},) ro, do = p.opByteBoolDS(dsi1, dsi2) @@ -841,8 +847,8 @@ def twoways(helper, p): # # opShortIntDS # - dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 }) - dsi2 = ({ 100: -1001 },) + dsi1 = ({110: -1, 1100: 123123}, {110: -1, 111: -100, 1101: 0}) + dsi2 = ({100: -1001},) ro, do = p.opShortIntDS(dsi1, dsi2) @@ -869,8 +875,8 @@ def twoways(helper, p): # # opLongFloatDS # - dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 }) - dsi2 = ({ 999999140: 3.14 },) + dsi1 = ({999999110: -1.1, 999999111: 123123.2}, {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}) + dsi2 = ({999999140: 3.14},) ro, do = p.opLongFloatDS(dsi1, dsi2) @@ -898,8 +904,8 @@ def twoways(helper, p): # opStringStringDS # - dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" }) - dsi2 = ({ "f00": "ABC -3.14" },) + dsi1 = ({"foo": "abc -1.1", "bar": "abc 123123.2"}, {"foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5"}) + dsi2 = ({"f00": "ABC -3.14"},) ro, do = p.opStringStringDS(dsi1, dsi2) @@ -927,11 +933,11 @@ def twoways(helper, p): # opStringMyEnumDS # dsi1 = ( - { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 }, - { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 } - ) + {"abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2}, + {"abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2} + ) - dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },) + dsi2 = ({"Goodbye": Test.MyEnum.enum1},) ro, do = p.opStringMyEnumDS(dsi1, dsi2) @@ -958,8 +964,8 @@ def twoways(helper, p): # # opMyEnumStringDS # - dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}) - dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },) + dsi1 = ({Test.MyEnum.enum1: 'abc'}, {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}) + dsi2 = ({Test.MyEnum.enum1: 'Goodbye'},) ro, do = p.opMyEnumStringDS(dsi1, dsi2) @@ -989,10 +995,10 @@ def twoways(helper, p): s23 = Test.MyStruct(2, 3) dsi1 = ( - { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 }, - { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 } - ) - dsi2 = ({ s23: Test.MyEnum.enum3 },) + {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}, + {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2} + ) + dsi2 = ({s23: Test.MyEnum.enum3},) ro, do = p.opMyStructMyEnumDS(dsi1, dsi2) @@ -1017,10 +1023,10 @@ def twoways(helper, p): test(do[2][s23] == Test.MyEnum.enum2) # - #opByteByteSD + # opByteByteSD # - sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) } - sdi2 = { 0xf1: (0xf2, 0xf3) } + sdi1 = {0x01: (0x01, 0x11), 0x22: (0x12,)} + sdi2 = {0xf1: (0xf2, 0xf3)} ro, do = p.opByteByteSD(sdi1, sdi2) @@ -1041,8 +1047,8 @@ def twoways(helper, p): # # opBoolBoolSD # - sdi1 = { False: (True, False), True: (False, True, True) } - sdi2 = { False: (True, False) } + sdi1 = {False: (True, False), True: (False, True, True)} + sdi2 = {False: (True, False)} ro, do = p.opBoolBoolSD(sdi1, sdi2) @@ -1062,8 +1068,8 @@ def twoways(helper, p): # # opShortShortSD # - sdi1 = { 1: (1, 2, 3), 2: (4, 5) } - sdi2 = { 4: (6, 7) } + sdi1 = {1: (1, 2, 3), 2: (4, 5)} + sdi2 = {4: (6, 7)} ro, do = p.opShortShortSD(sdi1, sdi2) @@ -1086,8 +1092,8 @@ def twoways(helper, p): # # opIntIntSD # - sdi1 = { 100: (100, 200, 300), 200: (400, 500) } - sdi2 = { 400: (600, 700) } + sdi1 = {100: (100, 200, 300), 200: (400, 500)} + sdi2 = {400: (600, 700)} ro, do = p.opIntIntSD(sdi1, sdi2) @@ -1110,8 +1116,8 @@ def twoways(helper, p): # # opLongLongSD # - sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) } - sdi2 = { 999999992: (999999110, 999999120) } + sdi1 = {999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130)} + sdi2 = {999999992: (999999110, 999999120)} ro, do = p.opLongLongSD(sdi1, sdi2) @@ -1134,8 +1140,8 @@ def twoways(helper, p): # # opStringFloatSD # - sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) } - sdi2 = { "aBc": (-3.14, 3.14) } + sdi1 = {"abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61)} + sdi2 = {"aBc": (-3.14, 3.14)} ro, do = p.opStringFloatSD(sdi1, sdi2) @@ -1159,8 +1165,8 @@ def twoways(helper, p): # # opStringDoubleSD # - sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) } - sdi2 = { "": (1.6E10, 1.7E10) } + sdi1 = {"Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10)} + sdi2 = {"": (1.6E10, 1.7E10)} ro, do = p.opStringDoubleSD(sdi1, sdi2) @@ -1183,8 +1189,8 @@ def twoways(helper, p): # # opStringStringSD # - sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") } - sdi2 = { "ghi": ("and", "xor") } + sdi1 = {"abc": ("abc", "de", "fghi"), "def": ("xyz", "or")} + sdi2 = {"ghi": ("and", "xor")} ro, do = p.opStringStringSD(sdi1, sdi2) @@ -1208,10 +1214,10 @@ def twoways(helper, p): # opMyEnumMyEnumSD # sdi1 = { - Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2), - Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2) - } - sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) } + Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2), + Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2) + } + sdi2 = {Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3)} ro, do = p.opMyEnumMyEnumSD(sdi1, sdi2) @@ -1234,7 +1240,7 @@ def twoways(helper, p): # # opIntS # - lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 ) + lengths = (0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000) for l in lengths: s = [] for i in range(l): @@ -1268,7 +1274,7 @@ def twoways(helper, p): # Test implicit context propagation # if p.ice_getConnection(): - impls = ( 'Shared', 'PerThread' ) + impls = ('Shared', 'PerThread') for i in impls: initData = Ice.InitializationData() initData.properties = communicator.getProperties().clone() @@ -1368,6 +1374,6 @@ def twoways(helper, p): p.opMDict1() - p1 = { "test": "test" } + p1 = {"test": "test"} (p3, p2) = p.opMDict2(p1) test(p3["test"] == "test" and p2["test"] == "test") diff --git a/python/test/Ice/operations/TwowaysFuture.py b/python/test/Ice/operations/TwowaysFuture.py index 722831ae5d1..5515404faee 100644 --- a/python/test/Ice/operations/TwowaysFuture.py +++ b/python/test/Ice/operations/TwowaysFuture.py @@ -2,12 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, math, sys, threading +import Ice +import Test +import math +import sys +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + class CallbackBase: def __init__(self): self._called = False @@ -24,6 +30,7 @@ def called(self): self._called = True self._cond.notify() + class Callback(CallbackBase): def __init__(self, communicator=None): CallbackBase.__init__(self) @@ -249,59 +256,59 @@ def opByteSS(self, f): def opBoolSS(self, f): try: (rso, bso) = f.result() - test(len(bso) == 4); - test(len(bso[0]) == 1); - test(bso[0][0]); - test(len(bso[1]) == 1); - test(not bso[1][0]); - test(len(bso[2]) == 2); - test(bso[2][0]); - test(bso[2][1]); - test(len(bso[3]) == 3); - test(not bso[3][0]); - test(not bso[3][1]); - test(bso[3][2]); - test(len(rso) == 3); - test(len(rso[0]) == 2); - test(rso[0][0]); - test(rso[0][1]); - test(len(rso[1]) == 1); - test(not rso[1][0]); - test(len(rso[2]) == 1); - test(rso[2][0]); - self.called(); + test(len(bso) == 4) + test(len(bso[0]) == 1) + test(bso[0][0]) + test(len(bso[1]) == 1) + test(not bso[1][0]) + test(len(bso[2]) == 2) + test(bso[2][0]) + test(bso[2][1]) + test(len(bso[3]) == 3) + test(not bso[3][0]) + test(not bso[3][1]) + test(bso[3][2]) + test(len(rso) == 3) + test(len(rso[0]) == 2) + test(rso[0][0]) + test(rso[0][1]) + test(len(rso[1]) == 1) + test(not rso[1][0]) + test(len(rso[2]) == 1) + test(rso[2][0]) + self.called() except: test(False) def opShortIntLongSS(self, f): try: (rso, sso, iso, lso) = f.result() - test(len(rso) == 1); - test(len(rso[0]) == 2); - test(rso[0][0] == 496); - test(rso[0][1] == 1729); - test(len(sso) == 3); - test(len(sso[0]) == 3); - test(sso[0][0] == 1); - test(sso[0][1] == 2); - test(sso[0][2] == 5); - test(len(sso[1]) == 1); - test(sso[1][0] == 13); - test(len(sso[2]) == 0); - test(len(iso) == 2); - test(len(iso[0]) == 1); - test(iso[0][0] == 42); - test(len(iso[1]) == 2); - test(iso[1][0] == 24); - test(iso[1][1] == 98); - test(len(lso) == 2); - test(len(lso[0]) == 2); - test(lso[0][0] == 496); - test(lso[0][1] == 1729); - test(len(lso[1]) == 2); - test(lso[1][0] == 496); - test(lso[1][1] == 1729); - self.called(); + test(len(rso) == 1) + test(len(rso[0]) == 2) + test(rso[0][0] == 496) + test(rso[0][1] == 1729) + test(len(sso) == 3) + test(len(sso[0]) == 3) + test(sso[0][0] == 1) + test(sso[0][1] == 2) + test(sso[0][2] == 5) + test(len(sso[1]) == 1) + test(sso[1][0] == 13) + test(len(sso[2]) == 0) + test(len(iso) == 2) + test(len(iso[0]) == 1) + test(iso[0][0] == 42) + test(len(iso[1]) == 2) + test(iso[1][0] == 24) + test(iso[1][1] == 98) + test(len(lso) == 2) + test(len(lso[0]) == 2) + test(lso[0][0] == 496) + test(lso[0][1] == 1729) + test(len(lso[1]) == 2) + test(lso[1][0] == 496) + test(lso[1][1] == 1729) + self.called() except: test(False) @@ -851,6 +858,7 @@ def opNonmutating(self, f): def opDerived(self, f): self.called() + def twowaysFuture(helper, p): communicator = helper.communicator() f = p.ice_pingAsync() @@ -968,9 +976,9 @@ def twowaysFuture(helper, p): cb = Callback() p.opBoolSSAsync(bsi1, bsi2).add_done_callback(cb.opBoolSS) - cb.check(); + cb.check() - ssi = ((1,2,5), (13,), ()) + ssi = ((1, 2, 5), (13,), ()) isi = ((24, 98), (42,)) lsi = ((496, 1729),) @@ -1053,47 +1061,47 @@ def twowaysFuture(helper, p): p.opMyStructMyEnumDAsync(di1, di2).add_done_callback(cb.opMyStructMyEnumD) cb.check() - dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True }) - dsi2 = ({ 100: False, 101: False },) + dsi1 = ({10: True, 100: False}, {10: True, 11: False, 101: True}) + dsi2 = ({100: False, 101: False},) cb = Callback() p.opByteBoolDSAsync(dsi1, dsi2).add_done_callback(cb.opByteBoolDS) cb.check() - dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 }) - dsi2 = ({ 100: -1001 },) + dsi1 = ({110: -1, 1100: 123123}, {110: -1, 111: -100, 1101: 0}) + dsi2 = ({100: -1001},) cb = Callback() p.opShortIntDSAsync(dsi1, dsi2).add_done_callback(cb.opShortIntDS) cb.called() - dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 }) - dsi2 = ({ 999999140: 3.14 },) + dsi1 = ({999999110: -1.1, 999999111: 123123.2}, {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}) + dsi2 = ({999999140: 3.14},) cb = Callback() p.opLongFloatDSAsync(dsi1, dsi2).add_done_callback(cb.opLongFloatDS) cb.called() - dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" }) - dsi2 = ({ "f00": "ABC -3.14" },) + dsi1 = ({"foo": "abc -1.1", "bar": "abc 123123.2"}, {"foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5"}) + dsi2 = ({"f00": "ABC -3.14"},) cb = Callback() p.opStringStringDSAsync(dsi1, dsi2).add_done_callback(cb.opStringStringDS) cb.called() dsi1 = ( - { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 }, - { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 } - ) + {"abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2}, + {"abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2} + ) - dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },) + dsi2 = ({"Goodbye": Test.MyEnum.enum1},) cb = Callback() p.opStringMyEnumDSAsync(dsi1, dsi2).add_done_callback(cb.opStringMyEnumDS) cb.called() - dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}) - dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },) + dsi1 = ({Test.MyEnum.enum1: 'abc'}, {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}) + dsi2 = ({Test.MyEnum.enum1: 'Goodbye'},) cb = Callback() p.opMyEnumStringDSAsync(dsi1, dsi2).add_done_callback(cb.opMyEnumStringDS) @@ -1106,82 +1114,82 @@ def twowaysFuture(helper, p): s23 = Test.MyStruct(2, 3) dsi1 = ( - { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 }, - { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 } - ) - dsi2 = ({ s23: Test.MyEnum.enum3 },) + {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}, + {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2} + ) + dsi2 = ({s23: Test.MyEnum.enum3},) cb = Callback() p.opMyStructMyEnumDSAsync(dsi1, dsi2).add_done_callback(cb.opMyStructMyEnumDS) cb.called() - sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) } - sdi2 = { 0xf1: (0xf2, 0xf3) } + sdi1 = {0x01: (0x01, 0x11), 0x22: (0x12,)} + sdi2 = {0xf1: (0xf2, 0xf3)} cb = Callback() p.opByteByteSDAsync(sdi1, sdi2).add_done_callback(cb.opByteByteSD) cb.called() - sdi1 = { False: (True, False), True: (False, True, True) } - sdi2 = { False: (True, False) } + sdi1 = {False: (True, False), True: (False, True, True)} + sdi2 = {False: (True, False)} cb = Callback() p.opBoolBoolSDAsync(sdi1, sdi2).add_done_callback(cb.opBoolBoolSD) cb.called() - sdi1 = { 1: (1, 2, 3), 2: (4, 5) } - sdi2 = { 4: (6, 7) } + sdi1 = {1: (1, 2, 3), 2: (4, 5)} + sdi2 = {4: (6, 7)} cb = Callback() p.opShortShortSDAsync(sdi1, sdi2).add_done_callback(cb.opShortShortSD) cb.called() - sdi1 = { 100: (100, 200, 300), 200: (400, 500) } - sdi2 = { 400: (600, 700) } + sdi1 = {100: (100, 200, 300), 200: (400, 500)} + sdi2 = {400: (600, 700)} cb = Callback() p.opIntIntSDAsync(sdi1, sdi2).add_done_callback(cb.opIntIntSD) cb.called() - sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) } - sdi2 = { 999999992: (999999110, 999999120) } + sdi1 = {999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130)} + sdi2 = {999999992: (999999110, 999999120)} cb = Callback() p.opLongLongSDAsync(sdi1, sdi2).add_done_callback(cb.opLongLongSD) cb.called() - sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) } - sdi2 = { "aBc": (-3.14, 3.14) } + sdi1 = {"abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61)} + sdi2 = {"aBc": (-3.14, 3.14)} cb = Callback() p.opStringFloatSDAsync(sdi1, sdi2).add_done_callback(cb.opStringFloatSD) cb.called() - sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) } - sdi2 = { "": (1.6E10, 1.7E10) } + sdi1 = {"Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10)} + sdi2 = {"": (1.6E10, 1.7E10)} cb = Callback() p.opStringDoubleSDAsync(sdi1, sdi2).add_done_callback(cb.opStringDoubleSD) cb.called() - sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") } - sdi2 = { "ghi": ("and", "xor") } + sdi1 = {"abc": ("abc", "de", "fghi"), "def": ("xyz", "or")} + sdi2 = {"ghi": ("and", "xor")} cb = Callback() p.opStringStringSDAsync(sdi1, sdi2).add_done_callback(cb.opStringStringSD) cb.called() sdi1 = { - Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2), - Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2) - } - sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) } + Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2), + Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2) + } + sdi2 = {Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3)} cb = Callback() p.opMyEnumMyEnumSDAsync(sdi1, sdi2).add_done_callback(cb.opMyEnumMyEnumSD) cb.called() - lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 ) + lengths = (0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000) for l in lengths: s = [] for i in range(l): @@ -1216,7 +1224,7 @@ def twowaysFuture(helper, p): # Test implicit context propagation # if p.ice_getConnection(): - impls = ( 'Shared', 'PerThread' ) + impls = ('Shared', 'PerThread') for i in impls: initData = Ice.InitializationData() initData.properties = communicator.getProperties().clone() diff --git a/python/test/Ice/optional/AllTests.py b/python/test/Ice/optional/AllTests.py index 28112cc7b74..5f57214f27c 100644 --- a/python/test/Ice/optional/AllTests.py +++ b/python/test/Ice/optional/AllTests.py @@ -2,12 +2,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys +import Ice +import Test +import sys + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -70,14 +74,14 @@ def allTests(helper, communicator): ss = Test.SmallStruct() fs = Test.FixedStruct(78) vs = Test.VarStruct("hello") - mo1 = Test.MultiOptional(15, True, 19, 78, 99, 5.5, 1.0, "test", Test.MyEnum.MyEnumMember, \ - Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test")), \ - None, [5], ["test", "test2"], {4:3}, {"test":10}, fs, vs, [1], \ - [Test.MyEnum.MyEnumMember, Test.MyEnum.MyEnumMember], \ - [ fs ], [ vs ], [ oo1 ], \ - [ Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test")) ], \ - {4:Test.MyEnum.MyEnumMember}, {4:fs}, {5:vs}, {5:Test.OneOptional(15)}, \ - {5:Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test"))}, \ + mo1 = Test.MultiOptional(15, True, 19, 78, 99, 5.5, 1.0, "test", Test.MyEnum.MyEnumMember, + Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test")), + None, [5], ["test", "test2"], {4: 3}, {"test": 10}, fs, vs, [1], + [Test.MyEnum.MyEnumMember, Test.MyEnum.MyEnumMember], + [fs], [vs], [oo1], + [Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test"))], + {4: Test.MyEnum.MyEnumMember}, {4: fs}, {5: vs}, {5: Test.OneOptional(15)}, + {5: Test.MyInterfacePrx.uncheckedCast(communicator.stringToProxy("test"))}, [False, True, False]) test(mo1.a == 15) @@ -319,9 +323,9 @@ def allTests(helper, communicator): r = initial.ice_encodingVersion(Ice.Encoding_1_0).returnOptionalClass(True) test(r is Ice.Unset) - recursive1 = [ Test.Recursive() ] - recursive2 = [ Test.Recursive() ] - recursive1[0].value = recursive2; + recursive1 = [Test.Recursive()] + recursive2 = [Test.Recursive()] + recursive1[0].value = recursive2 outer = Test.Recursive() outer.value = recursive1 @@ -445,8 +449,8 @@ def allTests(helper, communicator): d.ds = "test" d.seq = ["test1", "test2", "test3", "test4"] d.ao = Test.A(18) - d.requiredB = 14; - d.requiredA = 14; + d.requiredB = 14 + d.requiredA = 14 initial2.opClassAndUnknownOptional(Test.A(), d) print("ok") @@ -531,7 +535,7 @@ def allTests(helper, communicator): p1 = Test.SmallStruct(56) (p2, p3) = initial.opSmallStruct(p1) test(p2 == p1 and p3 == p1) - (p2, p3) = initial.opSmallStruct(None) # Test null struct + (p2, p3) = initial.opSmallStruct(None) # Test null struct test(p2.m == 0 and p3.m == 0) f = initial.opSmallStructAsync(p1) (p2, p3) = f.result() @@ -699,7 +703,7 @@ def allTests(helper, communicator): (p2, p3) = initial.opIntIntDict(Ice.Unset) test(p2 is Ice.Unset and p3 is Ice.Unset) - p1 = {1:2, 2:3} + p1 = {1: 2, 2: 3} (p2, p3) = initial.opIntIntDict(p1) test(p2 == p1 and p3 == p1) f = initial.opIntIntDictAsync(p1) @@ -708,7 +712,7 @@ def allTests(helper, communicator): (p2, p3) = initial.opStringIntDict(Ice.Unset) test(p2 is Ice.Unset and p3 is Ice.Unset) - p1 = {"1":2, "2":3} + p1 = {"1": 2, "2": 3} (p2, p3) = initial.opStringIntDict(p1) test(p2 == p1 and p3 == p1) f = initial.opStringIntDictAsync(p1) @@ -717,12 +721,12 @@ def allTests(helper, communicator): (p2, p3) = initial.opIntOneOptionalDict(Ice.Unset) test(p2 is Ice.Unset and p3 is Ice.Unset) - p1 = {1:Test.OneOptional(58), 2:Test.OneOptional(59)} + p1 = {1: Test.OneOptional(58), 2: Test.OneOptional(59)} (p2, p3) = initial.opIntOneOptionalDict(p1) - test(p2[1].a == 58 and p3[1].a == 58); + test(p2[1].a == 58 and p3[1].a == 58) f = initial.opIntOneOptionalDictAsync(p1) (p2, p3) = f.result() - test(p2[1].a == 58 and p3[1].a == 58); + test(p2[1].a == 58 and p3[1].a == 58) try: (p1, p2, p3) = initial.opRequiredAfterOptional(1, 2, 3) @@ -779,8 +783,8 @@ def allTests(helper, communicator): test(ex.o is Ice.Unset) test(ex.ss is Ice.Unset) test(ex.o2 is Ice.Unset) - test(ex.d1 == "d1"); - test(ex.d2 == "d2"); + test(ex.d1 == "d1") + test(ex.d2 == "d2") try: initial.opDerivedException(30, "test2", Test.OneOptional(53)) @@ -790,8 +794,8 @@ def allTests(helper, communicator): test(ex.o.a == 53) test(ex.ss == "test2") test(ex.o2 == ex.o) - test(ex.d1 == "d1"); - test(ex.d2 == "d2"); + test(ex.d1 == "d1") + test(ex.d2 == "d2") try: initial.opRequiredException(Ice.Unset, Ice.Unset, Ice.Unset) @@ -816,15 +820,15 @@ def allTests(helper, communicator): sys.stdout.write("testing optionals with marshaled results... ") sys.stdout.flush() - test(initial.opMStruct1() != Ice.Unset); - test(initial.opMDict1() != Ice.Unset); - test(initial.opMSeq1() != Ice.Unset); - test(initial.opMG1() != Ice.Unset); + test(initial.opMStruct1() != Ice.Unset) + test(initial.opMDict1() != Ice.Unset) + test(initial.opMSeq1() != Ice.Unset) + test(initial.opMG1() != Ice.Unset) - (p3, p2) = initial.opMStruct2(Ice.Unset); - test(p2 == Ice.Unset and p3 == Ice.Unset); + (p3, p2) = initial.opMStruct2(Ice.Unset) + test(p2 == Ice.Unset and p3 == Ice.Unset) - p1 = Test.SmallStruct(); + p1 = Test.SmallStruct() (p3, p2) = initial.opMStruct2(p1) test(p2 == p1 and p3 == p1) @@ -832,22 +836,22 @@ def allTests(helper, communicator): test(p2 == Ice.Unset and p3 == Ice.Unset) p1 = ["hello"] - (p3, p2) = initial.opMSeq2(p1); + (p3, p2) = initial.opMSeq2(p1) test(p2[0] == "hello" and p3[0] == "hello") (p3, p2) = initial.opMDict2(Ice.Unset) test(p2 == Ice.Unset and p3 == Ice.Unset) - p1 = {"test" : 54} + p1 = {"test": 54} (p3, p2) = initial.opMDict2(p1) test(p2["test"] == 54 and p3["test"] == 54) (p3, p2) = initial.opMG2(Ice.Unset) test(p2 == Ice.Unset and p3 == Ice.Unset) - p1 = Test.G(); - (p3, p2) = initial.opMG2(p1); - test(p2 != Ice.Unset and p3 != Ice.Unset and p3 == p2); + p1 = Test.G() + (p3, p2) = initial.opMG2(p1) + test(p2 != Ice.Unset and p3 != Ice.Unset and p3 == p2) print("ok") diff --git a/python/test/Ice/packagemd/AllTests.py b/python/test/Ice/packagemd/AllTests.py index caa036067ce..4f2bf20a6aa 100644 --- a/python/test/Ice/packagemd/AllTests.py +++ b/python/test/Ice/packagemd/AllTests.py @@ -2,12 +2,22 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, Test1, testpkg, modpkg, sys, threading, time, traceback +import Ice +import Test +import Test1 +import testpkg +import modpkg +import sys +import threading +import time +import traceback + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): sys.stdout.write("testing stringToProxy... ") diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py index d03ce50868a..aa0f6d66e92 100644 --- a/python/test/Ice/proxy/AllTests.py +++ b/python/test/Ice/proxy/AllTests.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading +import Ice +import Test +import sys +import threading + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator, collocated): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -25,19 +30,19 @@ def allTests(helper, communicator, collocated): test(base) b1 = communicator.stringToProxy("test") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy("test ") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy(" test ") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy(" test") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy("'test -f facet'") - test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) try: b1 = communicator.stringToProxy("\"test -f facet'") @@ -45,13 +50,13 @@ def allTests(helper, communicator, collocated): except Ice.ProxyParseException: pass b1 = communicator.stringToProxy("\"test -f facet\"") - test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy("\"test -f facet@test\"") - test(b1.ice_getIdentity().name == "test -f facet@test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test -f facet@test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) b1 = communicator.stringToProxy("\"test -f facet@test @test\"") - test(b1.ice_getIdentity().name == "test -f facet@test @test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test -f facet@test @test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getFacet()) == 0) try: b1 = communicator.stringToProxy("test test") @@ -82,7 +87,7 @@ def allTests(helper, communicator, collocated): test(b1.ice_getIdentity().name == "test\b\f\n\r\t\'\"\\test" and len(b1.ice_getIdentity().category) == 0) b1 = communicator.stringToProxy("category/test") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and len(b1.ice_getAdapterId()) == 0) b1 = communicator.stringToProxy("test:tcp --sourceAddress \"::1\"") @@ -92,7 +97,7 @@ def allTests(helper, communicator, collocated): test(b1 == communicator.stringToProxy(b1.ice_toString())) b1 = communicator.stringToProxy("test@adapter") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getAdapterId() == "adapter") try: b1 = communicator.stringToProxy("id@adapter test") @@ -100,35 +105,35 @@ def allTests(helper, communicator, collocated): except Ice.ProxyParseException: pass b1 = communicator.stringToProxy("category/test@adapter") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and b1.ice_getAdapterId() == "adapter") b1 = communicator.stringToProxy("category/test@adapter:tcp") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and b1.ice_getAdapterId() == "adapter:tcp") b1 = communicator.stringToProxy("'category 1/test'@adapter") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category 1" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category 1" and b1.ice_getAdapterId() == "adapter") b1 = communicator.stringToProxy("'category/test 1'@adapter") - test(b1.ice_getIdentity().name == "test 1" and b1.ice_getIdentity().category == "category" and \ + test(b1.ice_getIdentity().name == "test 1" and b1.ice_getIdentity().category == "category" and b1.ice_getAdapterId() == "adapter") b1 = communicator.stringToProxy("'category/test'@'adapter 1'") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and b1.ice_getAdapterId() == "adapter 1") b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and b1.ice_getAdapterId() == "adapter") b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\"") - test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \ + test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and b1.ice_getAdapterId() == "adapter:tcp") b1 = communicator.stringToProxy("id -f facet") - test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet") b1 = communicator.stringToProxy("id -f 'facet x'") - test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet x") b1 = communicator.stringToProxy("id -f \"facet x\"") - test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet x") try: b1 = communicator.stringToProxy("id -f \"facet x") @@ -141,19 +146,19 @@ def allTests(helper, communicator, collocated): except Ice.ProxyParseException: pass b1 = communicator.stringToProxy("test -f facet:tcp") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet" and len(b1.ice_getAdapterId()) == 0) b1 = communicator.stringToProxy("test -f \"facet:tcp\"") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet:tcp" and len(b1.ice_getAdapterId()) == 0) b1 = communicator.stringToProxy("test -f facet@test") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet" and b1.ice_getAdapterId() == "test") b1 = communicator.stringToProxy("test -f 'facet@test'") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet@test" and len(b1.ice_getAdapterId()) == 0) b1 = communicator.stringToProxy("test -f 'facet@test'@test") - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and b1.ice_getFacet() == "facet@test" and b1.ice_getAdapterId() == "test") try: b1 = communicator.stringToProxy("test -f facet@test @test") @@ -184,10 +189,10 @@ def allTests(helper, communicator, collocated): pass # This is an unknown endpoint warning, not a parse exception. # - #try: + # try: # b1 = communicator.stringToProxy("test -f the:facet:tcp") # test(False) - #except Ice.EndpointParseException: + # except Ice.EndpointParseException: # pass try: b1 = communicator.stringToProxy("test::tcp") @@ -202,7 +207,7 @@ def allTests(helper, communicator, collocated): propertyPrefix = "Foo.Proxy" prop.setProperty(propertyPrefix, "test:{0}".format(helper.getTestEndpoint())) b1 = communicator.propertyToProxy(propertyPrefix) - test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \ + test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0) property = propertyPrefix + ".Locator" @@ -265,12 +270,12 @@ def allTests(helper, communicator, collocated): test(not b1.ice_isConnectionCached()) prop.setProperty(property, "") - property = propertyPrefix + ".InvocationTimeout"; - test(b1.ice_getInvocationTimeout() == -1); - prop.setProperty(property, "1000"); - b1 = communicator.propertyToProxy(propertyPrefix); - test(b1.ice_getInvocationTimeout() == 1000); - prop.setProperty(property, ""); + property = propertyPrefix + ".InvocationTimeout" + test(b1.ice_getInvocationTimeout() == -1) + prop.setProperty(property, "1000") + b1 = communicator.propertyToProxy(propertyPrefix) + test(b1.ice_getInvocationTimeout() == 1000) + prop.setProperty(property, "") property = propertyPrefix + ".EndpointSelection" test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random) @@ -299,7 +304,7 @@ def allTests(helper, communicator, collocated): b1 = b1.ice_preferSecure(False) b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) b1 = b1.ice_locatorCacheTimeout(100) - b1 = b1.ice_invocationTimeout(1234); + b1 = b1.ice_invocationTimeout(1234) b1 = b1.ice_encodingVersion(Ice.EncodingVersion(1, 0)) router = communicator.stringToProxy("router") @@ -308,7 +313,7 @@ def allTests(helper, communicator, collocated): router = router.ice_preferSecure(True) router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random) router = router.ice_locatorCacheTimeout(200) - router = router.ice_invocationTimeout(1500); + router = router.ice_invocationTimeout(1500) locator = communicator.stringToProxy("locator") locator = locator.ice_collocationOptimized(True) @@ -316,7 +321,7 @@ def allTests(helper, communicator, collocated): locator = locator.ice_preferSecure(True) locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random) locator = locator.ice_locatorCacheTimeout(300) - locator = locator.ice_invocationTimeout(1500); + locator = locator.ice_invocationTimeout(1500) locator = locator.ice_router(Ice.RouterPrx.uncheckedCast(router)) b1 = b1.ice_locator(Ice.LocatorPrx.uncheckedCast(locator)) @@ -330,7 +335,7 @@ def allTests(helper, communicator, collocated): test(proxyProps["Test.PreferSecure"] == "0") test(proxyProps["Test.EndpointSelection"] == "Ordered") test(proxyProps["Test.LocatorCacheTimeout"] == "100") - test(proxyProps["Test.InvocationTimeout"] == "1234"); + test(proxyProps["Test.InvocationTimeout"] == "1234") test(proxyProps["Test.Locator"] == "locator -t -e " + Ice.encodingVersionToString(Ice.currentEncoding())) test(proxyProps["Test.Locator.CollocationOptimized"] == "1") @@ -338,7 +343,7 @@ def allTests(helper, communicator, collocated): test(proxyProps["Test.Locator.PreferSecure"] == "1") test(proxyProps["Test.Locator.EndpointSelection"] == "Random") test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300") - test(proxyProps["Test.Locator.InvocationTimeout"] == "1500"); + test(proxyProps["Test.Locator.InvocationTimeout"] == "1500") test(proxyProps["Test.Locator.Router"] == "router -t -e " + Ice.encodingVersionToString(Ice.currentEncoding())) test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0") @@ -346,7 +351,7 @@ def allTests(helper, communicator, collocated): test(proxyProps["Test.Locator.Router.PreferSecure"] == "1") test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random") test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200") - test(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500"); + test(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500") print("ok") @@ -491,13 +496,13 @@ def allTests(helper, communicator, collocated): test(compObj.ice_connectionCached(False) < compObj.ice_connectionCached(True)) test(not (compObj.ice_connectionCached(True) < compObj.ice_connectionCached(False))) - test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) == \ + test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) == compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random)) - test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) != \ + test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) != compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)) - test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) < \ + test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) < compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)) - test(not (compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) < \ + test(not (compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) < compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))) test(compObj.ice_connectionId("id2") == compObj.ice_connectionId("id2")) @@ -512,18 +517,18 @@ def allTests(helper, communicator, collocated): test(compObj.ice_compress(False) < compObj.ice_compress(True)) test(not (compObj.ice_compress(True) < compObj.ice_compress(False))) - test(compObj.ice_getCompress() == Ice.Unset); - test(compObj.ice_compress(True).ice_getCompress() == True); - test(compObj.ice_compress(False).ice_getCompress() == False); + test(compObj.ice_getCompress() == Ice.Unset) + test(compObj.ice_compress(True).ice_getCompress() == True) + test(compObj.ice_compress(False).ice_getCompress() == False) test(compObj.ice_timeout(20) == compObj.ice_timeout(20)) test(compObj.ice_timeout(10) != compObj.ice_timeout(20)) test(compObj.ice_timeout(10) < compObj.ice_timeout(20)) test(not (compObj.ice_timeout(20) < compObj.ice_timeout(10))) - test(compObj.ice_getTimeout() == Ice.Unset); - test(compObj.ice_timeout(10).ice_getTimeout() == 10); - test(compObj.ice_timeout(20).ice_getTimeout() == 20); + test(compObj.ice_getTimeout() == Ice.Unset) + test(compObj.ice_timeout(10).ice_getTimeout() == 10) + test(compObj.ice_timeout(20).ice_getTimeout() == 20) loc1 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000")) loc2 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000")) @@ -549,14 +554,14 @@ def allTests(helper, communicator, collocated): test(compObj.ice_router(rtr1) < compObj.ice_router(rtr2)) test(not (compObj.ice_router(rtr2) < compObj.ice_router(rtr1))) - ctx1 = { } + ctx1 = {} ctx1["ctx1"] = "v1" - ctx2 = { } + ctx2 = {} ctx2["ctx2"] = "v2" - test(compObj.ice_context({ }) == compObj.ice_context({ })) + test(compObj.ice_context({}) == compObj.ice_context({})) test(compObj.ice_context(ctx1) == compObj.ice_context(ctx1)) - test(compObj.ice_context(ctx1) != compObj.ice_context({ })) - test(compObj.ice_context({ }) != compObj.ice_context(ctx2)) + test(compObj.ice_context(ctx1) != compObj.ice_context({})) + test(compObj.ice_context({}) != compObj.ice_context(ctx2)) test(compObj.ice_context(ctx1) != compObj.ice_context(ctx2)) test(compObj.ice_context(ctx1) < compObj.ice_context(ctx2)) test(not (compObj.ice_context(ctx2) < compObj.ice_context(ctx1))) @@ -583,10 +588,10 @@ def allTests(helper, communicator, collocated): test(compObj1.ice_locatorCacheTimeout(10) < compObj1.ice_locatorCacheTimeout(20)) test(not (compObj1.ice_locatorCacheTimeout(20) < compObj1.ice_locatorCacheTimeout(10))) - test(compObj1.ice_invocationTimeout(20) == compObj1.ice_invocationTimeout(20)); - test(compObj1.ice_invocationTimeout(10) != compObj1.ice_invocationTimeout(20)); - test(compObj1.ice_invocationTimeout(10) < compObj1.ice_invocationTimeout(20)); - test(not (compObj1.ice_invocationTimeout(20) < compObj1.ice_invocationTimeout(10))); + test(compObj1.ice_invocationTimeout(20) == compObj1.ice_invocationTimeout(20)) + test(compObj1.ice_invocationTimeout(10) != compObj1.ice_invocationTimeout(20)) + test(compObj1.ice_invocationTimeout(10) < compObj1.ice_invocationTimeout(20)) + test(not (compObj1.ice_invocationTimeout(20) < compObj1.ice_invocationTimeout(10))) compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000") compObj2 = communicator.stringToProxy("foo@MyAdapter1") @@ -606,12 +611,12 @@ def allTests(helper, communicator, collocated): test(compObj.ice_encodingVersion(Ice.Encoding_1_0) < compObj.ice_encodingVersion(Ice.Encoding_1_1)) test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) < compObj.ice_encodingVersion(Ice.Encoding_1_0))) - baseConnection = base.ice_getConnection(); + baseConnection = base.ice_getConnection() if baseConnection: - baseConnection2 = base.ice_connectionId("base2").ice_getConnection(); - compObj1 = compObj1.ice_fixed(baseConnection); - compObj2 = compObj2.ice_fixed(baseConnection2); - test(compObj1 != compObj2); + baseConnection2 = base.ice_connectionId("base2").ice_getConnection() + compObj1 = compObj1.ice_fixed(baseConnection) + compObj2 = compObj2.ice_fixed(baseConnection2) + test(compObj1 != compObj2) print("ok") @@ -648,9 +653,9 @@ def allTests(helper, communicator, collocated): c = tccp.getContext() test(c == None or len(c) == 0) - c = { } + c = {} c["one"] = "hello" - c["two"] = "world" + c["two"] = "world" tccp = Test.MyClassPrx.checkedCast(base, c) c2 = tccp.getContext() test(c == c2) @@ -666,24 +671,24 @@ def allTests(helper, communicator, collocated): test(cl.ice_secure(True).ice_fixed(connection).ice_isSecure()) test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet") test(cl.ice_oneway().ice_fixed(connection).ice_isOneway()) - ctx = { } + ctx = {} ctx["one"] = "hello" - ctx["two"] = "world" - test(len(cl.ice_fixed(connection).ice_getContext()) == 0); - test(len(cl.ice_context(ctx).ice_fixed(connection).ice_getContext()) == 2); - test(cl.ice_fixed(connection).ice_getInvocationTimeout() == -1); - test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == 10); + ctx["two"] = "world" + test(len(cl.ice_fixed(connection).ice_getContext()) == 0) + test(len(cl.ice_context(ctx).ice_fixed(connection).ice_getContext()) == 2) + test(cl.ice_fixed(connection).ice_getInvocationTimeout() == -1) + test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == 10) test(cl.ice_fixed(connection).ice_getConnection() == connection) test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection) test(cl.ice_fixed(connection).ice_getTimeout() == Ice.Unset) fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection() test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection) try: - cl.ice_secure(not connection.getEndpoint().getInfo().secure()).ice_fixed(connection).ice_ping(); + cl.ice_secure(not connection.getEndpoint().getInfo().secure()).ice_fixed(connection).ice_ping() except Ice.NoEndpointException: pass try: - cl.ice_datagram().ice_fixed(connection).ice_ping(); + cl.ice_datagram().ice_fixed(connection).ice_ping() except Ice.NoEndpointException: pass else: @@ -698,7 +703,7 @@ def allTests(helper, communicator, collocated): sys.stdout.write("testing encoding versioning... ") sys.stdout.flush() ref20 = "test -e 2.0:{0}".format(helper.getTestEndpoint()) - cl20 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref20)); + cl20 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref20)) try: cl20.ice_ping() test(False) @@ -815,7 +820,8 @@ def allTests(helper, communicator, collocated): tcp = communicator.getProperties().getProperty("Ice.Default.Protocol") == "tcp" # Two legal TCP endpoints expressed as opaque endpoints - p1 = communicator.stringToProxy("test -e 1.0:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMusuAAAQJwAAAA==") + p1 = communicator.stringToProxy( + "test -e 1.0:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMusuAAAQJwAAAA==") pstr = communicator.proxyToString(p1) test(pstr == "test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000") @@ -823,7 +829,8 @@ def allTests(helper, communicator, collocated): # Test that an SSL endpoint and a nonsense endpoint get written # back out as an opaque endpoint. # - p1 = communicator.stringToProxy("test -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") + p1 = communicator.stringToProxy( + "test -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") pstr = communicator.proxyToString(p1) if ssl: test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch") @@ -858,17 +865,17 @@ def allTests(helper, communicator, collocated): print("ok") - sys.stdout.write("testing communicator shutdown/destroy... "); + sys.stdout.write("testing communicator shutdown/destroy... ") sys.stdout.flush() - c = Ice.initialize(); - c.shutdown(); - test(c.isShutdown()); - c.waitForShutdown(); - c.destroy(); - c.shutdown(); - test(c.isShutdown()); - c.waitForShutdown(); - c.destroy(); - print("ok"); + c = Ice.initialize() + c.shutdown() + test(c.isShutdown()) + c.waitForShutdown() + c.destroy() + c.shutdown() + test(c.isShutdown()) + c.waitForShutdown() + c.destroy() + print("ok") return cl diff --git a/python/test/Ice/proxy/Server.py b/python/test/Ice/proxy/Server.py index 794633e701e..afbcc9c2cab 100755 --- a/python/test/Ice/proxy/Server.py +++ b/python/test/Ice/proxy/Server.py @@ -10,6 +10,7 @@ import Test import TestI + class Server(TestHelper): def run(self, args): diff --git a/python/test/Ice/proxy/ServerAMD.py b/python/test/Ice/proxy/ServerAMD.py index 38b39b8ec9f..eea5e894dde 100755 --- a/python/test/Ice/proxy/ServerAMD.py +++ b/python/test/Ice/proxy/ServerAMD.py @@ -9,6 +9,7 @@ import Test import TestI + class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.ctx = None diff --git a/python/test/Ice/proxy/TestI.py b/python/test/Ice/proxy/TestI.py index 9c33e0aeaa1..ffd0dea5d51 100644 --- a/python/test/Ice/proxy/TestI.py +++ b/python/test/Ice/proxy/TestI.py @@ -2,9 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test +import Ice +import Test import time + class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.ctx = None diff --git a/python/test/Ice/scope/AllTests.py b/python/test/Ice/scope/AllTests.py index d60e19cd945..0de0f045efe 100644 --- a/python/test/Ice/scope/AllTests.py +++ b/python/test/Ice/scope/AllTests.py @@ -2,7 +2,13 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, string, re, traceback, Ice, Test, Inner +import sys +import string +import re +import traceback +import Ice +import Test +import Inner def test(b): diff --git a/python/test/Ice/servantLocator/AllTests.py b/python/test/Ice/servantLocator/AllTests.py index 19bcf51e56f..0ec8e8afe57 100644 --- a/python/test/Ice/servantLocator/AllTests.py +++ b/python/test/Ice/servantLocator/AllTests.py @@ -2,12 +2,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, Ice, Test +import sys +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + def testExceptions(obj): try: @@ -119,6 +123,7 @@ def testExceptions(obj): except: test(False) + def allTests(helper, communicator): sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -227,6 +232,6 @@ def allTests(helper, communicator): communicator.stringToProxy("invalidReturnType:{0}".format(helper.getTestEndpoint())).ice_ping() except Ice.ObjectNotExistException: pass - print ("ok") + print("ok") return obj diff --git a/python/test/Ice/servantLocator/TestAMDI.py b/python/test/Ice/servantLocator/TestAMDI.py index cc1b4eeb91f..cd936b2ad7c 100644 --- a/python/test/Ice/servantLocator/TestAMDI.py +++ b/python/test/Ice/servantLocator/TestAMDI.py @@ -2,13 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, time -import Ice, Test +import os +import sys +import traceback +import time +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class TestI(Test.TestIntf): def requestFailedException(self, current=None): @@ -65,7 +71,7 @@ def asyncResponse(self, current=None): # # We can't do this with futures. # - #return Ice.Future.completed(None) + # return Ice.Future.completed(None) raise Ice.ObjectNotExistException() def asyncException(self, current=None): @@ -73,17 +79,19 @@ def asyncException(self, current=None): # We can't do this with futures. # #f = Ice.Future() - #f.set_exception(Test.TestIntfUserException()) - #return f + # f.set_exception(Test.TestIntfUserException()) + # return f raise Ice.ObjectNotExistException() def shutdown(self, current=None): current.adapter.deactivate() + class Cookie: def message(self): return 'blahblah' + class ServantLocatorI(Ice.ServantLocator): def __init__(self, category): self._deactivated = False @@ -162,9 +170,9 @@ def exception(self, current): elif current.operation == "unknownExceptionWithServantException": raise Ice.UnknownException("reason") elif current.operation == "impossibleException": - raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException. + raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException. elif current.operation == "intfUserException": - raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException. + raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException. elif current.operation == "asyncResponse": raise Test.TestImpossibleException() elif current.operation == "asyncException": diff --git a/python/test/Ice/servantLocator/TestActivationAMDI.py b/python/test/Ice/servantLocator/TestActivationAMDI.py index e442bec9a82..250152b2da4 100644 --- a/python/test/Ice/servantLocator/TestActivationAMDI.py +++ b/python/test/Ice/servantLocator/TestActivationAMDI.py @@ -2,13 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, time -import Ice, Test, TestAMDI +import os +import sys +import traceback +import time +import Ice +import Test +import TestAMDI + class TestActivationAMDI(Test.TestActivation): def activateServantLocator(self, activate, current=None): - if(activate): + if (activate): current.adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "") current.adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category") else: diff --git a/python/test/Ice/servantLocator/TestActivationI.py b/python/test/Ice/servantLocator/TestActivationI.py index 42328034627..d465d371e26 100644 --- a/python/test/Ice/servantLocator/TestActivationI.py +++ b/python/test/Ice/servantLocator/TestActivationI.py @@ -2,8 +2,14 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, time -import Ice, Test, TestI +import os +import sys +import traceback +import time +import Ice +import Test +import TestI + class TestActivationI(Test.TestActivation): diff --git a/python/test/Ice/servantLocator/TestI.py b/python/test/Ice/servantLocator/TestI.py index 3a78aae09ce..4a5772bb3ed 100644 --- a/python/test/Ice/servantLocator/TestI.py +++ b/python/test/Ice/servantLocator/TestI.py @@ -2,13 +2,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, traceback, time -import Ice, Test +import os +import sys +import traceback +import time +import Ice +import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class TestI(Test.TestIntf): def requestFailedException(self, current=None): @@ -68,10 +74,12 @@ def asyncException(self, current=None): def shutdown(self, current=None): current.adapter.deactivate() + class Cookie: def message(self): return 'blahblah' + class ServantLocatorI(Ice.ServantLocator): def __init__(self, category): self._deactivated = False @@ -150,9 +158,9 @@ def exception(self, current): elif current.operation == "unknownExceptionWithServantException": raise Ice.UnknownException("reason") elif current.operation == "impossibleException": - raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException. + raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException. elif current.operation == "intfUserException": - raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException. + raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException. elif current.operation == "asyncResponse": raise Test.TestImpossibleException() elif current.operation == "asyncException": diff --git a/python/test/Ice/slicing/exceptions/AllTests.py b/python/test/Ice/slicing/exceptions/AllTests.py index 855a98d057f..ffbc722e291 100644 --- a/python/test/Ice/slicing/exceptions/AllTests.py +++ b/python/test/Ice/slicing/exceptions/AllTests.py @@ -3,15 +3,19 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, threading, sys +import Ice +import threading +import sys Ice.loadSlice('-I. --all ClientPrivate.ice') import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class CallbackBase: def __init__(self): self._called = False @@ -28,6 +32,7 @@ def called(self): self._called = True self._cond.notify() + class Callback(CallbackBase): def exception_baseAsBase(self, f): try: @@ -184,6 +189,7 @@ def exception_unknownMostDerived2AsBase(self, f): test(False) self.called() + class RelayI(Test.Relay): def knownPreservedAsBase(self, current=None): ex = Test.KnownPreservedDerived() @@ -217,6 +223,7 @@ def unknownPreservedAsKnownPreserved(self, current=None): ex.p2 = ex.p1 raise ex + def allTests(helper, communicator): obj = communicator.stringToProxy("Test:{0}".format(helper.getTestEndpoint())) t = Test.TestIntfPrx.checkedCast(obj) @@ -507,31 +514,31 @@ def allTests(helper, communicator): sys.stdout.flush() try: - t.unknownPreservedAsBase(); - test(False); + t.unknownPreservedAsBase() + test(False) except Test.Base as ex: if t.ice_getEncodingVersion() == Ice.Encoding_1_0: test(ex.ice_getSlicedData() is None) else: - slicedData = ex.ice_getSlicedData(); - test(slicedData); - test(len(slicedData.slices) == 2); - test(slicedData.slices[1].typeId == "::Test::SPreserved1"); - test(slicedData.slices[0].typeId == "::Test::SPreserved2"); + slicedData = ex.ice_getSlicedData() + test(slicedData) + test(len(slicedData.slices) == 2) + test(slicedData.slices[1].typeId == "::Test::SPreserved1") + test(slicedData.slices[0].typeId == "::Test::SPreserved2") try: - t.unknownPreservedAsKnownPreserved(); - test(False); + t.unknownPreservedAsKnownPreserved() + test(False) except Test.KnownPreserved as ex: test(ex.kp == "preserved") if t.ice_getEncodingVersion() == Ice.Encoding_1_0: test(ex.ice_getSlicedData() is None) else: - slicedData = ex.ice_getSlicedData(); - test(slicedData); - test(len(slicedData.slices) == 2); - test(slicedData.slices[1].typeId == "::Test::SPreserved1"); - test(slicedData.slices[0].typeId == "::Test::SPreserved2"); + slicedData = ex.ice_getSlicedData() + test(slicedData) + test(len(slicedData.slices) == 2) + test(slicedData.slices[1].typeId == "::Test::SPreserved1") + test(slicedData.slices[0].typeId == "::Test::SPreserved2") adapter = communicator.createObjectAdapter("") relay = Test.RelayPrx.uncheckedCast(adapter.addWithUUID(RelayI())) diff --git a/python/test/Ice/slicing/objects/AllTests.py b/python/test/Ice/slicing/objects/AllTests.py index dc0b98a6b26..4a25ea67a81 100644 --- a/python/test/Ice/slicing/objects/AllTests.py +++ b/python/test/Ice/slicing/objects/AllTests.py @@ -3,15 +3,20 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, gc, sys, threading +import Ice +import gc +import sys +import threading Ice.loadSlice('-I. --all ClientPrivate.ice') import Test + def test(b): if not b: raise RuntimeError('test assertion failed') + class CallbackBase: def __init__(self): self._called = False @@ -28,6 +33,7 @@ def called(self): self._called = True self._cond.notify() + class Callback(CallbackBase): def response_SBaseAsObject(self, f): o = f.result() @@ -359,6 +365,7 @@ def response_compactPreserved2(self, f): test(r.pbs[0] == r) self.called() + class PNodeI(Test.PNode): counter = 0 @@ -368,11 +375,13 @@ def __init__(self): def __del__(self): PNodeI.counter = PNodeI.counter - 1 + def NodeFactoryI(id): if id == Test.PNode.ice_staticId(): return PNodeI() return None + class PreservedI(Test.Preserved): counter = 0 @@ -382,11 +391,13 @@ def __init__(self): def __del__(self): PreservedI.counter = PreservedI.counter - 1 + def PreservedFactoryI(id): if id == Test.Preserved.ice_staticId(): return PreservedI() return None + def allTests(helper, communicator): obj = communicator.stringToProxy("Test:{0}".format(helper.getTestEndpoint())) t = Test.TestIntfPrx.checkedCast(obj) @@ -1504,7 +1515,7 @@ def allTests(helper, communicator): # pcd = Test.PCDerived() pcd.pi = 3 - pcd.pbs = [ pcd ] + pcd.pbs = [pcd] r = t.exchangePBase(pcd) if t.ice_getEncodingVersion() == Ice.Encoding_1_0: @@ -1521,7 +1532,7 @@ def allTests(helper, communicator): # pcd = Test.CompactPCDerived() pcd.pi = 3 - pcd.pbs = [ pcd ] + pcd.pbs = [pcd] r = t.exchangePBase(pcd) if t.ice_getEncodingVersion() == Ice.Encoding_1_0: @@ -1545,7 +1556,7 @@ def allTests(helper, communicator): for i in range(0, 300): p2 = Test.PCDerived2() p2.pi = i - p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table. + p2.pbs = [None] # Nil reference. This slice should not have an indirection table. p2.pcd2 = i pcd.pbs.append(p2) pcd.pcd2 = pcd.pi @@ -1621,7 +1632,7 @@ def allTests(helper, communicator): # pcd = Test.PCDerived() pcd.pi = 3 - pcd.pbs = [ pcd ] + pcd.pbs = [pcd] cb = Callback() if t.ice_getEncodingVersion() == Ice.Encoding_1_0: @@ -1636,7 +1647,7 @@ def allTests(helper, communicator): # pcd = Test.CompactPCDerived() pcd.pi = 3 - pcd.pbs = [ pcd ] + pcd.pbs = [pcd] cb = Callback() if t.ice_getEncodingVersion() == Ice.Encoding_1_0: @@ -1658,7 +1669,7 @@ def allTests(helper, communicator): for i in range(0, 300): p2 = Test.PCDerived2() p2.pi = i - p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table. + p2.pbs = [None] # Nil reference. This slice should not have an indirection table. p2.pcd2 = i pcd.pbs.append(p2) pcd.pcd2 = pcd.pi diff --git a/python/test/Ice/slicing/objects/Server.py b/python/test/Ice/slicing/objects/Server.py index 6abeb43ffbd..3a233fb7e19 100755 --- a/python/test/Ice/slicing/objects/Server.py +++ b/python/test/Ice/slicing/objects/Server.py @@ -13,6 +13,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') + class TestI(Test.TestIntf): def SBaseAsObject(self, current=None): sb = Test.SBase() @@ -249,7 +250,7 @@ def PBSUnknownAsPreservedWithGraph(self, current=None): r.graph.next.next = Test.PNode() r.graph.next.next.next = r.graph return Ice.Future.completed(r) - #r.graph.next.next.next = None # Break the cycle. + # r.graph.next.next.next = None # Break the cycle. def checkPBSUnknownWithGraph(self, p, current=None): if current.encoding == Ice.Encoding_1_0: @@ -272,7 +273,7 @@ def PBSUnknown2AsPreservedWithGraph(self, current=None): r.ps = "preserved" r.pb = r return Ice.Future.completed(r) - #r.pb = None # Break the cycle. + # r.pb = None # Break the cycle. def checkPBSUnknown2WithGraph(self, p, current=None): if current.encoding == Ice.Encoding_1_0: @@ -348,7 +349,7 @@ def throwPreservedException(self, current=None): f = Ice.Future() f.set_exception(ue) return f - #ue.p.pb = None # Break the cycle. + # ue.p.pb = None # Break the cycle. def useForward(self, current=None): f = Test.Forward() diff --git a/python/test/Ice/slicing/objects/ServerAMD.py b/python/test/Ice/slicing/objects/ServerAMD.py index 7f8b9b332de..77e3d3d0866 100755 --- a/python/test/Ice/slicing/objects/ServerAMD.py +++ b/python/test/Ice/slicing/objects/ServerAMD.py @@ -276,7 +276,7 @@ def PBSUnknownAsPreservedWithGraph(self, current=None): r.graph.next.next = Test.PNode() r.graph.next.next.next = r.graph return Ice.Future.completed(r) - #r.graph.next.next.next = None # Break the cycle. + # r.graph.next.next.next = None # Break the cycle. def checkPBSUnknownWithGraph(self, p, current=None): if current.encoding == Ice.Encoding_1_0: @@ -300,7 +300,7 @@ def PBSUnknown2AsPreservedWithGraph(self, current=None): r.ps = "preserved" r.pb = r return Ice.Future.completed(r) - #r.pb = None # Break the cycle. + # r.pb = None # Break the cycle. def checkPBSUnknown2WithGraph(self, p, current=None): if current.encoding == Ice.Encoding_1_0: @@ -385,7 +385,7 @@ def throwPreservedException(self, current=None): f = Ice.Future() f.set_exception(ue) return f - #ue.p.pb = None # Break the cycle. + # ue.p.pb = None # Break the cycle. def useForward(self, current=None): fwd = Test.Forward() diff --git a/python/test/Ice/thread/AllTests.py b/python/test/Ice/thread/AllTests.py index 8700a1c2ebe..57ec0df8a7c 100644 --- a/python/test/Ice/thread/AllTests.py +++ b/python/test/Ice/thread/AllTests.py @@ -2,12 +2,17 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, TestI +import Ice +import Test +import sys +import TestI + def test(b): if not b: raise RuntimeError('test assertion failed') + def allTests(helper, communicator): ref = "factory:{0} -t 10000".format(helper.getTestEndpoint()) diff --git a/python/test/Ice/thread/TestI.py b/python/test/Ice/thread/TestI.py index 20ce03c2bc3..0752a47022f 100644 --- a/python/test/Ice/thread/TestI.py +++ b/python/test/Ice/thread/TestI.py @@ -2,7 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, time, threading +import Ice +import Test +import time +import threading + class ThreadHook(Ice.ThreadNotification): def __init__(self): @@ -44,10 +48,12 @@ def getThreadStopCount(self): with self.cond: return self.threadStopCount + class TestIntfI(Test.TestIntf): - def sleep(self, ms, current = None): + def sleep(self, ms, current=None): time.sleep(ms / 1000.0) + class RemoteCommunicatorI(Test.RemoteCommunicator): def __init__(self, communicator, hook): self.communicator = communicator @@ -56,27 +62,28 @@ def __init__(self, communicator, hook): self.obj = Test.TestIntfPrx.uncheckedCast(oa.addWithUUID(TestIntfI())) oa.activate() - def getObject(self, current = None): + def getObject(self, current=None): return self.obj - def getThreadHookStartCount(self, current = None): + def getThreadHookStartCount(self, current=None): return self.hook.getThreadHookStartCount() - def getThreadHookStopCount(self, current = None): + def getThreadHookStopCount(self, current=None): return self.hook.getThreadHookStopCount() - def getThreadStartCount(self, current = None): + def getThreadStartCount(self, current=None): return self.hook.getThreadStartCount() - def getThreadStopCount(self, current = None): + def getThreadStopCount(self, current=None): return self.hook.getThreadStopCount() - def destroy(self, current = None): + def destroy(self, current=None): self.communicator.destroy() + class RemoteCommunicatorFactoryI(Test.RemoteCommunicatorFactory): - def createCommunicator(self, props, current = None): + def createCommunicator(self, props, current=None): # # Prepare the property set using the given properties. # @@ -97,5 +104,5 @@ def createCommunicator(self, props, current = None): proxy = current.adapter.addWithUUID(RemoteCommunicatorI(communicator, init.threadHook)) return Test.RemoteCommunicatorPrx.uncheckedCast(proxy) - def shutdown(self, current = None): + def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py index fa96ef75e4c..db74d215d90 100644 --- a/python/test/Ice/timeout/AllTests.py +++ b/python/test/Ice/timeout/AllTests.py @@ -2,12 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import Ice, Test, sys, threading, time +import Ice +import Test +import sys +import threading +import time + def test(b): if not b: raise RuntimeError('test assertion failed') + class CallbackBase: def __init__(self): self._called = False @@ -25,6 +31,7 @@ def check(self): self._called = False return True + class Callback(CallbackBase): def response(self): self.called() @@ -39,6 +46,7 @@ def exceptionEx(self, ex): test(isinstance(ex, Ice.TimeoutException)) self.called() + def connect(prx): # Establish connection with the given proxy (which might have a timeout # set and might sporadically fail on connection establishment if it's @@ -47,12 +55,13 @@ def connect(prx): nRetry = 10 while --nRetry > 0: try: - prx.ice_getConnection(); + prx.ice_getConnection() break except Ice.ConnectTimeoutException: # Can sporadically occur with slow machines pass - return prx.ice_getConnection(); # Establish connection + return prx.ice_getConnection() # Establish connection + def allTests(helper, communicator): controller = Test.ControllerPrx.checkedCast( @@ -67,6 +76,7 @@ def allTests(helper, communicator): controller.resumeAdapter() raise + def allTestsWithController(helper, communicator, controller): sref = "timeout:{0}".format(helper.getTestEndpoint()) @@ -87,9 +97,9 @@ def allTestsWithController(helper, communicator, controller): to.op() test(False) except Ice.ConnectTimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. # # Expect success. @@ -115,9 +125,9 @@ def allTestsWithController(helper, communicator, controller): to.sendData(seq) test(False) except Ice.TimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. # # Expect success. # @@ -157,7 +167,7 @@ def allTestsWithController(helper, communicator, controller): controller.holdAdapter(-1) connection.close(Ice.ConnectionClose.GracefullyWithWait) try: - connection.getInfo(); # getInfo() doesn't throw in the closing state. + connection.getInfo() # getInfo() doesn't throw in the closing state. except Ice.LocalException: test(False) while True: @@ -169,7 +179,7 @@ def allTestsWithController(helper, communicator, controller): test(ex.graceful) break controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. print("ok") sys.stdout.write("testing timeout overrides... ") @@ -191,9 +201,9 @@ def allTestsWithController(helper, communicator, controller): to.sendData(seq) test(False) except Ice.TimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. # # Calling ice_timeout() should have no effect. @@ -205,9 +215,9 @@ def allTestsWithController(helper, communicator, controller): to.sendData(seq) test(False) except Ice.TimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. comm.destroy() # # Test Ice.Override.ConnectTimeout. @@ -222,9 +232,9 @@ def allTestsWithController(helper, communicator, controller): to.op() test(False) except Ice.ConnectTimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. # # Calling ice_timeout() should have no effect on the connect timeout. # @@ -234,9 +244,9 @@ def allTestsWithController(helper, communicator, controller): to.op() test(False) except Ice.ConnectTimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. # # Verify that timeout set via ice_timeout() is still used for requests. # @@ -247,9 +257,9 @@ def allTestsWithController(helper, communicator, controller): to.sendData(seq) test(False) except Ice.TimeoutException: - pass # Expected. + pass # Expected. controller.resumeAdapter() - timeout.op() # Ensure adapter is active. + timeout.op() # Ensure adapter is active. comm.destroy() # diff --git a/python/test/Ice/timeout/Server.py b/python/test/Ice/timeout/Server.py index 80df24e82ab..2e233620a49 100755 --- a/python/test/Ice/timeout/Server.py +++ b/python/test/Ice/timeout/Server.py @@ -21,6 +21,7 @@ def run(self): time.sleep(self._timeout / 1000.0) self._adapter.activate() + class TimeoutI(Test.Timeout): def op(self, current=None): pass @@ -32,6 +33,7 @@ def sleep(self, timeout, current=None): if timeout != 0: time.sleep(timeout / 1000.0) + class ControllerI(Test.Controller): def __init__(self, adapter): diff --git a/python/test/Slice/escape/Client.py b/python/test/Slice/escape/Client.py index 0f306844a15..aecb703c08d 100755 --- a/python/test/Slice/escape/Client.py +++ b/python/test/Slice/escape/Client.py @@ -55,14 +55,14 @@ def testtypes(): assert "_finally" in dir(_and.ifPrx) assert "_elif" in dir(_and.ifPrx) f1 = ifI() - g = _and._is() + g = _and._is() g._lamba = 0 h = _and._not() h._lamba = 0 h._or = 1 h._pass = 2 i = printI() - j = _and._lambda; + j = _and._lambda en = _and.EnumNone._None print("ok") diff --git a/python/test/Slice/import/test.py b/python/test/Slice/import/test.py index 226235ac152..c07a2a13df3 100644 --- a/python/test/Slice/import/test.py +++ b/python/test/Slice/import/test.py @@ -18,4 +18,5 @@ def setupClientSide(self, current): slice2py.run(current, args=["Test1.ice"]) slice2py.run(current, args=["Test2.ice"]) -TestSuite(__name__, [ SliceImportTestCase() ]) + +TestSuite(__name__, [SliceImportTestCase()]) diff --git a/python/test/Slice/structure/Client.py b/python/test/Slice/structure/Client.py index 6e17c9d758e..4606be0b526 100755 --- a/python/test/Slice/structure/Client.py +++ b/python/test/Slice/structure/Client.py @@ -135,7 +135,7 @@ def allTests(communicator): # # Define some default values. # - def_s3 = Test.S3(Test.C("name"), {"1":"2"}, communicator.stringToProxy("test")) + def_s3 = Test.S3(Test.C("name"), {"1": "2"}, communicator.stringToProxy("test")) # # Compare default-constructed structures. @@ -161,7 +161,7 @@ def allTests(communicator): v1.sd = None test(v1 != def_s3) - v1.sd = {"1":"3"} + v1.sd = {"1": "3"} test(v1 != def_s3) v1 = copy.copy(def_s3) diff --git a/ruby/allTests.py b/ruby/allTests.py index 2241653995d..94a9466c3db 100755 --- a/ruby/allTests.py +++ b/ruby/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath diff --git a/scripts/Component.py b/scripts/Component.py index d777b6b10e4..d1ca2568719 100644 --- a/scripts/Component.py +++ b/scripts/Component.py @@ -6,33 +6,34 @@ from Util import * + class Ice(Component): # Options for all transports (ran only with Ice client/server tests defined for cross testing) transportOptions = { - "protocol" : ["tcp", "ssl", "wss", "ws"], - "compress" : [False, True], - "ipv6" : [False, True], - "serialize" : [False, True], - "mx" : [False, True], + "protocol": ["tcp", "ssl", "wss", "ws"], + "compress": [False, True], + "ipv6": [False, True], + "serialize": [False, True], + "mx": [False, True], } # Options for Ice tests, run tests with ssl and ws/ipv6/serial/mx/compress coreOptions = { - "protocol" : ["ssl", "ws"], - "compress" : [False, True], - "ipv6" : [False, True], - "serialize" : [False, True], - "mx" : [False, True], + "protocol": ["ssl", "ws"], + "compress": [False, True], + "ipv6": [False, True], + "serialize": [False, True], + "mx": [False, True], } # Options for Ice services, run tests with ssl + mx serviceOptions = { - "protocol" : ["ssl"], - "compress" : [False], - "ipv6" : [False], - "serialize" : [False], - "mx" : [True], + "protocol": ["ssl"], + "compress": [False], + "ipv6": [False], + "serialize": [False], + "mx": [True], } def useBinDist(self, mapping, current): @@ -127,7 +128,7 @@ def canRun(self, testId, mapping, current): return True def isMainThreadOnly(self, testId): - return False # By default, tests support being run concurrently + return False # By default, tests support being run concurrently def getDefaultProcesses(self, mapping, processType, testId): if testId.startswith("IceUtil") or testId.startswith("Slice"): @@ -191,6 +192,7 @@ def getSoVersion(self): else: return '%db%d' % (majorVersion * 10 + minorVersion, patchVersion - 60) + component = Ice() from Glacier2Util import * diff --git a/scripts/Controller.py b/scripts/Controller.py index 13010467c1a..1e4b4fd7605 100755 --- a/scripts/Controller.py +++ b/scripts/Controller.py @@ -3,9 +3,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys from Util import * + class ControllerDriver(Driver): class Current(Driver.Current): @@ -37,7 +39,7 @@ def __init__(self, options, *args, **kargs): self.id = "controller" self.endpoints = "" self.clean = False - parseOptions(self, options, { "clean" : "clean" }) + parseOptions(self, options, {"clean": "clean"}) if not self.endpoints: self.endpoints = ("tcp -h " + self.interface) if self.interface else "tcp" @@ -90,7 +92,8 @@ def startServerSide(self, config, c): return self.current.serverTestCase._startServerSide(self.current) except Exception as ex: self.serverSideRunning = False - raise Test.Common.TestCaseFailedException(self.current.result.getOutput() + "\n" + traceback.format_exc()) + raise Test.Common.TestCaseFailedException( + self.current.result.getOutput() + "\n" + traceback.format_exc()) def stopServerSide(self, success, c): if self.serverSideRunning: @@ -140,7 +143,8 @@ def runTestCase(self, mapping, testsuite, testcase, cross, c): current = self.driver.getCurrent(mapping, testsuite, testcase, cross) prx = c.adapter.addWithUUID(TestCaseI(self.driver, current)) - self.testcase = Test.Common.TestCasePrx.uncheckedCast(c.adapter.createDirectProxy(prx.ice_getIdentity())) + self.testcase = Test.Common.TestCasePrx.uncheckedCast( + c.adapter.createDirectProxy(prx.ice_getIdentity())) return self.testcase def getTestSuites(self, mapping, c): @@ -195,6 +199,7 @@ def isWorkerThread(self): def isInterrupted(self): return False + Driver.add("controller", ControllerDriver, default=True) runTests() diff --git a/scripts/Glacier2Util.py b/scripts/Glacier2Util.py index f37e084396c..e3dadd45618 100644 --- a/scripts/Glacier2Util.py +++ b/scripts/Glacier2Util.py @@ -2,9 +2,11 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, os +import sys +import os from Util import * + class Glacier2Router(ProcessFromBinDir, ProcessIsReleaseOnly, Server): def __init__(self, portnum=50, passwords={"userid": "abc123"}, *args, **kargs): @@ -21,7 +23,7 @@ def setup(self, current): path = os.path.join(current.testsuite.getPath(), "passwords") with open(path, "w") as file: command = "\"%s\" %s" % (sys.executable, - os.path.abspath(os.path.join(toplevel, "scripts", "icehashpassword.py"))) + os.path.abspath(os.path.join(toplevel, "scripts", "icehashpassword.py"))) # # For Linux ARM default rounds makes test slower (Usually runs on embedded boards) @@ -36,10 +38,10 @@ def setup(self, current): def getProps(self, current): props = Server.getProps(self, current) props.update({ - "Glacier2.Client.Endpoints" : current.getTestEndpoint(self.portnum), - "Glacier2.Server.Endpoints" : "tcp", - "Ice.Admin.Endpoints" : current.getTestEndpoint(self.portnum + 1), - "Ice.Admin.InstanceName" : "Glacier2", + "Glacier2.Client.Endpoints": current.getTestEndpoint(self.portnum), + "Glacier2.Server.Endpoints": "tcp", + "Ice.Admin.Endpoints": current.getTestEndpoint(self.portnum + 1), + "Ice.Admin.InstanceName": "Glacier2", }) if self.passwords: props["Glacier2.CryptPasswords"] = os.path.join(current.testsuite.getPath(), "passwords") @@ -51,6 +53,7 @@ def getProps(self, current): def getClientProxy(self, current): return "Glacier2/router:{0}".format(current.getTestEndpoint(self.portnum)) + class Glacier2TestSuite(TestSuite): def __init__(self, path, routerProps={}, testcases=None, *args, **kargs): diff --git a/scripts/IceBoxUtil.py b/scripts/IceBoxUtil.py index 59997fb87d8..2512d3b6ade 100644 --- a/scripts/IceBoxUtil.py +++ b/scripts/IceBoxUtil.py @@ -5,6 +5,7 @@ from Util import * from Component import component + class IceBox(ProcessFromBinDir, Server): def __init__(self, configFile=None, *args, **kargs): @@ -22,7 +23,7 @@ def getExe(self, current): if isinstance(platform, Linux) and \ platform.getLinuxId() in ["centos", "rhel", "fedora"] and \ current.config.buildPlatform == "x86": - name += "32" # Multilib platform + name += "32" # Multilib platform if isinstance(platform, AIX) and \ current.config.buildPlatform == "ppc": name += "_32" @@ -40,6 +41,7 @@ def getEffectiveArgs(self, current, args): args.append("--Ice.Config={0}".format(self.configFile)) return args + class IceBoxAdmin(ProcessFromBinDir, ProcessIsReleaseOnly, Client): def getMapping(self, current): @@ -55,7 +57,7 @@ def getExe(self, current): if isinstance(mapping, JavaMapping): return "com.zeroc.IceBox.Admin" elif isinstance(platform, AIX) and \ - current.config.buildPlatform == "ppc" and not component.useBinDist(mapping, current): + current.config.buildPlatform == "ppc" and not component.useBinDist(mapping, current): return "iceboxadmin_32" else: return "iceboxadmin" diff --git a/scripts/IceBridgeUtil.py b/scripts/IceBridgeUtil.py index 2df68fede37..e616707234b 100644 --- a/scripts/IceBridgeUtil.py +++ b/scripts/IceBridgeUtil.py @@ -4,6 +4,7 @@ from Util import * + class IceBridge(ProcessFromBinDir, ProcessIsReleaseOnly, Server): def __init__(self, *args, **kargs): @@ -13,13 +14,13 @@ def getExe(self, current): return self.exe + "_32" if current.config.buildPlatform == "ppc" else self.exe def getProps(self, current): - props = Server.getProps(self, current); + props = Server.getProps(self, current) props.update({ - 'Ice.Warn.Dispatch' : 0, - 'IceBridge.Target.Endpoints' : current.getTestEndpoint(0) + ":" + current.getTestEndpoint(0, "udp"), - 'IceBridge.Source.Endpoints' : current.getTestEndpoint(1) + ":" + current.getTestEndpoint(1, "udp"), - 'Ice.Admin.Endpoints' : current.getTestEndpoint(2, "tcp"), - 'Ice.Admin.InstanceName' : "IceBridge", + 'Ice.Warn.Dispatch': 0, + 'IceBridge.Target.Endpoints': current.getTestEndpoint(0) + ":" + current.getTestEndpoint(0, "udp"), + 'IceBridge.Source.Endpoints': current.getTestEndpoint(1) + ":" + current.getTestEndpoint(1, "udp"), + 'Ice.Admin.Endpoints': current.getTestEndpoint(2, "tcp"), + 'Ice.Admin.InstanceName': "IceBridge", }) del props['Ice.ThreadPool.Server.Size'] diff --git a/scripts/IceGridUtil.py b/scripts/IceGridUtil.py index 57a5fc0f0d2..722ac2d9154 100644 --- a/scripts/IceGridUtil.py +++ b/scripts/IceGridUtil.py @@ -2,12 +2,14 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, os +import sys +import os from Util import * from IceBoxUtil import * from Glacier2Util import * from IcePatch2Util import * + class IceGridProcess: def __init__(self, replica): @@ -16,7 +18,8 @@ def __init__(self, replica): def getProps(self, current): props = self.getParentProps(current) testcase = current.testcase - while testcase and not isinstance(testcase, IceGridTestCase): testcase = testcase.parent + while testcase and not isinstance(testcase, IceGridTestCase): + testcase = testcase.parent if self.replica is None: props["Ice.Default.Locator"] = testcase.getMasterLocator(current) else: @@ -27,13 +30,15 @@ def getProps(self, current): break return props + class IceGridServer(IceGridProcess, Server): def __init__(self, replica=None, *args, **kargs): Server.__init__(self, *args, **kargs) IceGridProcess.__init__(self, replica) - getParentProps = Server.getProps # Used by IceGridProcess to get the server properties + getParentProps = Server.getProps # Used by IceGridProcess to get the server properties + class IceGridClient(IceGridProcess, Client): @@ -41,7 +46,8 @@ def __init__(self, replica=None, *args, **kargs): Client.__init__(self, *args, **kargs) IceGridProcess.__init__(self, replica) - getParentProps = Client.getProps # Used by IceGridProcess to get the client properties + getParentProps = Client.getProps # Used by IceGridProcess to get the client properties + class IceGridAdmin(ProcessFromBinDir, ProcessIsReleaseOnly, IceGridClient): @@ -60,6 +66,7 @@ def getProps(self, current): props["IceGridAdmin.Password"] = self.password return props + class IceGridNode(ProcessFromBinDir, Server): def __init__(self, name="localnode", *args, **kargs): @@ -89,22 +96,22 @@ def teardown(self, current, success): def getProps(self, current): props = { - 'IceGrid.InstanceName' : 'TestIceGrid', - 'IceGrid.Node.Endpoints' : 'default', - 'IceGrid.Node.WaitTime' : 240, - 'Ice.ProgramName' : 'icegridnode', - 'IceGrid.Node.Trace.Replica' : 0, - 'IceGrid.Node.Trace.Activator' : 0, - 'IceGrid.Node.Trace.Adapter' : 0, - 'IceGrid.Node.Trace.Server' : 0, - 'IceGrid.Node.Trace.Patch' : 0, - 'IceGrid.Node.ThreadPool.SizeWarn' : 0, - 'IceGrid.Node.PrintServersReady' : 'node', - 'IceGrid.Node.Name' : self.name, - 'IceGrid.Node.Data' : '{testdir}/node-{process.name}', - 'IceGrid.Node.PropertiesOverride' : self.getPropertiesOverride(current), - 'Ice.Default.Locator' : current.testcase.getLocator(current), - 'Ice.NullHandleAbort' : 1, + 'IceGrid.InstanceName': 'TestIceGrid', + 'IceGrid.Node.Endpoints': 'default', + 'IceGrid.Node.WaitTime': 240, + 'Ice.ProgramName': 'icegridnode', + 'IceGrid.Node.Trace.Replica': 0, + 'IceGrid.Node.Trace.Activator': 0, + 'IceGrid.Node.Trace.Adapter': 0, + 'IceGrid.Node.Trace.Server': 0, + 'IceGrid.Node.Trace.Patch': 0, + 'IceGrid.Node.ThreadPool.SizeWarn': 0, + 'IceGrid.Node.PrintServersReady': 'node', + 'IceGrid.Node.Name': self.name, + 'IceGrid.Node.Data': '{testdir}/node-{process.name}', + 'IceGrid.Node.PropertiesOverride': self.getPropertiesOverride(current), + 'Ice.Default.Locator': current.testcase.getLocator(current), + 'Ice.NullHandleAbort': 1, } return props @@ -120,6 +127,7 @@ def getPropertiesOverride(self, current): def shutdown(self, current): current.testcase.runadmin(current, "node shutdown {0}".format(self.name)) + class IceGridRegistry(ProcessFromBinDir, Server): def __init__(self, name, portnum=20, ready="AdminSessionManager", *args, **kargs): @@ -150,27 +158,27 @@ def teardown(self, current, success): def getProps(self, current): props = { - 'IceGrid.InstanceName' : 'TestIceGrid', - 'IceGrid.Registry.PermissionsVerifier' : 'TestIceGrid/NullPermissionsVerifier', - 'IceGrid.Registry.AdminPermissionsVerifier' : 'TestIceGrid/NullPermissionsVerifier', - 'IceGrid.Registry.SSLPermissionsVerifier' : 'TestIceGrid/NullSSLPermissionsVerifier', - 'IceGrid.Registry.AdminSSLPermissionsVerifier' : 'TestIceGrid/NullSSLPermissionsVerifier', - 'IceGrid.Registry.Server.Endpoints' : 'default', - 'IceGrid.Registry.Internal.Endpoints' : 'default', - 'IceGrid.Registry.Client.Endpoints' : self.getEndpoints(current), - 'IceGrid.Registry.Discovery.Port' : current.driver.getTestPort(99), - 'IceGrid.Registry.SessionManager.Endpoints' : 'default', - 'IceGrid.Registry.AdminSessionManager.Endpoints' : 'default', - 'IceGrid.Registry.SessionTimeout' : 60, - 'IceGrid.Registry.ReplicaName' : self.name, - 'Ice.ProgramName' : self.name, - 'Ice.PrintAdapterReady' : 1, - 'Ice.Warn.Connections' : 0, - 'Ice.ThreadPool.Client.SizeWarn' : 0, - 'IceGrid.Registry.LMDB.MapSize' : 1, - 'IceGrid.Registry.LMDB.Path' : '{testdir}/registry-{process.name}', - 'IceGrid.Registry.Client.ThreadPool.SizeWarn' : 0, - 'IceGrid.Registry.DefaultTemplates' : + 'IceGrid.InstanceName': 'TestIceGrid', + 'IceGrid.Registry.PermissionsVerifier': 'TestIceGrid/NullPermissionsVerifier', + 'IceGrid.Registry.AdminPermissionsVerifier': 'TestIceGrid/NullPermissionsVerifier', + 'IceGrid.Registry.SSLPermissionsVerifier': 'TestIceGrid/NullSSLPermissionsVerifier', + 'IceGrid.Registry.AdminSSLPermissionsVerifier': 'TestIceGrid/NullSSLPermissionsVerifier', + 'IceGrid.Registry.Server.Endpoints': 'default', + 'IceGrid.Registry.Internal.Endpoints': 'default', + 'IceGrid.Registry.Client.Endpoints': self.getEndpoints(current), + 'IceGrid.Registry.Discovery.Port': current.driver.getTestPort(99), + 'IceGrid.Registry.SessionManager.Endpoints': 'default', + 'IceGrid.Registry.AdminSessionManager.Endpoints': 'default', + 'IceGrid.Registry.SessionTimeout': 60, + 'IceGrid.Registry.ReplicaName': self.name, + 'Ice.ProgramName': self.name, + 'Ice.PrintAdapterReady': 1, + 'Ice.Warn.Connections': 0, + 'Ice.ThreadPool.Client.SizeWarn': 0, + 'IceGrid.Registry.LMDB.MapSize': 1, + 'IceGrid.Registry.LMDB.Path': '{testdir}/registry-{process.name}', + 'IceGrid.Registry.Client.ThreadPool.SizeWarn': 0, + 'IceGrid.Registry.DefaultTemplates': '"' + os.path.abspath(os.path.join(toplevel, "cpp", "config", "templates.xml")) + '"' } if not isinstance(platform, Linux): @@ -186,11 +194,13 @@ def getLocator(self, current): def shutdown(self, current): current.testcase.runadmin(current, "registry shutdown {0}".format(self.name), replica=self.name) + class IceGridRegistryMaster(IceGridRegistry): def __init__(self, portnum=20, *args, **kargs): IceGridRegistry.__init__(self, "Master", portnum, *args, **kargs) + class IceGridRegistrySlave(IceGridRegistry): def __init__(self, replica=1, portnum=None, *args, **kargs): @@ -202,6 +212,7 @@ def getProps(self, current): props["Ice.Default.Locator"] = current.testcase.getMasterLocator(current) return props + class IceGridTestCase(TestCase): def __init__(self, name="IceGrid", icegridregistry=None, icegridnode=None, application="application.xml", @@ -222,7 +233,7 @@ def __init__(self, name="IceGrid", icegridregistry=None, icegridnode=None, appli self.targets = targets # Variables for built executables - self.exevars = { "server.dir" : "server" } + self.exevars = {"server.dir": "server"} self.exevars.update(exevars) def init(self, mapping, testsuite): @@ -244,14 +255,14 @@ def setupClientSide(self, current): javaHome = os.environ.get("JAVA_HOME", None) serverProps = Server().getProps(current) variables = { - "test.dir" : self.getPath(current), - "java.exe" : os.path.join(javaHome, "bin", "java") if javaHome else "java", - "icebox.exe" : IceBox().getCommandLine(current), - "icegridnode.exe" : IceGridNode().getCommandLine(current), - "glacier2router.exe" : Glacier2Router().getCommandLine(current), - "icepatch2server.exe" : IcePatch2Server().getCommandLine(current), - "icegridregistry.exe" : IceGridRegistryMaster().getCommandLine(current), - "properties-override" : self.icegridnode[0].getPropertiesOverride(current), + "test.dir": self.getPath(current), + "java.exe": os.path.join(javaHome, "bin", "java") if javaHome else "java", + "icebox.exe": IceBox().getCommandLine(current), + "icegridnode.exe": IceGridNode().getCommandLine(current), + "glacier2router.exe": Glacier2Router().getCommandLine(current), + "icepatch2server.exe": IcePatch2Server().getCommandLine(current), + "icegridregistry.exe": IceGridRegistryMaster().getCommandLine(current), + "properties-override": self.icegridnode[0].getPropertiesOverride(current), } if platform.getDotNetExe(): @@ -262,7 +273,7 @@ def setupClientSide(self, current): variables[k] = current.getBuildDir(v) variables.update(self.variables) - varStr = " ".join(["{0}={1}".format(k, val(v)) for k,v in variables.items()]) + varStr = " ".join(["{0}={1}".format(k, val(v)) for k, v in variables.items()]) targets = " ".join(self.targets) application = self.application if isinstance(self.mapping, CSharpMapping) and current.config.dotnet: diff --git a/scripts/IcePatch2Util.py b/scripts/IcePatch2Util.py index 428da4acefe..2f2beb17d0a 100644 --- a/scripts/IcePatch2Util.py +++ b/scripts/IcePatch2Util.py @@ -4,6 +4,7 @@ from Util import * + class IcePatch2Calc(ProcessFromBinDir, ProcessIsReleaseOnly, Process): def __init__(self, *args, **kargs): @@ -12,6 +13,7 @@ def __init__(self, *args, **kargs): def getExe(self, current): return self.exe + "_32" if current.config.buildPlatform == "ppc" else self.exe + class IcePatch2Client(ProcessFromBinDir, ProcessIsReleaseOnly, Process): def __init__(self, *args, **kargs): @@ -20,6 +22,7 @@ def __init__(self, *args, **kargs): def getExe(self, current): return self.exe + "_32" if current.config.buildPlatform == "ppc" else self.exe + class IcePatch2Server(ProcessFromBinDir, ProcessIsReleaseOnly, Process): def __init__(self, *args, **kargs): diff --git a/scripts/IceStormUtil.py b/scripts/IceStormUtil.py index 6142afbaf10..16e2558cbe2 100644 --- a/scripts/IceStormUtil.py +++ b/scripts/IceStormUtil.py @@ -7,6 +7,7 @@ from Component import component from IceBoxUtil import * + class IceStorm(ProcessFromBinDir, Server): def __init__(self, instanceName="IceStorm", replica=0, nreplicas=0, transient=False, portnum=0, @@ -46,15 +47,15 @@ def getProps(self, current): # Default properties props.update({ - 'IceBox.Service.IceStorm' : 'IceStormService,' + component.getSoVersion() + ':createIceStorm', - 'IceBox.PrintServicesReady' : 'IceStorm', - 'IceBox.InheritProperties' : 1, - 'IceStorm.InstanceName' : self.instanceName, - 'Ice.Admin.InstanceName' : 'IceBox', - 'Ice.Warn.Dispatch' : 0, - 'Ice.Warn.Connections' : 0, - 'IceStorm.LMDB.MapSize' : 1, - 'IceStorm.LMDB.Path' : '{testdir}/{process.instanceName}-{process.replica}.db', + 'IceBox.Service.IceStorm': 'IceStormService,' + component.getSoVersion() + ':createIceStorm', + 'IceBox.PrintServicesReady': 'IceStorm', + 'IceBox.InheritProperties': 1, + 'IceStorm.InstanceName': self.instanceName, + 'Ice.Admin.InstanceName': 'IceBox', + 'Ice.Warn.Dispatch': 0, + 'Ice.Warn.Connections': 0, + 'IceStorm.LMDB.MapSize': 1, + 'IceStorm.LMDB.Path': '{testdir}/{process.instanceName}-{process.replica}.db', }) if self.nreplicas > 0: @@ -72,17 +73,18 @@ def getProps(self, current): # # Manager, publish, node and admin endpoints for given replica number - manager = lambda replica: current.getTestEndpoint(self.portnum + replica * 4 + 0) - publish = lambda replica: "{0}:{1}".format(current.getTestEndpoint(self.portnum + replica * 4 + 1), - current.getTestEndpoint(self.portnum + replica * 4 + 1, "udp")) - node = lambda replica: current.getTestEndpoint(self.portnum + replica * 4 + 2) - admin = lambda replica: current.getTestEndpoint(self.portnum + replica * 4 + 3) + def manager(replica): return current.getTestEndpoint(self.portnum + replica * 4 + 0) + def publish(replica): return "{0}:{1}".format(current.getTestEndpoint(self.portnum + replica * 4 + 1), + current.getTestEndpoint(self.portnum + replica * 4 + 1, "udp")) + + def node(replica): return current.getTestEndpoint(self.portnum + replica * 4 + 2) + def admin(replica): return current.getTestEndpoint(self.portnum + replica * 4 + 3) # The endpoints for the given replica props.update({ - "IceStorm.TopicManager.Endpoints" : manager(self.replica), - "IceStorm.Publish.Endpoints" : publish(self.replica), - "Ice.Admin.Endpoints" : admin(self.replica), + "IceStorm.TopicManager.Endpoints": manager(self.replica), + "IceStorm.Publish.Endpoints": publish(self.replica), + "Ice.Admin.Endpoints": admin(self.replica), }) # Compute the node and replicated endpoints to be configured for each replica @@ -106,15 +108,17 @@ def getReplicatedTopicManager(self, current): # Return the replicated endpoints for IceStorm if self.nreplicas == 0: return self.getTopicManager(current) - manager = lambda replica: current.getTestEndpoint(self.portnum + replica * 4) + + def manager(replica): return current.getTestEndpoint(self.portnum + replica * 4) return "{1}/TopicManager:{0}".format(":".join([manager(i) for i in range(0, self.nreplicas)]), self.instanceName) def shutdown(self, current): # Shutdown this replica by connecting to the IceBox service manager with iceboxadmin endpoint = current.getTestEndpoint(self.portnum + self.replica * 4 + 3) - props = { "IceBoxAdmin.ServiceManager.Proxy" : "IceBox/admin -f IceBox.ServiceManager:" + endpoint } + props = {"IceBoxAdmin.ServiceManager.Proxy": "IceBox/admin -f IceBox.ServiceManager:" + endpoint} IceBoxAdmin().run(current, props=props, args=['shutdown']) + class IceStormProcess: def __init__(self, instanceName=None, instance=None): @@ -134,7 +138,8 @@ def getProps(self, current): props = self.getParentProps(current) testcase = current.testcase - while testcase and not isinstance(testcase, IceStormTestCase): testcase = testcase.parent + while testcase and not isinstance(testcase, IceStormTestCase): + testcase = testcase.parent if self.instance: props["IceStormAdmin.TopicManager.Default"] = self.instance.getTopicManager(current) else: @@ -146,6 +151,7 @@ def getProps(self, current): props["IceStormAdmin.TopicManager.{0}".format(name)] = testcase.getTopicManager(current, name) return props + class IceStormAdmin(ProcessFromBinDir, ProcessIsReleaseOnly, IceStormProcess, Client): def __init__(self, instanceName=None, instance=None, *args, **kargs): @@ -158,7 +164,8 @@ def getExe(self, current): else: return self.exe - getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + class Subscriber(IceStormProcess, Server): @@ -168,7 +175,8 @@ def __init__(self, instanceName=None, instance=None, *args, **kargs): Server.__init__(self, *args, **kargs) IceStormProcess.__init__(self, instanceName, instance) - getParentProps = Server.getProps # Used by IceStormProcess to get the server properties + getParentProps = Server.getProps # Used by IceStormProcess to get the server properties + class Publisher(IceStormProcess, Client): @@ -178,7 +186,8 @@ def __init__(self, instanceName=None, instance=None, *args, **kargs): Client.__init__(self, *args, **kargs) IceStormProcess.__init__(self, instanceName, instance) - getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + getParentProps = Client.getProps # Used by IceStormProcess to get the client properties + class IceStormTestCase(TestCase): diff --git a/scripts/LocalDriver.py b/scripts/LocalDriver.py index 84d8a250c01..5053a2ce7c0 100644 --- a/scripts/LocalDriver.py +++ b/scripts/LocalDriver.py @@ -2,12 +2,18 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, os, time, threading, queue +import sys +import os +import time +import threading +import queue from Util import * # # The Executor class runs testsuites on multiple worker threads. # + + class Executor: def __init__(self, threadlocal, workers, continueOnFailure): @@ -64,7 +70,7 @@ def runTestSuites(self, driver, total, results, mainThread=False): while True: item = self.get(total, mainThread) if not item: - results.put(None) # Notify the main thread that there are not more tests to run + results.put(None) # Notify the main thread that there are not more tests to run break (testsuite, index) = item @@ -81,7 +87,8 @@ def runTestSuites(self, driver, total, results, mainThread=False): current.destroy() results.put((result, mainThread)) if not result.isSuccess() and not self.continueOnFailure: - with self.lock: self.failure = True + with self.lock: + self.failure = True def runUntilCompleted(self, driver, start): if self.queueLength == 0: @@ -101,22 +108,23 @@ def runUntilCompleted(self, driver, start): # resultList = [] results = queue.Queue() + def worker(num): self.threadlocal.num = num try: self.runTestSuites(driver, total, results) except Exception as ex: print("unexpected exception raised from worker thread:\n" + str(ex)) - results.put(None) # Notify the main thread that we're done + results.put(None) # Notify the main thread that we're done # # Start the worker threads # - threads=[] + threads = [] for i in range(min(self.workers, total)): - t = threading.Thread(target=worker, args=[i]) - t.start() - threads.append(t) + t = threading.Thread(target=worker, args=[i]) + t.start() + threads.append(t) try: # @@ -176,6 +184,8 @@ def worker(num): # # Runner to run the test cases locally. # + + class TestCaseRunner: def getTestSuites(self, mapping, testSuiteIds): @@ -196,6 +206,8 @@ def runClientSide(self, testcase, current, host): # # Runner to run the test cases remotely with the controller (requires IcePy) # + + class RemoteTestCaseRunner(TestCaseRunner): def __init__(self, communicator, clientPrx, serverPrx): @@ -311,6 +323,7 @@ def getConfig(self, current): current.config.cprops, current.config.sprops) + class XmlExporter: def __init__(self, results, duration, failures): @@ -328,6 +341,7 @@ def save(self, filename, hostname): r.writeAsXml(out, hostname) out.write('\n') + class LocalDriver(Driver): class Current(Driver.Current): @@ -374,13 +388,13 @@ def __init__(self, options, *args, **kargs): self.clientCtlPrx = "" self.serverCtlPrx = "" - parseOptions(self, options, { "continue" : "continueOnFailure", - "l" : "loop", - "all-cross" : "allCross", - "client" : "clientCtlPrx", - "server" : "serverCtlPrx", - "show-durations" : "showDurations", - "export-xml" : "exportToXml" }) + parseOptions(self, options, {"continue": "continueOnFailure", + "l": "loop", + "all-cross": "allCross", + "client": "clientCtlPrx", + "server": "serverCtlPrx", + "show-durations": "showDurations", + "export-xml": "exportToXml"}) if self.cross: self.cross = Mapping.getByName(self.cross) @@ -409,6 +423,7 @@ def run(self, mappings, testSuiteIds): # Sort the test suites to run tests in the following order. # runOrder = self.component.getRunOrder() + def testsuiteKey(testsuite): for k in runOrder: if testsuite.getId().startswith(k + '/'): @@ -448,7 +463,7 @@ def testsuiteKey(testsuite): print("Ran {0} tests in {1:02.2f} seconds".format(len(results), s)) if self.showDurations: - for r in sorted(results, key = lambda r : r.getDuration()): + for r in sorted(results, key=lambda r: r.getDuration()): print("- {0} took {1:02.2f} seconds".format(r.testsuite, r.getDuration())) self.loopCount += 1 @@ -471,7 +486,7 @@ def testsuiteKey(testsuite): if not self.loop: return 0 finally: - Expect.cleanup() # Cleanup processes which might still be around + Expect.cleanup() # Cleanup processes which might still be around def runTestSuite(self, current): if self.loop: @@ -569,16 +584,17 @@ def runClientServerTestCase(self, current): # failure = [] sem = threading.Semaphore(0) + def stopServerSide(): try: self.runner.stopServerSide(server, current, success) except Exception as ex: failure.append(ex) - except KeyboardInterrupt: # Potentially raised by Except.py if Ctrl-C + except KeyboardInterrupt: # Potentially raised by Except.py if Ctrl-C pass sem.release() - t=threading.Thread(target = stopServerSide) + t = threading.Thread(target=stopServerSide) t.start() while True: try: @@ -592,7 +608,7 @@ def stopServerSide(): t.join() break except KeyboardInterrupt: - pass # Ignore keyboard interrupts + pass # Ignore keyboard interrupts def runTestCase(self, current): if self.cross or self.allCross: @@ -631,7 +647,7 @@ def setInterrupt(self, value): def getTestPort(self, portnum): # Return a port number in the range 14100-14199 for the first thread, 14200-14299 for the # second thread, etc. - assert(portnum < 100) + assert (portnum < 100) baseport = 14000 + self.threadlocal.num * 100 if hasattr(self.threadlocal, "num") else 12010 return baseport + portnum @@ -651,4 +667,5 @@ def getMappings(self): def filterOptions(self, options): return self.runner.filterOptions(options) + Driver.add("local", LocalDriver) diff --git a/scripts/NetworkProxy.py b/scripts/NetworkProxy.py index 7959be9fe32..5c8188d0005 100644 --- a/scripts/NetworkProxy.py +++ b/scripts/NetworkProxy.py @@ -53,12 +53,12 @@ def run(self): return try: - while(not self.closed): + while (not self.closed): readables, writeables, exceptions = select.select([self.socket, self.remoteSocket], [], []) for r in readables: w = self.remoteSocket if r == self.socket else self.socket data = r.recv(4096) - if(len(data) == 0): + if (len(data) == 0): self.closed = True break w.send(data) @@ -198,7 +198,7 @@ def decode(c): return c[0] if sys.version_info[0] == 2 else chr(c[0]) data = "" - while(len(data) < 4 or data[len(data) - 4:] != "\r\n\r\n"): + while (len(data) < 4 or data[len(data) - 4:] != "\r\n\r\n"): data += decode(s.recv(1)) if data.find("CONNECT ") != 0: @@ -217,7 +217,7 @@ def decode(c): return (host, port) def response(self, success): - if(success): + if (success): s = "HTTP/1.1 200 OK\r\nServer: CERN/3.0 libwww/2.17\r\n\r\n" else: s = "HTTP/1.1 404\r\n\r\n" diff --git a/scripts/Util.py b/scripts/Util.py index 93a3d880c85..f0e46d6d33b 100644 --- a/scripts/Util.py +++ b/scripts/Util.py @@ -2,8 +2,21 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys, runpy, getopt, traceback, types, threading, time, re, itertools, random, subprocess, shutil -import copy, xml.sax.saxutils +import os +import sys +import runpy +import getopt +import traceback +import types +import threading +import time +import re +import itertools +import random +import subprocess +import shutil +import copy +import xml.sax.saxutils from platform import machine as platform_machine from io import StringIO @@ -13,6 +26,7 @@ toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + def run(cmd, cwd=None, err=False, stdout=False, stdin=None, stdinRepeat=True): p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=None if stdout else subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd) @@ -29,7 +43,7 @@ def run(cmd, cwd=None, err=False, stdout=False, stdin=None, stdinRepeat=True): pass out = (p.stderr if stdout else p.stdout).read().decode('UTF-8').strip() - if(not err and p.wait() != 0) or (err and p.wait() == 0) : + if (not err and p.wait() != 0) or (err and p.wait() == 0): raise RuntimeError(cmd + " failed:\n" + out) finally: # @@ -44,6 +58,7 @@ def run(cmd, cwd=None, err=False, stdout=False, stdin=None, stdinRepeat=True): pass return out + def val(v, quoteValue=True): if type(v) == bool: return "1" if v else "0" @@ -55,18 +70,23 @@ def val(v, quoteValue=True): else: return str(v) + illegalXMLChars = re.compile(u'[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]') + def escapeXml(s, attribute=False): # Remove backspace characters from the output (they aren't accepted by Jenkins XML parser) s = "".join(ch for ch in s if ch != u"\u0008") - s = illegalXMLChars.sub("?", s) # Strip invalid XML characters + s = illegalXMLChars.sub("?", s) # Strip invalid XML characters return xml.sax.saxutils.quoteattr(s) if attribute else xml.sax.saxutils.escape(s) + """ Component abstract class. The driver and mapping classes rely on the component class to provide component specific information. """ + + class Component(object): def __init__(self): @@ -75,6 +95,7 @@ def __init__(self): """ Returns whether or not to use the binary distribution. """ + def useBinDist(self, mapping, current): return True @@ -82,6 +103,7 @@ def useBinDist(self, mapping, current): Returns the component installation directory if using a binary distribution or the mapping directory if using a source distribution. """ + def getInstallDir(self, mapping, current): raise Error("must be overridden") @@ -201,6 +223,7 @@ def _getInstallDir(self, mapping, current, envHomeName): else: return self.getSourceDir() + class Platform(object): def __init__(self): @@ -215,8 +238,8 @@ def __init__(self): def init(self, component): self.parseBuildVariables(component, { - "supported-platforms" : ("supportedPlatforms", lambda s : s.split(" ")), - "supported-configs" : ("supportedConfigs", lambda s : s.split(" ")) + "supported-platforms": ("supportedPlatforms", lambda s: s.split(" ")), + "supported-configs": ("supportedConfigs", lambda s: s.split(" ")) }) def hasDotNet(self): @@ -245,7 +268,7 @@ def hasSwift(self, version): def parseBuildVariables(self, component, variables): # Run make to get the values of the given variables - if os.path.exists(os.path.join(component.getSourceDir(), "Makefile")): # Top level makefile + if os.path.exists(os.path.join(component.getSourceDir(), "Makefile")): # Top level makefile cwd = component.getSourceDir() elif Mapping.getByName("cpp"): cwd = Mapping.getByName("cpp").getPath() @@ -306,6 +329,7 @@ def hasOpenSSL(self): def getDotNetExe(self): return "dotnet" + class Darwin(Platform): def getDefaultBuildPlatform(self): @@ -317,6 +341,7 @@ def getLdPathEnvName(self): def getInstallDir(self): return "/usr/local" + class AIX(Platform): def hasOpenSSL(self): @@ -335,6 +360,7 @@ def getDefaultBuildPlatform(self): def getInstallDir(self): return "/opt/freeware" + class Linux(Platform): def __init__(self): @@ -347,15 +373,14 @@ def __init__(self): def init(self, component): Platform.init(self, component) self.parseBuildVariables(component, { - "linux_id" : ("linuxId", None), - "build-platform" : ("buildPlatform", None), - "foreign-platforms" : ("foreignPlatforms", lambda s : s.split(" ") if s else []), + "linux_id": ("linuxId", None), + "build-platform": ("buildPlatform", None), + "foreign-platforms": ("foreignPlatforms", lambda s: s.split(" ") if s else []), }) if self.linuxId in ["ubuntu", "debian"]: for p in [self.buildPlatform] + self.foreignPlatforms: self.multiArch[p] = run("dpkg-architecture -f -a{0} -qDEB_HOST_MULTIARCH 2> /dev/null".format(p)) - def hasOpenSSL(self): return True @@ -398,6 +423,7 @@ def getBuildSubDir(self, mapping, name, current): def getLinuxId(self): return self.linuxId + class Windows(Platform): def __init__(self): @@ -405,7 +431,7 @@ def __init__(self): self.compiler = None def parseBuildVariables(self, component, variables): - pass # Nothing to do, we don't support the make build system on Windows + pass # Nothing to do, we don't support the make build system on Windows def getDefaultBuildPlatform(self): return "x64" if "X64" in os.environ.get("PLATFORM", "") else "Win32" @@ -497,7 +523,7 @@ def getLdPathEnvName(self): return "PATH" def getInstallDir(self): - return None # No default installation directory on Windows + return None # No default installation directory on Windows def getNugetPackageDir(self, component, mapping, current): if isinstance(mapping, CSharpMapping) and current.config.dotnet: @@ -517,16 +543,19 @@ def getDotNetExe(self): except: return None + def parseOptions(obj, options, mapped={}): # Transform configuration options provided on the command line to # object data members. The data members must be already set on the # object and with the correct type. if not hasattr(obj, "parsedOptions"): - obj.parsedOptions=[] + obj.parsedOptions = [] remaining = [] for (o, a) in options: - if o.startswith("--"): o = o[2:] - if o.startswith("-"): o = o[1:] + if o.startswith("--"): + o = o[2:] + if o.startswith("-"): + o = o[1:] if not a and o.startswith("no-"): a = "false" o = o[3:] @@ -549,11 +578,14 @@ def parseOptions(obj, options, mapped={}): remaining.append((o, a)) options[:] = remaining + """ Mapping abstract class. The mapping class provides mapping specific information. Multiple components can share the same mapping rules as long as the layout is similar. """ + + class Mapping(object): mappings = OrderedDict() @@ -621,13 +653,14 @@ def __init__(self, options=[]): self.phpVersion = "7.1" self.python = sys.executable - parseOptions(self, options, { "config" : "buildConfig", "platform" : "buildPlatform" }) + parseOptions(self, options, {"config": "buildConfig", "platform": "buildPlatform"}) def __str__(self): s = [] for o in self.parsedOptions: v = getattr(self, o) - if v: s.append(o if type(v) == bool else str(v)) + if v: + s.append(o if type(v) == bool else str(v)) return ",".join(s) def getAll(self, current, testcase, rand=False): @@ -757,7 +790,7 @@ def getProps(self, process, current): if self.mx: props["Ice.Admin.Endpoints"] = "tcp -h \"::1\"" if self.ipv6 else "tcp -h 127.0.0.1" props["Ice.Admin.InstanceName"] = "Server" if isinstance(process, Server) else "Client" - props["IceMX.Metrics.Debug.GroupBy"] ="id" + props["IceMX.Metrics.Debug.GroupBy"] = "id" props["IceMX.Metrics.Parent.GroupBy"] = "parent" props["IceMX.Metrics.All.GroupBy"] = "none" @@ -785,7 +818,7 @@ def getProps(self, process, current): for pps in additionalProps: for p in pps.split(" "): if p.find("=") > 0: - (k , v) = p.split("=") + (k, v) = p.split("=") props[k] = v else: props[p] = True @@ -900,7 +933,7 @@ def loadTestSuites(self, tests, config, filters=[], rfilters=[]): # # First check if there's a test.py file in the test directory, if there's one use it. # - if "test.py" in files : + if "test.py" in files: # # WORKAROUND for Python issue 15230 (fixed in 3.2) where run_path doesn't work correctly. # @@ -956,8 +989,8 @@ def checkFile(f, m): # Expected if the mapping doesn't support the process type return False - checkClient = lambda f: checkFile(f, self.getClientMapping(testId)) - checkServer = lambda f: checkFile(f, self.getServerMapping(testId)) + def checkClient(f): return checkFile(f, self.getClientMapping(testId)) + def checkServer(f): return checkFile(f, self.getServerMapping(testId)) testcases = [] if checkClient("client") and checkServer("server"): @@ -1060,7 +1093,7 @@ def getProps(self, process, current): def getSSLProps(self, process, current): sslProps = { - "Ice.Plugin.IceSSL" : self.getPluginEntryPoint("IceSSL", process, current), + "Ice.Plugin.IceSSL": self.getPluginEntryPoint("IceSSL", process, current), "IceSSL.Password": "password", "IceSSL.DefaultDir": "" if current.config.buildPlatform == "iphoneos" else os.path.join(self.component.getSourceDir(), "certs"), } @@ -1087,17 +1120,19 @@ def getOptions(self, current): # A Runnable can be used as a "client" for in test cases, it provides # implements run, setup and teardown methods. # + + class Runnable(object): def __init__(self, desc=None): self.desc = desc def setup(self, current): - ### Only called when ran from testcase + # Only called when ran from testcase pass def teardown(self, current, success): - ### Only called when ran from testcase + # Only called when ran from testcase pass def run(self, current): @@ -1106,6 +1141,8 @@ def run(self, current): # # A Process describes how to run an executable process. # + + class Process(Runnable): processType = None @@ -1129,7 +1166,7 @@ def __str__(self): return self.exe + (" ({0})".format(self.desc) if self.desc else "") def getOutput(self, current, encoding="utf-8"): - assert(self in current.processes) + assert (self in current.processes) def d(s): return s.decode(encoding) if isinstance(s, bytes) else s @@ -1171,7 +1208,8 @@ def __init__(self, timeout): self.lock = threading.Lock() def reset(self): - with self.lock: self.lastProgressTime = time.time() + with self.lock: + self.lastProgressTime = time.time() def timedOut(self, timeout): with self.lock: @@ -1294,7 +1332,7 @@ def stop(self, current, waitSuccess=False, exitstatus=0): finally: if not process.isTerminated(): process.terminate() - if not self.quiet: # Write the output to the test case (but not on stdout) + if not self.quiet: # Write the output to the test case (but not on stdout) current.write(self.getOutput(current), stdout=False) def teardown(self, current, success): @@ -1302,19 +1340,19 @@ def teardown(self, current, success): current.processes[self].teardown(current, success) def expect(self, current, pattern, timeout=60): - assert(self in current.processes and isinstance(current.processes[self], Expect.Expect)) + assert (self in current.processes and isinstance(current.processes[self], Expect.Expect)) return current.processes[self].expect(pattern, timeout) def expectall(self, current, pattern, timeout=60): - assert(self in current.processes and isinstance(current.processes[self], Expect.Expect)) + assert (self in current.processes and isinstance(current.processes[self], Expect.Expect)) return current.processes[self].expectall(pattern, timeout) def sendline(self, current, data): - assert(self in current.processes and isinstance(current.processes[self], Expect.Expect)) + assert (self in current.processes and isinstance(current.processes[self], Expect.Expect)) return current.processes[self].sendline(data) def getMatch(self, current): - assert(self in current.processes and isinstance(current.processes[self], Expect.Expect)) + assert (self in current.processes and isinstance(current.processes[self], Expect.Expect)) return current.processes[self].match def isStarted(self, current): @@ -1348,6 +1386,8 @@ def getCommandLine(self, current, args=""): # # A simple client (used to run Slice/IceUtil clients for example) # + + class SimpleClient(Process): pass @@ -1355,6 +1395,8 @@ class SimpleClient(Process): # An IceProcess specialization class. This is used by drivers to figure out if # the process accepts Ice configuration properties. # + + class IceProcess(Process): pass @@ -1364,6 +1406,8 @@ class IceProcess(Process): # the server is considered "ready". It can also be configure to wait (the default) # or not wait for shutdown when the stop method is invoked. # + + class Server(IceProcess): def __init__(self, exe=None, waitForShutdown=True, readyCount=1, ready=None, startTimeout=300, *args, **kargs): @@ -1380,12 +1424,14 @@ def getProps(self, current): "Ice.ThreadPool.Server.SizeMax": 3, "Ice.ThreadPool.Server.SizeWarn": 0, }) - props.update(current.driver.getProcessProps(current, self.ready, self.readyCount + (1 if current.config.mx else 0))) + props.update(current.driver.getProcessProps(current, self.ready, + self.readyCount + (1 if current.config.mx else 0))) return props def waitForStart(self, current): # Wait for the process to be ready - current.processes[self].waitReady(self.ready, self.readyCount + (1 if current.config.mx else 0), self.startTimeout) + current.processes[self].waitReady(self.ready, self.readyCount + + (1 if current.config.mx else 0), self.startTimeout) # Filter out remaining ready messages self.outfilters.append(re.compile("[^\n]+ ready")) @@ -1400,6 +1446,8 @@ def stop(self, current, waitSuccess=False, exitstatus=0): # # An Ice client process. # + + class Client(IceProcess): pass @@ -1407,6 +1455,8 @@ class Client(IceProcess): # Executables for processes inheriting this marker class are looked up in the # Ice distribution bin directory. # + + class ProcessFromBinDir: def isFromBinDir(self): @@ -1416,11 +1466,14 @@ def isFromBinDir(self): # Executables for processes inheriting this marker class are only provided # as a Release executable on Windows # + + class ProcessIsReleaseOnly: def isReleaseOnly(self): return True + class SliceTranslator(ProcessFromBinDir, ProcessIsReleaseOnly, SimpleClient): def __init__(self, translator): @@ -1438,12 +1491,15 @@ def getCommandLine(self, current, args=""): else: return Process.getCommandLine(self, current, args) + class ServerAMD(Server): pass + class Collocated(Client): pass + class EchoServer(Server): def __init__(self): @@ -1451,7 +1507,7 @@ def __init__(self): def getProps(self, current): props = Server.getProps(self, current) - props["Ice.MessageSizeMax"] = 8192 # Don't limit the amount of data to transmit between client/server + props["Ice.MessageSizeMax"] = 8192 # Don't limit the amount of data to transmit between client/server return props def getCommandLine(self, current, args=""): @@ -1470,6 +1526,8 @@ def getCommandLine(self, current, args=""): # A TestCase is also a "Runnable", like the Process class. In other words, it can be # used a client to allow nested test cases. # + + class TestCase(Runnable): def __init__(self, name, client=None, clients=None, server=None, servers=None, args=None, props=None, envs=None, @@ -1519,7 +1577,8 @@ def init(self, mapping, testsuite): testId = self.testsuite.getId() if not self.clients: if self.getClientType(): - self.clients = self.mapping.getClientMapping(testId).getDefaultProcesses(self.getClientType(), testsuite) + self.clients = self.mapping.getClientMapping( + testId).getDefaultProcesses(self.getClientType(), testsuite) else: self.clients = [] @@ -1529,7 +1588,8 @@ def init(self, mapping, testsuite): # if not self.servers: if self.getServerType(): - self.servers = self.mapping.getServerMapping(testId).getDefaultProcesses(self.getServerType(), testsuite) + self.servers = self.mapping.getServerMapping( + testId).getDefaultProcesses(self.getServerType(), testsuite) else: self.servers = [] @@ -1709,6 +1769,7 @@ def run(self, current): finally: current.pop() + class ClientTestCase(TestCase): def __init__(self, name="client", *args, **kargs): @@ -1720,6 +1781,7 @@ def runWithDriver(self, current): def getClientType(self): return "client" + class ClientServerTestCase(ClientTestCase): def __init__(self, name="client/server", *args, **kargs): @@ -1731,6 +1793,7 @@ def runWithDriver(self, current): def getServerType(self): return "server" + class CollocatedTestCase(ClientTestCase): def __init__(self, name="collocated", *args, **kargs): @@ -1739,6 +1802,7 @@ def __init__(self, name="collocated", *args, **kargs): def getClientType(self): return "collocated" + class ClientAMDServerTestCase(ClientServerTestCase): def __init__(self, name="client/amd server", *args, **kargs): @@ -1747,6 +1811,7 @@ def __init__(self, name="client/amd server", *args, **kargs): def getServerType(self): return "serveramd" + class ClientTieServerTestCase(ClientServerTestCase): def __init__(self, name="client/tie server", *args, **kargs): @@ -1755,6 +1820,7 @@ def __init__(self, name="client/tie server", *args, **kargs): def getServerType(self): return "servertie" + class ClientAMDTieServerTestCase(ClientServerTestCase): def __init__(self, name="client/amd tie server", *args, **kargs): @@ -1763,10 +1829,13 @@ def __init__(self, name="client/amd tie server", *args, **kargs): def getServerType(self): return "serveramdtie" + class Result: - getKey = lambda self, current: (current.testcase, current.config) if isinstance(current, Driver.Current) else current - getDesc = lambda self, current: current.desc if isinstance(current, Driver.Current) else "" + def getKey(self, current): return (current.testcase, current.config) if isinstance( + current, Driver.Current) else current + + def getDesc(self, current): return current.desc if isinstance(current, Driver.Current) else "" def __init__(self, testsuite, writeToStdout): self.testsuite = testsuite @@ -1776,7 +1845,7 @@ def __init__(self, testsuite, writeToStdout): self._writeToStdout = writeToStdout self._testcases = {} self._duration = 0 - self._testCaseDuration = 0; + self._testCaseDuration = 0 def start(self): self._duration = time.time() @@ -1785,13 +1854,13 @@ def finished(self): self._duration = time.time() - self._duration def started(self, current): - self._testCaseDuration = time.time(); + self._testCaseDuration = time.time() self._start = self._stdout.tell() def failed(self, current, exception): print(exception) key = self.getKey(current) - self._testCaseDuration = time.time() - self._testCaseDuration; + self._testCaseDuration = time.time() - self._testCaseDuration self.writeln("\ntest in {0} failed:\n{1}".format(self.testsuite, exception)) self._testcases[key] = (self._start, self._stdout.tell(), self._testCaseDuration, self.getDesc(current)) self._failed[key] = exception @@ -1808,7 +1877,7 @@ def failed(self, current, exception): def succeeded(self, current): key = self.getKey(current) - self._testCaseDuration = time.time() - self._testCaseDuration; + self._testCaseDuration = time.time() - self._testCaseDuration self._testcases[key] = (self._start, self._stdout.tell(), self._testCaseDuration, self.getDesc(current)) def skipped(self, current, reason): @@ -1868,12 +1937,12 @@ def writeln(self, msg, stdout=True): def writeAsXml(self, out, hostname=""): out.write(' \n' - .format(len(self._testcases) - 2, - len(self._failed), - 0, - self._duration, - self.testsuite, - self.testsuite.getMapping())) + .format(len(self._testcases) - 2, + len(self._failed), + 0, + self._duration, + self.testsuite, + self.testsuite.getMapping())) for (k, v) in self._testcases.items(): if isinstance(k, str): @@ -1915,7 +1984,8 @@ def writeAsXml(self, out, hostname=""): out.write(' \n') out.write(' \n') - out.write( '\n') + out.write('\n') + class TestSuite(object): @@ -1971,7 +2041,7 @@ def isMainThreadOnly(self, driver): config = driver.configs[self.mapping] if "iphone" in config.buildPlatform or config.browser or config.android: - return True # Not supported yet for tests that require a remote process controller + return True # Not supported yet for tests that require a remote process controller return False def addTestCase(self, testcase): @@ -1992,13 +2062,14 @@ def setup(self, current): def run(self, current): try: current.result.start() - cwd=None + cwd = None if self.chdir: cwd = os.getcwd() os.chdir(self.path) current.driver.runTestSuite(current) finally: - if cwd: os.chdir(cwd) + if cwd: + os.chdir(cwd) current.result.finished() def teardown(self, current, success): @@ -2007,6 +2078,7 @@ def teardown(self, current, success): def isMultiHost(self): return self.multihost + class ProcessController: def __init__(self, current): @@ -2018,6 +2090,7 @@ def start(self, process, current, args, props, envs, watchDog): def destroy(self, driver): pass + class LocalProcessController(ProcessController): class LocalProcess(Expect.Expect): @@ -2028,10 +2101,10 @@ def __init__(self, traceFile, *args, **kargs): def waitReady(self, ready, readyCount, startTimeout): if ready: - self.expect("%s ready\n" % ready, timeout = startTimeout) + self.expect("%s ready\n" % ready, timeout=startTimeout) else: while readyCount > 0: - self.expect("[^\n]+ ready\n", timeout = startTimeout) + self.expect("[^\n]+ ready\n", timeout=startTimeout) readyCount -= 1 def isTerminated(self): @@ -2073,14 +2146,14 @@ def start(self, process, current, args, props, envs, watchDog): traceProps["Ice.LogFile"] = traceFile props.update(traceProps) - args = ["--{0}={1}".format(k, val(v)) for k,v in props.items()] + [val(a) for a in args] + args = ["--{0}={1}".format(k, val(v)) for k, v in props.items()] + [val(a) for a in args] for k, v in envs.items(): envs[k] = val(v, quoteValue=False) cmd = "" if current.driver.valgrind: cmd += "valgrind -q --child-silent-after-fork=yes --leak-check=full --suppressions=\"{0}\" ".format( - os.path.join(current.driver.getComponent().getSourceDir(), "config", "valgrind.sup")) + os.path.join(current.driver.getComponent().getSourceDir(), "config", "valgrind.sup")) exe = process.getCommandLine(current, " ".join(args)) cmd += exe.format(**kargs) @@ -2105,6 +2178,7 @@ def start(self, process, current, args, props, envs, watchDog): process.startReader(watchDog) return process + class RemoteProcessController(ProcessController): class RemoteProcess: @@ -2208,7 +2282,7 @@ def getController(self, current): if current.driver.controllerApp: if ident in self.controllerApps: - self.restartControllerApp(current, ident) # Controller must have crashed, restart it + self.restartControllerApp(current, ident) # Controller must have crashed, restart it else: self.controllerApps.append(ident) self.startControllerApp(current, ident) @@ -2258,10 +2332,11 @@ def setProcessController(self, proxy): with self.cond: self.processControllerProxies[proxy.ice_getIdentity()] = proxy conn = proxy.ice_getConnection() - if(hasattr(conn, "setCloseCallback")): - proxy.ice_getConnection().setCloseCallback(lambda conn : self.clearProcessController(proxy, conn)) + if (hasattr(conn, "setCloseCallback")): + proxy.ice_getConnection().setCloseCallback(lambda conn: self.clearProcessController(proxy, conn)) else: import Ice + class CallbackI(Ice.ConnectionCallback): def __init__(self, registry): self.registry = registry @@ -2304,7 +2379,7 @@ def start(self, process, current, args, props, envs, watchDog): # TODO: support envs? exe = process.getExe(current) - args = ["--{0}={1}".format(k, val(v, quoteValue=False)) for k,v in props.items()] + [val(a) for a in args] + args = ["--{0}={1}".format(k, val(v, quoteValue=False)) for k, v in props.items()] + [val(a) for a in args] if current.driver.debug: current.writeln("(executing `{0}/{1}' on `{2}' args = {3})".format(current.testsuite, exe, self, args)) prx = processController.start(str(current.testsuite), exe, args) @@ -2323,6 +2398,7 @@ def destroy(self, driver): if self.adapter: self.adapter.destroy() + class AndroidProcessController(RemoteProcessController): def __init__(self, current): @@ -2334,7 +2410,7 @@ def __init__(self, current): RemoteProcessController.__init__(self, current, endpoint) self.device = current.config.device self.avd = current.config.avd - self.emulator = None # Keep a reference to the android emulator process + self.emulator = None # Keep a reference to the android emulator process def __str__(self): return "Android" @@ -2370,7 +2446,8 @@ def startEmulator(self, avd): raise RuntimeError("cannot find free port in range 5554-5584, to run android emulator") self.device = "emulator-{}".format(port) - cmd = "emulator -avd {0} -port {1} -no-audio -partition-size 768 -no-snapshot -gpu auto -no-boot-anim -no-window".format(avd, port) + cmd = "emulator -avd {0} -port {1} -no-audio -partition-size 768 -no-snapshot -gpu auto -no-boot-anim -no-window".format( + avd, port) self.emulator = subprocess.Popen(cmd, shell=True) if self.emulator.poll(): @@ -2388,7 +2465,7 @@ def startEmulator(self, avd): if len(lines) > 0 and lines[0].strip() == "1": break except RuntimeError: - pass # expected if device is offline + pass # expected if device is offline # # If the emulator doesn't complete boot in 300 seconds give up # @@ -2409,11 +2486,11 @@ def startControllerApp(self, current, ident): sdk = current.testcase.getMapping().getSDKPackage() print("creating virtual device ({0})... ".format(sdk)) try: - run("avdmanager -v delete avd -n IceTests") # Delete the created device + run("avdmanager -v delete avd -n IceTests") # Delete the created device except: pass # The SDK is downloaded by test VMs instead of here. - #run("sdkmanager \"{0}\"".format(sdk), stdout=True, stdin="yes", stdinRepeat=True) # yes to accept licenses + # run("sdkmanager \"{0}\"".format(sdk), stdout=True, stdin="yes", stdinRepeat=True) # yes to accept licenses run("avdmanager -v create avd -k \"{0}\" -d \"Nexus 6\" -n IceTests".format(sdk)) self.startEmulator("IceTests") elif current.config.device != "usb": @@ -2442,7 +2519,7 @@ def stopControllerApp(self, ident): if self.avd == "IceTests": try: - run("avdmanager -v delete avd -n IceTests") # Delete the created device + run("avdmanager -v delete avd -n IceTests") # Delete the created device except: pass @@ -2465,6 +2542,7 @@ def stopControllerApp(self, ident): except: pass + class iOSSimulatorProcessController(RemoteProcessController): device = "iOSSimulatorProcessController" @@ -2483,7 +2561,7 @@ def __init__(self, current): except: pass if not self.runtimeID: - self.runtimeID = "com.apple.CoreSimulator.SimRuntime.iOS-15-2" # Default value + self.runtimeID = "com.apple.CoreSimulator.SimRuntime.iOS-15-2" # Default value def __str__(self): return "iOS Simulator ({})".format(self.runtimeID.replace("com.apple.CoreSimulator.SimRuntime.", "").strip()) @@ -2499,7 +2577,7 @@ def startControllerApp(self, current, ident): sys.stdout.flush() try: run("xcrun simctl boot \"{0}\"".format(self.device)) - run("xcrun simctl bootstatus \"{0}\"".format(self.device)) # Wait for the boot to complete + run("xcrun simctl bootstatus \"{0}\"".format(self.device)) # Wait for the boot to complete except Exception as ex: if str(ex).find("Booted") >= 0: pass @@ -2507,9 +2585,10 @@ def startControllerApp(self, current, ident): # # Create the simulator device if it doesn't exist # - self.simulatorID = run("xcrun simctl create \"{0}\" {1} {2}".format(self.device, self.deviceID, self.runtimeID)) + self.simulatorID = run("xcrun simctl create \"{0}\" {1} {2}".format( + self.device, self.deviceID, self.runtimeID)) run("xcrun simctl boot \"{0}\"".format(self.device)) - run("xcrun simctl bootstatus \"{0}\"".format(self.device)) # Wait for the boot to complete + run("xcrun simctl bootstatus \"{0}\"".format(self.device)) # Wait for the boot to complete # # This not longer works on iOS 15 simulator, fails with: # "Could not write domain com.apple.springboard; exiting" @@ -2576,6 +2655,7 @@ def destroy(self, driver): pass print("ok") + class iOSDeviceProcessController(RemoteProcessController): appPath = "cpp/test/ios/controller/build" @@ -2596,6 +2676,7 @@ def startControllerApp(self, current, ident): def stopControllerApp(self, ident): pass + class BrowserProcessController(RemoteProcessController): def __init__(self, current): @@ -2637,7 +2718,8 @@ def __init__(self, current): # contains our Test CA cert. It should be possible to avoid this by setting the webdriver # acceptInsecureCerts capability but it's only supported by latest Firefox releases. # - profilepath = os.path.join(current.driver.getComponent().getSourceDir(), "scripts", "selenium", "firefox") + profilepath = os.path.join(current.driver.getComponent().getSourceDir(), + "scripts", "selenium", "firefox") options = webdriver.FirefoxOptions() options.set_preference("profile", profilepath) self.driver = webdriver.Firefox(options=options) @@ -2734,7 +2816,7 @@ def getController(self, current): try: print("browser log:\n{0}".format(self.driver.get_log("browser"))) except: - pass # Not all browsers support retrieving the browser console log + pass # Not all browsers support retrieving the browser console log raise ex def destroy(self, driver): @@ -2748,6 +2830,7 @@ def destroy(self, driver): except: pass + class Driver: class Current: @@ -2782,7 +2865,7 @@ def writeln(self, *args, **kargs): def push(self, testcase, host=None): if not testcase.mapping: - assert(not testcase.parent and not testcase.testsuite) + assert (not testcase.parent and not testcase.testsuite) testcase.mapping = self.testcase.getMapping() testcase.testsuite = self.testcase.getTestSuite() testcase.parent = self.testcase @@ -2792,7 +2875,7 @@ def push(self, testcase, host=None): self.host = host def pop(self): - assert(self.testcase) + assert (self.testcase) testcase = self.testcase (self.testcase, self.config, self.host) = self.testcases.pop() if testcase.parent and self.testcase != testcase: @@ -2816,9 +2899,11 @@ def mkdirs(self, dirs): def destroy(self): for d in self.dirs: - if os.path.exists(d): shutil.rmtree(d) + if os.path.exists(d): + shutil.rmtree(d) for f in self.files: - if os.path.exists(f): os.unlink(f) + if os.path.exists(f): + os.unlink(f) drivers = {} driver = "local" @@ -2883,14 +2968,14 @@ def __init__(self, options, component): self.rlanguages = [] self.failures = [] - parseOptions(self, options, { "d": "debug", - "r" : "filters", - "R" : "rfilters", - "filter" : "filters", - "rfilter" : "rfilters", - "host-ipv6" : "hostIPv6", - "host-bt" : "hostBT", - "controller-app" : "controllerApp"}) + parseOptions(self, options, {"d": "debug", + "r": "filters", + "R": "rfilters", + "filter": "filters", + "rfilter": "rfilters", + "host-ipv6": "hostIPv6", + "host-bt": "hostBT", + "controller-app": "controllerApp"}) if self.languages: self.languages = [i for sublist in [l.split(",") for l in self.languages] for i in sublist] @@ -2935,7 +3020,7 @@ def getTestPort(self, portnum): return 12010 + portnum def getArgs(self, process, current): - ### Return driver specific arguments + # Return driver specific arguments return [] def getProps(self, process, current): @@ -2948,7 +3033,7 @@ def getProps(self, process, current): return props def getMappings(self): - ### Return additional mappings to load required by the driver + # Return additional mappings to load required by the driver return [] def matchLanguage(self, language): @@ -3039,6 +3124,7 @@ def destroy(self): if self.communicator: self.communicator.destroy() + class CppMapping(Mapping): class Config(Mapping.Config): @@ -3069,9 +3155,9 @@ def __init__(self, options=[]): # tests on the cpp11 value in the testcase options specification self.cpp11 = self.buildConfig.lower().find("cpp11") >= 0 - parseOptions(self, options, { "cpp-config" : "buildConfig", - "cpp-platform" : "buildPlatform", - "cpp-path" : "pathOverride" }) + parseOptions(self, options, {"cpp-config": "buildConfig", + "cpp-platform": "buildPlatform", + "cpp-path": "pathOverride"}) if self.pathOverride: self.pathOverride = os.path.abspath(self.pathOverride) @@ -3093,17 +3179,17 @@ def getSSLProps(self, process, current): }) if isinstance(platform, Darwin): props.update({ - "IceSSL.KeychainPassword" : "password", + "IceSSL.KeychainPassword": "password", "IceSSL.Keychain": "server.keychain" if server else "client.keychain" - }) + }) return props def getPluginEntryPoint(self, plugin, process, current): return { - "IceSSL" : "IceSSLOpenSSL:createIceSSLOpenSSL" if current.config.openssl else "IceSSL:createIceSSL", - "IceBT" : "IceBT:createIceBT", - "IceDiscovery" : "IceDiscovery:createIceDiscovery", - "IceLocatorDiscovery" : "IceLocatorDiscovery:createIceLocatorDiscovery" + "IceSSL": "IceSSLOpenSSL:createIceSSLOpenSSL" if current.config.openssl else "IceSSL:createIceSSL", + "IceBT": "IceBT:createIceBT", + "IceDiscovery": "IceDiscovery:createIceDiscovery", + "IceLocatorDiscovery": "IceLocatorDiscovery:createIceLocatorDiscovery" }[plugin] def getEnv(self, process, current): @@ -3141,12 +3227,12 @@ def getEnv(self, process, current): def _getDefaultSource(self, processType): return { - "client" : "Client.cpp", - "server" : "Server.cpp", - "serveramd" : "ServerAMD.cpp", - "collocated" : "Collocated.cpp", - "subscriber" : "Subscriber.cpp", - "publisher" : "Publisher.cpp", + "client": "Client.cpp", + "server": "Server.cpp", + "serveramd": "ServerAMD.cpp", + "collocated": "Collocated.cpp", + "subscriber": "Subscriber.cpp", + "publisher": "Publisher.cpp", }[processType] def _getDefaultExe(self, processType): @@ -3161,9 +3247,11 @@ def getIOSAppFullPath(self, current): appName = "C++11 Test Controller.app" if current.config.cpp11 else "C++98 Test Controller.app" path = os.path.join(self.component.getTestDir(self), "ios", "controller") path = os.path.join(path, "build-{0}-{1}".format(current.config.buildPlatform, current.config.buildConfig)) - build = "Debug" if os.path.exists(os.path.join(path, "Debug-{0}".format(current.config.buildPlatform))) else "Release" + build = "Debug" if os.path.exists(os.path.join( + path, "Debug-{0}".format(current.config.buildPlatform))) else "Release" return os.path.join(path, "{0}-{1}".format(build, current.config.buildPlatform), appName) + class JavaMapping(Mapping): class Config(Mapping.Config): @@ -3191,7 +3279,7 @@ def getCommandLine(self, current, process, exe, args): return "{0} -ea {1} {2}".format(java, exe, args) testdir = self.component.getTestDir(self) - assert(current.testcase.getPath(current).startswith(testdir)) + assert (current.testcase.getPath(current).startswith(testdir)) package = "test." + current.testcase.getPath(current)[len(testdir) + 1:].replace(os.sep, ".") javaArgs = self.getJavaArgs(process, current) if javaArgs: @@ -3209,9 +3297,9 @@ def getSSLProps(self, process, current): props = Mapping.getSSLProps(self, process, current) if current.config.android: props.update({ - "IceSSL.KeystoreType" : "BKS", - "IceSSL.TruststoreType" : "BKS", - "Ice.InitPlugins" : "0", + "IceSSL.KeystoreType": "BKS", + "IceSSL.TruststoreType": "BKS", + "Ice.InitPlugins": "0", "IceSSL.Keystore": "server.bks" if isinstance(process, Server) else "client.bks" }) else: @@ -3222,21 +3310,21 @@ def getSSLProps(self, process, current): def getPluginEntryPoint(self, plugin, process, current): return { - "IceSSL" : "com.zeroc.IceSSL.PluginFactory", - "IceBT" : "com.zeroc.IceBT.PluginFactory", - "IceDiscovery" : "com.zeroc.IceDiscovery.PluginFactory", - "IceLocatorDiscovery" : "com.zeroc.IceLocatorDiscovery.PluginFactory" + "IceSSL": "com.zeroc.IceSSL.PluginFactory", + "IceBT": "com.zeroc.IceBT.PluginFactory", + "IceDiscovery": "com.zeroc.IceDiscovery.PluginFactory", + "IceLocatorDiscovery": "com.zeroc.IceLocatorDiscovery.PluginFactory" }[plugin] def getEnv(self, process, current): - return { "CLASSPATH" : os.path.join(self.path, "lib", "test.jar") } + return {"CLASSPATH": os.path.join(self.path, "lib", "test.jar")} def _getDefaultSource(self, processType): return { - "client" : "Client.java", - "server" : "Server.java", - "serveramd" : "AMDServer.java", - "collocated" : "Collocated.java", + "client": "Client.java", + "server": "Server.java", + "serveramd": "AMDServer.java", + "collocated": "Collocated.java", }[processType] def getSDKPackage(self): @@ -3250,6 +3338,7 @@ def getApk(self, current): def getActivityName(self): return "com.zeroc.testcontroller/.ControllerActivity" + class CSharpMapping(Mapping): class Config(Mapping.Config): @@ -3303,9 +3392,9 @@ def getPluginEntryPoint(self, plugin, process, current): plugindir += os.sep return { - "IceSSL" : plugindir + "IceSSL.dll:IceSSL.PluginFactory", - "IceDiscovery" : plugindir + "IceDiscovery.dll:IceDiscovery.PluginFactory", - "IceLocatorDiscovery" : plugindir + "IceLocatorDiscovery.dll:IceLocatorDiscovery.PluginFactory" + "IceSSL": plugindir + "IceSSL.dll:IceSSL.PluginFactory", + "IceDiscovery": plugindir + "IceDiscovery.dll:IceDiscovery.PluginFactory", + "IceLocatorDiscovery": plugindir + "IceLocatorDiscovery.dll:IceLocatorDiscovery.PluginFactory" }[plugin] def getEnv(self, process, current): @@ -3321,12 +3410,12 @@ def getEnv(self, process, current): def _getDefaultSource(self, processType): return { - "client" : "Client.cs", - "server" : "Server.cs", - "serveramd" : "ServerAMD.cs", - "servertie" : "ServerTie.cs", - "serveramdtie" : "ServerAMDTie.cs", - "collocated" : "Collocated.cs", + "client": "Client.cs", + "server": "Server.cs", + "serveramd": "ServerAMD.cs", + "servertie": "ServerTie.cs", + "serveramdtie": "ServerAMDTie.cs", + "collocated": "Collocated.cs", }[processType] def _getDefaultExe(self, processType): @@ -3339,6 +3428,7 @@ def getCommandLine(self, current, process, exe, args): path = os.path.join(current.testcase.getPath(current), current.getBuildDir(exe)) return "dotnet {}.dll {}".format(os.path.join(path, exe), args) + class CppBasedMapping(Mapping): class Config(Mapping.Config): @@ -3352,16 +3442,16 @@ def usage(self): print("") print(self.mappingDesc + " mapping options:") print("--{0}-config= {1} build configuration for native executables (overrides --config)." - .format(self.mappingName, self.mappingDesc)) + .format(self.mappingName, self.mappingDesc)) print("--{0}-platform= {1} build platform for native executables (overrides --platform)." - .format(self.mappingName, self.mappingDesc)) + .format(self.mappingName, self.mappingDesc)) print("--openssl Run SSL tests with OpenSSL instead of the default platform SSL engine.") def __init__(self, options=[]): Mapping.Config.__init__(self, options) parseOptions(self, options, - { self.mappingName + "-config" : "buildConfig", - self.mappingName + "-platform" : "buildPlatform" }) + {self.mappingName + "-config": "buildConfig", + self.mappingName + "-platform": "buildPlatform"}) def getSSLProps(self, process, current): return Mapping.getByName("cpp").getSSLProps(process, current) @@ -3377,6 +3467,7 @@ def getEnv(self, process, current): env[platform.getLdPathEnvName()] = self.component.getLibDir(process, Mapping.getByName("cpp"), current) return env + class PythonMapping(CppBasedMapping): class Config(CppBasedMapping.Config): @@ -3434,12 +3525,13 @@ def getPythonDirs(self, iceDir, config): def _getDefaultSource(self, processType): return { - "client" : "Client.py", - "server" : "Server.py", - "serveramd" : "ServerAMD.py", - "collocated" : "Collocated.py", + "client": "Client.py", + "server": "Server.py", + "serveramd": "ServerAMD.py", + "collocated": "Collocated.py", }[processType] + class CppBasedClientMapping(CppBasedMapping): def loadTestSuites(self, tests, config, filters, rfilters): @@ -3447,7 +3539,8 @@ def loadTestSuites(self, tests, config, filters, rfilters): self.getServerMapping().loadTestSuites(self.testsuites.keys(), config) def getServerMapping(self, testId=None): - return Mapping.getByName("cpp") # By default, run clients against C++ mapping executables + return Mapping.getByName("cpp") # By default, run clients against C++ mapping executables + class RubyMapping(CppBasedClientMapping): @@ -3470,7 +3563,8 @@ def getEnv(self, process, current): return env def _getDefaultSource(self, processType): - return { "client" : "Client.rb" }[processType] + return {"client": "Client.rb"}[processType] + class PhpMapping(CppBasedClientMapping): @@ -3488,10 +3582,9 @@ def usage(self): print("PHP Mapping options:") print("--php-version=[7.1|7.2|7.3|8.0|8.1] PHP Version used for Windows builds") - def __init__(self, options=[]): CppBasedClientMapping.Config.__init__(self, options) - parseOptions(self, options, { "php-version" : "phpVersion" }) + parseOptions(self, options, {"php-version": "phpVersion"}) def getCommandLine(self, current, process, exe, args): phpArgs = [] @@ -3513,7 +3606,8 @@ def getCommandLine(self, current, process, exe, args): threadSafe = current.driver.configs[self].buildConfig in ["Debug", "Release"] buildPlatform = current.driver.configs[self].buildPlatform buildConfig = "Debug" if current.driver.configs[self].buildConfig.find("Debug") >= 0 else "Release" - packageName = "php-{0}-{1}.{2}".format(current.config.phpVersion, "ts" if threadSafe else "nts", nugetVersion) + packageName = "php-{0}-{1}.{2}".format(current.config.phpVersion, + "ts" if threadSafe else "nts", nugetVersion) php = os.path.join(self.path, "msbuild", "packages", packageName, "build", "native", "bin", buildPlatform, buildConfig, "php.exe") @@ -3523,7 +3617,7 @@ def getCommandLine(self, current, process, exe, args): # if isinstance(platform, Windows) and not self.component.useBinDist(self, current) or \ platform.getInstallDir() and self.component.getInstallDir(self, current) != platform.getInstallDir(): - phpArgs += ["-n"] # Do not load any php.ini files + phpArgs += ["-n"] # Do not load any php.ini files phpArgs += ["-d", "extension_dir='{0}'".format(self.component.getLibDir(process, self, current))] phpArgs += ["-d", "extension='{0}'".format(self.component.getPhpExtension(self, current))] phpArgs += ["-d", "include_path='{0}'".format(self.component.getPhpIncludePath(self, current))] @@ -3538,7 +3632,8 @@ def getCommandLine(self, current, process, exe, args): args) def _getDefaultSource(self, processType): - return { "client" : "Client.php" }[processType] + return {"client": "Client.php"}[processType] + class MatlabMapping(CppBasedClientMapping): @@ -3558,17 +3653,17 @@ def getCommandLine(self, current, process, exe, args): args) def getServerMapping(self, testId=None): - return Mapping.getByName("python") # Run clients against Python mapping servers + return Mapping.getByName("python") # Run clients against Python mapping servers def _getDefaultSource(self, processType): - return { "client" : "client.m" }[processType] + return {"client": "client.m"}[processType] def getOptions(self, current): # # Metrics tests configuration not supported with MATLAB they use the Admin adapter. # options = CppBasedClientMapping.getOptions(self, current) - options["mx"] = [ False ] + options["mx"] = [False] return options @@ -3586,7 +3681,7 @@ def getServerMapping(self, testId=None): if testId and self.hasSource(testId, "server"): return self else: - return Mapping.getByName("cpp") # Run clients against C++ mapping servers if no JS server provided + return Mapping.getByName("cpp") # Run clients against C++ mapping servers if no JS server provided def _getDefaultProcesses(self, processType): if processType.startswith("server"): @@ -3609,16 +3704,16 @@ def getSSLProps(self, process, current): def getOptions(self, current): options = { - "protocol" : ["ws", "wss"] if current.config.browser else ["tcp"], - "compress" : [False], - "ipv6" : [False], - "serialize" : [False], - "mx" : [False], + "protocol": ["ws", "wss"] if current.config.browser else ["tcp"], + "compress": [False], + "ipv6": [False], + "serialize": [False], + "mx": [False], } return options -class JavaScriptMapping(JavaScriptMixin,Mapping): +class JavaScriptMapping(JavaScriptMixin, Mapping): class Config(Mapping.Config): @@ -3643,7 +3738,7 @@ def getCommonDir(self, current): return os.path.join(self.getPath(), "test", "Common") def _getDefaultSource(self, processType): - return { "client" : "Client.js", "serveramd" : "ServerAMD.js", "server" : "Server.js" }[processType] + return {"client": "Client.js", "serveramd": "ServerAMD.js", "server": "Server.js"}[processType] def getTestCwd(self, process, current): return os.path.join(self.path, "test", current.testcase.getTestSuite().getId()) @@ -3651,11 +3746,12 @@ def getTestCwd(self, process, current): def getOptions(self, current): options = JavaScriptMixin.getOptions(self, current) options.update({ - "worker" : [False, True] if current.config.browser else [False], + "worker": [False, True] if current.config.browser else [False], }) return options -class TypeScriptMapping(JavaScriptMixin,Mapping): + +class TypeScriptMapping(JavaScriptMixin, Mapping): class Config(Mapping.Config): @@ -3681,7 +3777,8 @@ def canRun(self, testId, current): return Mapping.Config.canRun(self, testId, current) and not self.browser def _getDefaultSource(self, processType): - return { "client" : "Client.ts", "serveramd" : "ServerAMD.ts", "server" : "Server.ts" }[processType] + return {"client": "Client.ts", "serveramd": "ServerAMD.ts", "server": "Server.ts"}[processType] + class SwiftMapping(Mapping): @@ -3696,10 +3793,9 @@ def __init__(self, options=[]): # Check the OPTIMIZE environment variable to figure out if it's Debug/Release build self.buildConfig = "Release" if os.environ.get("OPTIMIZE", "yes") != "no" else "Debug" - def getCommandLine(self, current, process, exe, args): testdir = self.component.getTestDir(self) - assert(current.testcase.getPath(current).startswith(testdir)) + assert (current.testcase.getPath(current).startswith(testdir)) package = current.testcase.getPath(current)[len(testdir) + 1:].replace(os.sep, ".") cmd = "xcodebuild -project {0} -target 'TestDriver {1}' -configuration {2} -showBuildSettings".format( @@ -3721,11 +3817,11 @@ def getCommandLine(self, current, process, exe, args): return "{0} {1} {2} {3}".format(testDriver, package, exe, args) def _getDefaultSource(self, processType): - return { "client" : "Client.swift", - "server" : "Server.swift", - "serveramd" : "ServerAMD.swift", - "collocated" : "Collocated.swift" - }[processType] + return {"client": "Client.swift", + "server": "Server.swift", + "serveramd": "ServerAMD.swift", + "collocated": "Collocated.swift" + }[processType] def getIOSControllerIdentity(self, current): category = "iPhoneSimulator" if current.config.buildPlatform == "iphonesimulator" else "iPhoneOS" @@ -3766,6 +3862,7 @@ def getXcodeProject(self, current): # TODO ice-test.xcodeproj once Carthage supports binary XCFramework projects # "ice-test.xcodeproj" if self.component.useBinDist(self, current) else "ice.xcodeproj") + # # Instantiate platform global variable # @@ -3797,6 +3894,7 @@ def getXcodeProject(self, current): # from LocalDriver import * + def runTestsWithPath(path): mappings = Mapping.getAllByPath(path) if not mappings: @@ -3804,6 +3902,7 @@ def runTestsWithPath(path): sys.exit(0) runTests(mappings) + def runTests(mappings=None, drivers=None): if not mappings: mappings = Mapping.getAll() diff --git a/scripts/icehashpassword.py b/scripts/icehashpassword.py index 32f379bb97c..4fb95079f69 100755 --- a/scripts/icehashpassword.py +++ b/scripts/icehashpassword.py @@ -3,11 +3,16 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import sys, getopt, passlib.hash, passlib.hosts, getpass +import sys +import getopt +import passlib.hash +import passlib.hosts +import getpass usePBKDF2 = any(sys.platform == p for p in ["win32", "darwin", "cygwin"]) useCryptExt = any(sys.platform.startswith(p) for p in ["linux", "freebsd", "gnukfreebsd"]) + def usage(): print("Usage: icehashpassword [options]") print("") @@ -29,10 +34,11 @@ def usage(): print(" -r ROUNDS, --rounds=ROUNDS") print(" Optional number of rounds to use.") print("") - print(" -h, --help" ) + print(" -h, --help") print(" Show this message.") print("") + def main(): digestAlgorithms = () @@ -104,13 +110,13 @@ def main(): if rounds: if not passScheme.min_rounds <= rounds <= passScheme.max_rounds: print("Invalid number rounds for the digest algorithm. Value must be an integer between %s and %s" % - (passScheme.min_rounds, passScheme.max_rounds)) + (passScheme.min_rounds, passScheme.max_rounds)) usage() return 2 if salt: if not passScheme.min_salt_size <= salt <= passScheme.max_salt_size: print("Invalid salt size for the digest algorithm. Value must be an integer between %s and %s" % - (passScheme.min_salt_size, passScheme.max_salt_size)) + (passScheme.min_salt_size, passScheme.max_salt_size)) usage() return 2 @@ -135,5 +141,6 @@ def main(): return 0 + if __name__ == '__main__': sys.exit(main()) diff --git a/scripts/tests/Glacier2/application.py b/scripts/tests/Glacier2/application.py index 2b8886ebe4c..089c3a4aec2 100644 --- a/scripts/tests/Glacier2/application.py +++ b/scripts/tests/Glacier2/application.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -Glacier2TestSuite(__name__, routerProps = { "Glacier2.SessionTimeout" : 30 }) +Glacier2TestSuite(__name__, routerProps={"Glacier2.SessionTimeout": 30}) diff --git a/scripts/tests/Glacier2/router.py b/scripts/tests/Glacier2/router.py index a3b32fa7297..e03b99b15e4 100644 --- a/scripts/tests/Glacier2/router.py +++ b/scripts/tests/Glacier2/router.py @@ -13,11 +13,11 @@ } routerProps = { - "Ice.Warn.Dispatch" : "0", - "Ice.Warn.Connections" : "0", - "Glacier2.Filter.Category.Accept" : "c1 c2", - "Glacier2.Filter.Category.AcceptUser" : "2", - "Glacier2.Client.ACM.Timeout" : "30", + "Ice.Warn.Dispatch": "0", + "Ice.Warn.Connections": "0", + "Glacier2.Filter.Category.Accept": "c1 c2", + "Glacier2.Filter.Category.AcceptUser": "2", + "Glacier2.Client.ACM.Timeout": "30", } traceProps = { @@ -26,8 +26,10 @@ "Ice.Trace.Retry": 1, } + def buffered(enabled): - return { "Glacier2.Client.Buffered": enabled, "Glacier2.Server.Buffered": enabled } + return {"Glacier2.Client.Buffered": enabled, "Glacier2.Server.Buffered": enabled} + Glacier2TestSuite(__name__, routerProps, [ ClientServerTestCase(name="client/server with router in unbuffered mode", diff --git a/scripts/tests/Glacier2/sessionHelper.py b/scripts/tests/Glacier2/sessionHelper.py index 77d27b491cc..435a3488299 100644 --- a/scripts/tests/Glacier2/sessionHelper.py +++ b/scripts/tests/Glacier2/sessionHelper.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -Glacier2TestSuite(__name__, routerProps = { "Glacier2.Client.ACM.Timeout" : 30 }) +Glacier2TestSuite(__name__, routerProps={"Glacier2.Client.ACM.Timeout": 30}) diff --git a/scripts/tests/Ice/admin.py b/scripts/tests/Ice/admin.py index 47f5c692ddd..92a2ac7f608 100644 --- a/scripts/tests/Ice/admin.py +++ b/scripts/tests/Ice/admin.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, options = { "ipv6" : [False] }, multihost=False) +TestSuite(__name__, options={"ipv6": [False]}, multihost=False) diff --git a/scripts/tests/Ice/ami.py b/scripts/tests/Ice/ami.py index 3f369cbd21b..eea41489e6c 100644 --- a/scripts/tests/Ice/ami.py +++ b/scripts/tests/Ice/ami.py @@ -5,14 +5,14 @@ # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Network" : 2, - "Ice.Trace.Retry" : 1, - "Ice.Trace.Protocol" : 1 + "Ice.Trace.Network": 2, + "Ice.Trace.Retry": 1, + "Ice.Trace.Protocol": 1 } -testcases = [ ClientServerTestCase(traceProps=traceProps) ] +testcases = [ClientServerTestCase(traceProps=traceProps)] if Mapping.getByPath(__name__).hasSource("Ice/ami", "collocated"): - testcases += [ CollocatedTestCase() ] + testcases += [CollocatedTestCase()] TestSuite(__name__, testcases, - options = { "compress" : [False], "serialize" : [False] }) + options={"compress": [False], "serialize": [False]}) diff --git a/scripts/tests/Ice/background.py b/scripts/tests/Ice/background.py index 4616c54b061..688997af769 100644 --- a/scripts/tests/Ice/background.py +++ b/scripts/tests/Ice/background.py @@ -2,4 +2,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, libDirs=["testtransport"], options={ "mx": [False] }) +TestSuite(__name__, libDirs=["testtransport"], options={"mx": [False]}) diff --git a/scripts/tests/Ice/binding.py b/scripts/tests/Ice/binding.py index 8dea61ab254..1b84cc6324b 100644 --- a/scripts/tests/Ice/binding.py +++ b/scripts/tests/Ice/binding.py @@ -12,4 +12,5 @@ def setlimits(): import resource resource.setrlimit(resource.RLIMIT_NOFILE, (92, 92)) + TestSuite(__name__, [ClientServerTestCase(server=Server(preexec_fn=setlimits))]) diff --git a/scripts/tests/Ice/enums.py b/scripts/tests/Ice/enums.py index 287ba20f474..086a09fd427 100644 --- a/scripts/tests/Ice/enums.py +++ b/scripts/tests/Ice/enums.py @@ -4,5 +4,5 @@ TestSuite(__name__, [ ClientServerTestCase("client/server with default encoding"), - ClientServerTestCase("client/server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }), + ClientServerTestCase("client/server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ]) diff --git a/scripts/tests/Ice/exceptions.py b/scripts/tests/Ice/exceptions.py index 982c08a20d7..407eec045c1 100644 --- a/scripts/tests/Ice/exceptions.py +++ b/scripts/tests/Ice/exceptions.py @@ -4,19 +4,19 @@ testcases = [ ClientServerTestCase("client/server with compact format"), - ClientServerTestCase("client/server with sliced format", props={ "Ice.Default.SlicedFormat" : True }), - ClientServerTestCase("client/server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }), + ClientServerTestCase("client/server with sliced format", props={"Ice.Default.SlicedFormat": True}), + ClientServerTestCase("client/server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ] # If the mapping has AMD servers, also run with the AMD servers if Mapping.getByPath(__name__).hasSource("Ice/exceptions", "serveramd"): testcases += [ ClientAMDServerTestCase("client/amd server with compact format"), - ClientAMDServerTestCase("client/amd server with sliced format", props={ "Ice.Default.SlicedFormat" : True }), - ClientAMDServerTestCase("client/amd server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0"}), + ClientAMDServerTestCase("client/amd server with sliced format", props={"Ice.Default.SlicedFormat": True}), + ClientAMDServerTestCase("client/amd server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ] if Mapping.getByPath(__name__).hasSource("Ice/exceptions", "collocated"): - testcases += [ CollocatedTestCase() ] + testcases += [CollocatedTestCase()] TestSuite(__name__, testcases) diff --git a/scripts/tests/Ice/faultTolerance.py b/scripts/tests/Ice/faultTolerance.py index bb00e6bf4a4..3ec75d00ec1 100755 --- a/scripts/tests/Ice/faultTolerance.py +++ b/scripts/tests/Ice/faultTolerance.py @@ -5,10 +5,13 @@ from Util import * # This is used for the trace file -props = lambda process, current: { + + +def props(process, current): return { "Ice.ProgramName": "server{}".format(process.args[0]) } + # Enable some tracing to allow investigating test failures traceProps = { "Ice.Trace.Network": 3, @@ -19,7 +22,7 @@ # # Start 12 servers # -servers=range(1, 13) +servers = range(1, 13) TestSuite(__name__, [ ClientServerTestCase(client=Client(args=[i for i in servers]), diff --git a/scripts/tests/Ice/info.py b/scripts/tests/Ice/info.py index 70cdb42f626..1363cf46890 100644 --- a/scripts/tests/Ice/info.py +++ b/scripts/tests/Ice/info.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, options = { "ipv6" : [False], "compress" : [False] }, multihost=False) +TestSuite(__name__, options={"ipv6": [False], "compress": [False]}, multihost=False) diff --git a/scripts/tests/Ice/interceptor.py b/scripts/tests/Ice/interceptor.py index 686ff180970..6bcbe8faad2 100644 --- a/scripts/tests/Ice/interceptor.py +++ b/scripts/tests/Ice/interceptor.py @@ -2,4 +2,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, [ClientTestCase(client=Client(props={"Ice.Warn.Dispatch" : 0}))], libDirs=["interceptortest"]) +TestSuite(__name__, [ClientTestCase(client=Client(props={"Ice.Warn.Dispatch": 0}))], libDirs=["interceptortest"]) diff --git a/scripts/tests/Ice/interrupt.py b/scripts/tests/Ice/interrupt.py index 016ef8b330d..b91b22956d5 100644 --- a/scripts/tests/Ice/interrupt.py +++ b/scripts/tests/Ice/interrupt.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -TestSuite(__name__, options = { "compress" : [False] }) +TestSuite(__name__, options={"compress": [False]}) diff --git a/scripts/tests/Ice/location.py b/scripts/tests/Ice/location.py index 69bbbb97388..ae3dfd55e52 100644 --- a/scripts/tests/Ice/location.py +++ b/scripts/tests/Ice/location.py @@ -5,8 +5,8 @@ # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Locator" : 2, - "Ice.Trace.Protocol" : 1 + "Ice.Trace.Locator": 2, + "Ice.Trace.Protocol": 1 } TestSuite(__name__, [ClientServerTestCase(traceProps=traceProps)]) diff --git a/scripts/tests/Ice/metrics.py b/scripts/tests/Ice/metrics.py index 19f8e43f474..671ebcfbb5c 100644 --- a/scripts/tests/Ice/metrics.py +++ b/scripts/tests/Ice/metrics.py @@ -5,18 +5,18 @@ # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Network" : 2, - "Ice.Trace.Retry" : 1, - "Ice.Trace.Protocol" : 1 + "Ice.Trace.Network": 2, + "Ice.Trace.Retry": 1, + "Ice.Trace.Protocol": 1 } testcases = [ ClientServerTestCase(traceProps=traceProps), ] if Mapping.getByPath(__name__).hasSource("Ice/metrics", "serveramd"): - testcases += [ ClientAMDServerTestCase(traceProps=traceProps) ] + testcases += [ClientAMDServerTestCase(traceProps=traceProps)] if Mapping.getByPath(__name__).hasSource("Ice/metrics", "collocated"): - testcases += [ CollocatedTestCase(traceProps=traceProps) ] + testcases += [CollocatedTestCase(traceProps=traceProps)] TestSuite(__name__, testcases, - options = { "ipv6" : [False], "compress": [False], "protocol" : ["tcp", "ssl"] }, + options={"ipv6": [False], "compress": [False], "protocol": ["tcp", "ssl"]}, multihost=False) diff --git a/scripts/tests/Ice/networkProxy.py b/scripts/tests/Ice/networkProxy.py index af10905b65d..226ba02e7b1 100644 --- a/scripts/tests/Ice/networkProxy.py +++ b/scripts/tests/Ice/networkProxy.py @@ -4,15 +4,17 @@ import NetworkProxy + class NetworkProxyTestSuite(TestSuite): def setup(self, current): self.portNum = 30 + class NetworkProxyTestCase(ClientServerTestCase): def __init__(self, proxyName, proxyType): - ClientServerTestCase.__init__(self, proxyName + " client/server", client = Client(props = lambda p, c: { + ClientServerTestCase.__init__(self, proxyName + " client/server", client=Client(props=lambda p, c: { "Ice.{0}ProxyHost".format(proxyName): "localhost", "Ice.{0}ProxyPort".format(proxyName): "{0}".format(c.driver.getTestPort(c.testsuite.portNum)) })) @@ -37,7 +39,8 @@ def teardownClientSide(self, current, success): current.testsuite.portNum += 1 current.writeln("ok") + NetworkProxyTestSuite(__name__, [ NetworkProxyTestCase("SOCKS", NetworkProxy.SocksProxy), NetworkProxyTestCase("HTTP", NetworkProxy.HttpProxy), -], options = { "ipv6" : [False] }) +], options={"ipv6": [False]}) diff --git a/scripts/tests/Ice/objects.py b/scripts/tests/Ice/objects.py index 70ce1b8eba0..8fac1ee78af 100644 --- a/scripts/tests/Ice/objects.py +++ b/scripts/tests/Ice/objects.py @@ -29,13 +29,14 @@ def getProps(self, process, current): props["Ice.ThreadPool.Server.StackSize"] = 768 * 1024 return props + testcases = [ ObjectClientServerTestCase("client/server with compact format"), - ObjectClientServerTestCase("client/server with sliced format", props = {"Ice.Default.SlicedFormat" : True}), - ObjectClientServerTestCase("client/server with 1.0 encoding", props = {"Ice.Default.EncodingVersion" : "1.0"}), + ObjectClientServerTestCase("client/server with sliced format", props={"Ice.Default.SlicedFormat": True}), + ObjectClientServerTestCase("client/server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ] if Mapping.getByPath(__name__).hasSource("Ice/objects", "collocated"): - testcases += [ CollocatedTestCase() ] + testcases += [CollocatedTestCase()] TestSuite(__name__, testcases) diff --git a/scripts/tests/Ice/optional.py b/scripts/tests/Ice/optional.py index 4e6994bbd61..65c1a026143 100644 --- a/scripts/tests/Ice/optional.py +++ b/scripts/tests/Ice/optional.py @@ -4,14 +4,14 @@ testcases = [ ClientServerTestCase("client/server with compact format"), - ClientServerTestCase("client/server with sliced format", props={ "Ice.Default.SlicedFormat" : True }), + ClientServerTestCase("client/server with sliced format", props={"Ice.Default.SlicedFormat": True}), ] # If the mapping has AMD servers, also run with the AMD servers if Mapping.getByPath(__name__).hasSource("Ice/optional", "serveramd"): testcases += [ ClientAMDServerTestCase("client/amd server with compact format"), - ClientAMDServerTestCase("client/amd server with sliced format", props={ "Ice.Default.SlicedFormat" : True }), + ClientAMDServerTestCase("client/amd server with sliced format", props={"Ice.Default.SlicedFormat": True}), ] TestSuite(__name__, testcases) diff --git a/scripts/tests/Ice/properties.py b/scripts/tests/Ice/properties.py index 01828aafaf0..ce45a2660e1 100644 --- a/scripts/tests/Ice/properties.py +++ b/scripts/tests/Ice/properties.py @@ -13,6 +13,7 @@ def setup(self, current): "Ice.Trace.Network=1", "Ice.ProgramName=PropertiesClient", "Config.Path=./config/" + name], - "utf-8") + "utf-8") -PropertiesTestSuite(__name__, [ ClientTestCase(client=Client(args=["{testdir}"])) ]) + +PropertiesTestSuite(__name__, [ClientTestCase(client=Client(args=["{testdir}"]))]) diff --git a/scripts/tests/Ice/retry.py b/scripts/tests/Ice/retry.py index 643143fb4f9..81ac0858bdf 100644 --- a/scripts/tests/Ice/retry.py +++ b/scripts/tests/Ice/retry.py @@ -5,14 +5,14 @@ # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Network" : 2, - "Ice.Trace.Retry" : 1, - "Ice.Trace.Protocol" : 1 + "Ice.Trace.Network": 2, + "Ice.Trace.Retry": 1, + "Ice.Trace.Protocol": 1 } testcases = [ClientServerTestCase(traceProps=traceProps)] if Mapping.getByPath(__name__).hasSource("Ice/retry", "collocated"): - testcases += [ CollocatedTestCase(traceProps=traceProps) ] + testcases += [CollocatedTestCase(traceProps=traceProps)] TestSuite(__name__, testcases) diff --git a/scripts/tests/Ice/slicing/exceptions.py b/scripts/tests/Ice/slicing/exceptions.py index 4ebcb0e5a39..47823f33478 100644 --- a/scripts/tests/Ice/slicing/exceptions.py +++ b/scripts/tests/Ice/slicing/exceptions.py @@ -4,14 +4,14 @@ testcases = [ ClientServerTestCase(), - ClientServerTestCase("client/server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }), + ClientServerTestCase("client/server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ] # If the mapping has AMD servers, also run with the AMD servers if Mapping.getByPath(__name__).hasSource("Ice/exceptions", "serveramd"): testcases += [ ClientAMDServerTestCase(), - ClientAMDServerTestCase("client/amd server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }), + ClientAMDServerTestCase("client/amd server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), ] -TestSuite(__name__, testcases, options = { "serialize" : [False] }) +TestSuite(__name__, testcases, options={"serialize": [False]}) diff --git a/scripts/tests/Ice/slicing/objects.py b/scripts/tests/Ice/slicing/objects.py index 07805cf1118..0f4a865eeb1 100644 --- a/scripts/tests/Ice/slicing/objects.py +++ b/scripts/tests/Ice/slicing/objects.py @@ -4,5 +4,5 @@ TestSuite(__name__, [ ClientServerTestCase(), - ClientServerTestCase("client/server with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }), -], options = { "valgrind" : [False] }) + ClientServerTestCase("client/server with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}), +], options={"valgrind": [False]}) diff --git a/scripts/tests/Ice/stream.py b/scripts/tests/Ice/stream.py index ca9ecb835a5..ffcae89db0c 100644 --- a/scripts/tests/Ice/stream.py +++ b/scripts/tests/Ice/stream.py @@ -4,5 +4,5 @@ TestSuite(__name__, [ ClientTestCase("client with default encoding"), - ClientTestCase("client with 1.0 encoding", props={ "Ice.Default.EncodingVersion" : "1.0" }) + ClientTestCase("client with 1.0 encoding", props={"Ice.Default.EncodingVersion": "1.0"}) ]) diff --git a/scripts/tests/Ice/timeout.py b/scripts/tests/Ice/timeout.py index d300fd0130f..4609c52eccd 100644 --- a/scripts/tests/Ice/timeout.py +++ b/scripts/tests/Ice/timeout.py @@ -5,9 +5,10 @@ # Enable some tracing to allow investigating test failures traceProps = { - "Ice.Trace.Network" : 2, - "Ice.Trace.Retry" : 1, - "Ice.Trace.Protocol" : 1 + "Ice.Trace.Network": 2, + "Ice.Trace.Retry": 1, + "Ice.Trace.Protocol": 1 } -TestSuite(__name__, [ClientServerTestCase(server=Server(readyCount=2), traceProps=traceProps)], options = { "compress" : [False] }, ) +TestSuite(__name__, [ClientServerTestCase(server=Server(readyCount=2), + traceProps=traceProps)], options={"compress": [False]}, ) diff --git a/scripts/tests/Ice/udp.py b/scripts/tests/Ice/udp.py index 88ce7ff3218..6c427fa05b1 100644 --- a/scripts/tests/Ice/udp.py +++ b/scripts/tests/Ice/udp.py @@ -4,6 +4,7 @@ from Util import * + class UdpTestCase(ClientServerTestCase): def setupServerSide(self, current): @@ -18,4 +19,5 @@ def setupClientSide(self, current): else: self.clients = [Client(args=[5])] -TestSuite(__name__, [ UdpTestCase() ], multihost=False) + +TestSuite(__name__, [UdpTestCase()], multihost=False) diff --git a/scripts/tests/IceBox/admin.py b/scripts/tests/IceBox/admin.py index 4442bc76d1a..24e3049fffb 100644 --- a/scripts/tests/IceBox/admin.py +++ b/scripts/tests/IceBox/admin.py @@ -7,7 +7,7 @@ class IceBoxAdminTestCase(ClientServerTestCase): def runClientSide(self, current): - admin = IceBoxAdmin(args = ['--Ice.Config="{testdir}/config.admin"']) + admin = IceBoxAdmin(args=['--Ice.Config="{testdir}/config.admin"']) current.write("testing service stop...") admin.run(current, args=['stop', 'TestService']) current.writeln("ok") @@ -18,11 +18,12 @@ def runClientSide(self, current): admin.run(current, args=['shutdown']) current.writeln("ok") + TestSuite(__name__, [ - ClientServerTestCase(server=IceBox("{testdir}/config.icebox")), - IceBoxAdminTestCase("iceboxadmin", server=IceBox("{testdir}/config.icebox")), - ], + ClientServerTestCase(server=IceBox("{testdir}/config.icebox")), + IceBoxAdminTestCase("iceboxadmin", server=IceBox("{testdir}/config.icebox")), +], libDirs=["testservice"], runOnMainThread=True, - options={ "ipv6" : [False], "mx" : [False], "cpp11" : [False] }, + options={"ipv6": [False], "mx": [False], "cpp11": [False]}, multihost=False) diff --git a/scripts/tests/IceBox/configuration.py b/scripts/tests/IceBox/configuration.py index effb5ad107c..63d02090837 100644 --- a/scripts/tests/IceBox/configuration.py +++ b/scripts/tests/IceBox/configuration.py @@ -6,4 +6,4 @@ TestSuite(__name__, [ ClientServerTestCase("client/server #1", server=IceBox("{testdir}/config.icebox")), ClientServerTestCase("client/server #2", server=IceBox("{testdir}/config.icebox2")) -], libDirs=["testservice"], runOnMainThread=True, options={ "protocol" : ["tcp"], "ipv6" : [False], "mx" : [False] }, multihost=False) +], libDirs=["testservice"], runOnMainThread=True, options={"protocol": ["tcp"], "ipv6": [False], "mx": [False]}, multihost=False) diff --git a/scripts/tests/IceDiscovery/simple.py b/scripts/tests/IceDiscovery/simple.py index 0594f3ce1ab..22ecce4a982 100644 --- a/scripts/tests/IceDiscovery/simple.py +++ b/scripts/tests/IceDiscovery/simple.py @@ -5,28 +5,33 @@ import uuid -domainId = uuid.uuid4() # Ensures each test uses a unique domain ID +domainId = uuid.uuid4() # Ensures each test uses a unique domain ID -props = lambda process, current: { + +def props(process, current): return { "IceDiscovery.Timeout": 50, "IceDiscovery.RetryCount": 20, "IceDiscovery.DomainId": domainId, "IceDiscovery.Interface": "" if isinstance(platform, Linux) else "::1" if current.config.ipv6 else "127.0.0.1", "IceDiscovery.Port": current.driver.getTestPort(10), "Ice.Plugin.IceDiscovery": current.getPluginEntryPoint("IceDiscovery", process), - "Ice.ProgramName": "server{}".format(process.args[0]) if isinstance(process, Server) else "client" # This is used for the trace file + # This is used for the trace file + "Ice.ProgramName": "server{}".format(process.args[0]) if isinstance(process, Server) else "client" } + traceProps = { - "Ice.Trace.Locator" : 2, - "Ice.Trace.Protocol" : 1, - "Ice.Trace.Network" : 3 + "Ice.Trace.Locator": 2, + "Ice.Trace.Protocol": 1, + "Ice.Trace.Network": 3 } # # Suppress the warning lines # -suppressDiscoveryWarning=False +suppressDiscoveryWarning = False + + def suppressWarning(x): global suppressDiscoveryWarning if re.search("-! .* warning: .*failed to lookup adapter.*\n", x): @@ -38,17 +43,18 @@ def suppressWarning(x): suppressDiscoveryWarning = False return x + # Filter-out the warning about invalid lookup proxy -outfilters = [ lambda x: suppressWarning(x) ] +outfilters = [lambda x: suppressWarning(x)] options = None -if isinstance(platform,AIX): +if isinstance(platform, AIX): # AIX test VMs only have IPv6 enabled on the loopback interface # where multicast doesn't work - options = { "ipv6" : [False] } + options = {"ipv6": [False]} TestSuite(__name__, [ - ClientServerTestCase(client=Client(args=[3], props=props, outfilters=outfilters), - servers=[Server(args=[i], readyCount=4, props=props) for i in range(0, 3)], - traceProps=traceProps) + ClientServerTestCase(client=Client(args=[3], props=props, outfilters=outfilters), + servers=[Server(args=[i], readyCount=4, props=props) for i in range(0, 3)], + traceProps=traceProps) ], multihost=False, options=options) diff --git a/scripts/tests/IceGrid/simple.py b/scripts/tests/IceGrid/simple.py index 3cf29209c01..b96637a6e20 100644 --- a/scripts/tests/IceGrid/simple.py +++ b/scripts/tests/IceGrid/simple.py @@ -4,28 +4,31 @@ # serverProps = { - "TestAdapter.Endpoints" : "default", - "TestAdapter.AdapterId" : "TestAdapter" + "TestAdapter.Endpoints": "default", + "TestAdapter.AdapterId": "TestAdapter" } registryProps = { - "IceGrid.Registry.DynamicRegistration" : 1 + "IceGrid.Registry.DynamicRegistration": 1 } registryTraceProps = { "IceGrid.Registry.Trace.Discovery": 2 } -clientProps = lambda process, current: { + +def clientProps(process, current): return { "IceLocatorDiscovery.Timeout": 50, "IceLocatorDiscovery.RetryCount": 5, "IceLocatorDiscovery.Interface": "" if isinstance(platform, Linux) else "::1" if current.config.ipv6 else "127.0.0.1", "IceLocatorDiscovery.Port": current.driver.getTestPort(99), } -clientTraceProps = { "IceLocatorDiscovery.Trace.Lookup" : 3 } + + +clientTraceProps = {"IceLocatorDiscovery.Trace.Lookup": 3} # Filter-out the warning about invalid lookup proxy -outfilters = [ lambda x: re.sub("-! .* warning: .*failed to lookup locator.*\n", "", x), - lambda x: re.sub("^ .*\n", "", x) ] +outfilters = [lambda x: re.sub("-! .* warning: .*failed to lookup locator.*\n", "", x), + lambda x: re.sub("^ .*\n", "", x)] if isinstance(platform, Windows) or os.getuid() != 0: TestSuite(__name__, [ diff --git a/scripts/tests/IceSSL/configuration.py b/scripts/tests/IceSSL/configuration.py index bd3814c54ae..e45d037ae69 100644 --- a/scripts/tests/IceSSL/configuration.py +++ b/scripts/tests/IceSSL/configuration.py @@ -5,6 +5,7 @@ import os + class ConfigurationTestCase(ClientServerTestCase): def setupServerSide(self, current): @@ -29,7 +30,8 @@ def setupServerSide(self, current): os.system("mkdir -p {0}".format(os.path.join(certsPath, "keychain"))) os.system("security create-keychain -p password %s" % keychainPath) for cert in ["s_rsa_ca1.p12", "c_rsa_ca1.p12"]: - os.system("security import %s -f pkcs12 -A -P password -k %s" % (os.path.join(certsPath, cert), keychainPath)) + os.system("security import %s -f pkcs12 -A -P password -k %s" % + (os.path.join(certsPath, cert), keychainPath)) elif current.config.openssl or platform.hasOpenSSL(): if isinstance(platform, Windows): conf = os.path.join(current.testsuite.getPath(), "openssl.cnf") @@ -44,7 +46,8 @@ def setupServerSide(self, current): # for c in ["cacert1.pem", "cacert2.pem"]: pem = os.path.join(certsPath, c) - out = run("{openssl} x509 -subject_hash -noout -in {pem}".format(pem=pem, openssl=self.getOpenSSLCommand(current))) + out = run("{openssl} x509 -subject_hash -noout -in {pem}".format(pem=pem, + openssl=self.getOpenSSLCommand(current))) shutil.copyfile(pem, "{dir}/{out}.0".format(dir=certsPath, out=out)) def teardownServerSide(self, current, success): @@ -59,11 +62,13 @@ def teardownServerSide(self, current, success): certsPath = os.path.abspath(os.path.join(current.testsuite.getPath(), "..", "certs")) if isinstance(platform, Darwin) and current.config.buildPlatform == "macosx": - os.system("rm -rf {0} {1}".format(os.path.join(certsPath, "keychain"), os.path.join(certsPath, "Find.keychain"))) + os.system("rm -rf {0} {1}".format(os.path.join(certsPath, "keychain"), + os.path.join(certsPath, "Find.keychain"))) elif current.config.openssl or platform.hasOpenSSL(): for c in ["cacert1.pem", "cacert2.pem"]: pem = os.path.join(certsPath, c) - out = run("{openssl} x509 -subject_hash -noout -in {pem}".format(pem=pem, openssl=self.getOpenSSLCommand(current))) + out = run("{openssl} x509 -subject_hash -noout -in {pem}".format(pem=pem, + openssl=self.getOpenSSLCommand(current))) os.remove("{dir}/{out}.0".format(out=out, dir=certsPath)) if isinstance(platform, Windows): os.remove(os.path.join(current.testsuite.getPath(), "openssl.cnf")) @@ -77,6 +82,7 @@ def getOpenSSLCommand(self, current): else: return "openssl" + class IceSSLConfigurationClient(Client): def getExe(self, current): @@ -84,6 +90,7 @@ def getExe(self, current): return "clientopenssl" return Client.getExe(self, current) + class IceSSLConfigurationServer(Server): def getExe(self, current): @@ -91,7 +98,8 @@ def getExe(self, current): return "serveropenssl" return Server.getExe(self, current) + TestSuite(__name__, [ - ConfigurationTestCase(client=IceSSLConfigurationClient(args=['"{testdir}"']), - server=IceSSLConfigurationServer(args=['"{testdir}"'])) + ConfigurationTestCase(client=IceSSLConfigurationClient(args=['"{testdir}"']), + server=IceSSLConfigurationServer(args=['"{testdir}"'])) ], multihost=False) diff --git a/scripts/tests/IceSSL/revocationutil.py b/scripts/tests/IceSSL/revocationutil.py index a40efdce974..7eb71db555c 100644 --- a/scripts/tests/IceSSL/revocationutil.py +++ b/scripts/tests/IceSSL/revocationutil.py @@ -133,6 +133,7 @@ def validate(self, data): self.end_headers() self.wfile.write(response.public_bytes(Encoding.DER)) + def createOCSPServer(host, port, basepath): db = load_db(basepath) handler = partial(OCSPHandler, db) diff --git a/scripts/tests/Slice/generation.py b/scripts/tests/Slice/generation.py index 9a22923d159..f8ab3432a4e 100644 --- a/scripts/tests/Slice/generation.py +++ b/scripts/tests/Slice/generation.py @@ -29,4 +29,5 @@ def runClientSide(self, current): else: current.writeln("ok") -TestSuite(__name__, [ SliceGenerationTestCase() ]) + +TestSuite(__name__, [SliceGenerationTestCase()]) diff --git a/swift/allTests.py b/swift/allTests.py index 2241653995d..94a9466c3db 100755 --- a/swift/allTests.py +++ b/swift/allTests.py @@ -3,7 +3,8 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -import os, sys +import os +import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts")) from Util import runTestsWithPath