diff options
Diffstat (limited to 'py')
81 files changed, 2973 insertions, 2973 deletions
diff --git a/py/allTests.py b/py/allTests.py index 4fa9e5007f8..1471a729ef5 100755 --- a/py/allTests.py +++ b/py/allTests.py @@ -25,22 +25,22 @@ def runTests(args, tests, num = 0): # for i in tests: - i = os.path.normpath(i) - dir = os.path.join(toplevel, "test", i) + i = os.path.normpath(i) + dir = os.path.join(toplevel, "test", i) - print - if(num > 0): - print "[" + str(num) + "]", - print "*** running tests in " + dir, - print + print + if(num > 0): + print "[" + str(num) + "]", + print "*** running tests in " + dir, + print status = os.system(os.path.join(dir, "run.py " + args)) - if status and not (sys.platform.startswith("aix") and status == 256): - if(num > 0): - print "[" + str(num) + "]", - print "test in " + dir + " failed with exit status", status, - sys.exit(status) + if status and not (sys.platform.startswith("aix") and status == 256): + if(num > 0): + print "[" + str(num) + "]", + print "test in " + dir + " failed with exit status", status, + sys.exit(status) # # List of all basic tests. @@ -69,7 +69,7 @@ def usage(): try: opts, args = getopt.getopt(sys.argv[1:], "lr:R:", \ - ["debug", "protocol=", "compress", "host=", "threadPerConnection"]) + ["debug", "protocol=", "compress", "host=", "threadPerConnection"]) except getopt.GetoptError: usage() @@ -82,27 +82,27 @@ for o, a in opts: if o == "-l": loop = 1 if o == "-r" or o == '-R': - import re - regexp = re.compile(a) - if o == '-r': - def rematch(x): return regexp.search(x) - else: - def rematch(x): return not regexp.search(x) - tests = filter(rematch, tests) + import re + regexp = re.compile(a) + if o == '-r': + def rematch(x): return regexp.search(x) + else: + def rematch(x): return not regexp.search(x) + tests = filter(rematch, tests) if o == "--protocol": - if a not in ( "ssl", "tcp"): - usage() - args += " " + o + " " + a + if a not in ( "ssl", "tcp"): + usage() + args += " " + o + " " + a if o == "--host" : - args += " " + o + " " + a + args += " " + o + " " + a if o in ( "--debug", "--compress", "--threadPerConnection" ): - args += " " + o + args += " " + o if loop: num = 1 while 1: - runTests(args, tests, num) - num += 1 + runTests(args, tests, num) + num += 1 else: runTests(args, tests) diff --git a/py/config/TestUtil.py b/py/config/TestUtil.py index 8b3993cd799..ef33313665b 100644 --- a/py/config/TestUtil.py +++ b/py/config/TestUtil.py @@ -66,17 +66,17 @@ except getopt.GetoptError: for o, a in opts: if o == "--debug": - debug = 1 + debug = 1 if o == "--protocol": - if a not in ( "tcp", "ssl"): - usage() - protocol = a + if a not in ( "tcp", "ssl"): + usage() + protocol = a if o == "--compress": - compress = 1 + compress = 1 if o == "--threadPerConnection": - threadPerConnection = 1 + threadPerConnection = 1 if o == "--host": - host = a + host = a def isCygwin(): @@ -133,13 +133,13 @@ def isDarwin(): def closePipe(pipe): try: - status = pipe.close() + status = pipe.close() except IOError, ex: - # TODO: There's a waitpid problem on CentOS, so we have to ignore ECHILD. - if ex.errno == errno.ECHILD: - status = 0 - else: - raise + # TODO: There's a waitpid problem on CentOS, so we have to ignore ECHILD. + if ex.errno == errno.ECHILD: + status = 0 + else: + raise return status @@ -152,22 +152,22 @@ class ReaderThread(Thread): def run(self): - #print "started: " + str(self) + ": " + str(thread.get_ident()) + #print "started: " + str(self) + ": " + str(thread.get_ident()) try: while 1: line = self.pipe.readline() if not line: break - # Suppress "adapter ready" messages. Under windows the eol isn't \n. - if not line.endswith(" ready\n") and not line.endswith(" ready\r\n"): - print "server: " + line, + # Suppress "adapter ready" messages. Under windows the eol isn't \n. + if not line.endswith(" ready\n") and not line.endswith(" ready\r\n"): + print "server: " + line, except IOError: pass - self.status = closePipe(self.pipe) - #print "terminating: " + str(self) + self.status = closePipe(self.pipe) + #print "terminating: " + str(self) def getStatus(self): - return self.status + return self.status serverPids = [] serverThreads = [] @@ -177,18 +177,18 @@ def joinServers(): global serverThreads global allServerThreads for t in serverThreads: - t.join() - allServerThreads.append(t) + t.join() + allServerThreads.append(t) serverThreads = [] def serverStatus(): global allServerThreads joinServers() for t in allServerThreads: - status = t.getStatus() - if status: - print "server " + str(t) + " status: " + str(status) - return status + status = t.getStatus() + if status: + print "server " + str(t) + " status: " + str(status) + return status return 0 def killServers(): @@ -226,32 +226,32 @@ def getServerPid(pipe): global serverThreads while 1: - output = pipe.readline().strip() - if not output: - print "failed!" - killServers() - sys.exit(1) - if output.startswith("warning: "): - continue - break + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break try: - serverPids.append(int(output)) + serverPids.append(int(output)) except ValueError: - print "Output is not a PID: " + output - raise + print "Output is not a PID: " + output + raise def ignorePid(pipe): while 1: - output = pipe.readline().strip() - if not output: - print "failed!" - killServers() - sys.exit(1) - if output.startswith("warning: "): - continue - break + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break def getAdapterReady(pipe, createThread = True): global serverThreads @@ -265,9 +265,9 @@ def getAdapterReady(pipe, createThread = True): # Start a thread for this server. if createThread: - serverThread = ReaderThread(pipe) - serverThread.start() - serverThreads.append(serverThread) + serverThread = ReaderThread(pipe) + serverThread.start() + serverThreads.append(serverThread) def waitServiceReady(pipe, token, createThread = True): global serverThreads @@ -282,9 +282,9 @@ def waitServiceReady(pipe, token, createThread = True): # Start a thread for this server. if createThread: - serverThread = ReaderThread(pipe) - serverThread.start() - serverThreads.append(serverThread) + serverThread = ReaderThread(pipe) + serverThread.start() + serverThreads.append(serverThread) def printOutputFromPipe(pipe): @@ -303,9 +303,9 @@ else: if isWin32(): if isCygwin(): - os.environ["PATH"] = os.path.join(toplevel, "bin") + ":" + os.getenv("PATH", "") + os.environ["PATH"] = os.path.join(toplevel, "bin") + ":" + os.getenv("PATH", "") else: - os.environ["PATH"] = os.path.join(toplevel, "bin") + ";" + os.getenv("PATH", "") + os.environ["PATH"] = os.path.join(toplevel, "bin") + ";" + os.getenv("PATH", "") elif isHpUx(): os.environ["SHLIB_PATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("SHLIB_PATH", "") elif isDarwin(): @@ -317,8 +317,8 @@ else: os.environ["LD_LIBRARY_PATH_64"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LD_LIBRARY_PATH_64", "") if protocol == "ssl": - certs = os.path.abspath(os.path.join(toplevel, "certs")) - plugin = " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + certs = os.path.abspath(os.path.join(toplevel, "certs")) + plugin = " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" clientProtocol = plugin + " --Ice.Default.Protocol=ssl" + \ " --IceSSL.DefaultDir=" + certs + \ " --IceSSL.CertFile=c_rsa1024_pub.pem" + \ @@ -358,7 +358,7 @@ commonServerOptions = " --Ice.PrintProcessId --Ice.PrintAdapterReady --Ice.NullH " --Ice.ThreadPool.Server.SizeWarn=0" commonCollocatedOptions = " --Ice.ThreadPool.Server.Size=1 --Ice.ThreadPool.Server.SizeMax=3" + \ - " --Ice.ThreadPool.Server.SizeWarn=0" + " --Ice.ThreadPool.Server.SizeWarn=0" clientOptions = clientProtocol + defaultHost + commonClientOptions serverOptions = serverProtocol + defaultHost + commonServerOptions @@ -378,7 +378,7 @@ def clientServerTestWithOptionsAndNames(name, additionalServerOptions, additiona print "starting " + serverName + "...", serverCmd = "python " + server + serverOptions + additionalServerOptions if debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") getServerPid(serverPipe) getAdapterReady(serverPipe) @@ -387,7 +387,7 @@ def clientServerTestWithOptionsAndNames(name, additionalServerOptions, additiona print "starting " + clientName + "...", clientCmd = "python " + client + clientOptions + additionalClientOptions if debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") print "ok" @@ -395,10 +395,10 @@ def clientServerTestWithOptionsAndNames(name, additionalServerOptions, additiona clientStatus = closePipe(clientPipe) if clientStatus: - killServers() + killServers() if clientStatus or serverStatus(): - sys.exit(1) + sys.exit(1) os.chdir(cwd) @@ -423,7 +423,7 @@ def mixedClientServerTestWithOptions(name, additionalServerOptions, additionalCl print "starting server...", serverCmd = "python " + server + clientServerOptions + additionalServerOptions if debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") getServerPid(serverPipe) getAdapterReady(serverPipe) @@ -432,7 +432,7 @@ def mixedClientServerTestWithOptions(name, additionalServerOptions, additionalCl print "starting client...", clientCmd = "python " + client + clientServerOptions + additionalClientOptions if debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") ignorePid(clientPipe) getAdapterReady(clientPipe, False) @@ -442,10 +442,10 @@ def mixedClientServerTestWithOptions(name, additionalServerOptions, additionalCl clientStatus = closePipe(clientPipe) if clientStatus: - killServers() + killServers() if clientStatus or serverStatus(): - sys.exit(1) + sys.exit(1) os.chdir(cwd) @@ -464,7 +464,7 @@ def collocatedTestWithOptions(name, additionalOptions): print "starting collocated...", command = "python " + collocated + collocatedOptions + additionalOptions if debug: - print "(" + command + ")", + print "(" + command + ")", collocatedPipe = os.popen(command + " 2>&1") print "ok" @@ -473,8 +473,8 @@ def collocatedTestWithOptions(name, additionalOptions): collocatedStatus = closePipe(collocatedPipe) if collocatedStatus: - killServers() - sys.exit(1) + killServers() + sys.exit(1) os.chdir(cwd) diff --git a/py/demo/Glacier2/callback/Client.py b/py/demo/Glacier2/callback/Client.py index c39b818c2a2..4aae7ed161e 100644 --- a/py/demo/Glacier2/callback/Client.py +++ b/py/demo/Glacier2/callback/Client.py @@ -34,37 +34,37 @@ class CallbackReceiverI(Demo.CallbackReceiver): class Client(Ice.Application): def run(self, args): defaultRouter = self.communicator().getDefaultRouter() - if not defaultRouter: - print self.appName() + ": no default router set" - return 1 + if not defaultRouter: + print self.appName() + ": no default router set" + return 1 - router = Glacier2.RouterPrx.checkedCast(defaultRouter) - if not router: - print self.appName() + ": configured router is not a Glacier2 router" - return 1 + router = Glacier2.RouterPrx.checkedCast(defaultRouter) + if not router: + print self.appName() + ": configured router is not a Glacier2 router" + return 1 - while True: - print "This demo accepts any user-id / password combination." + while True: + print "This demo accepts any user-id / password combination." id = raw_input("user id: ") pw = raw_input("password: ") - try: - router.createSession(id, pw) - break - except Glacier2.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason - - category = router.getCategoryForClient() - callbackReceiverIdent = Ice.Identity() - callbackReceiverIdent.name = "callbackReceiver" - callbackReceiverIdent.category = category - callbackReceiverFakeIdent = Ice.Identity() - callbackReceiverFakeIdent.name = "callbackReceiver" - callbackReceiverFakeIdent.category = "fake" + try: + router.createSession(id, pw) + break + except Glacier2.PermissionDeniedException, ex: + print "permission denied:\n" + ex.reason + + category = router.getCategoryForClient() + callbackReceiverIdent = Ice.Identity() + callbackReceiverIdent.name = "callbackReceiver" + callbackReceiverIdent.category = category + callbackReceiverFakeIdent = Ice.Identity() + callbackReceiverFakeIdent.name = "callbackReceiver" + callbackReceiverFakeIdent.category = "fake" base = self.communicator().propertyToProxy('Callback.Proxy') twoway = Demo.CallbackPrx.checkedCast(base) - oneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_oneway()) - batchOneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_batchOneway()) + oneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_oneway()) + batchOneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_batchOneway()) adapter = self.communicator().createObjectAdapter("Callback.Client") adapter.add(CallbackReceiverI(), callbackReceiverIdent) @@ -75,7 +75,7 @@ class Client(Ice.Application): onewayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_oneway()) override = '' - fake = False + fake = False menu() @@ -84,41 +84,41 @@ class Client(Ice.Application): try: c = raw_input("==> ") if c == 't': - context = {} - context["_fwd"] = "t" - if not len(override) == 0: - context["_ovrd"] = override + context = {} + context["_fwd"] = "t" + if not len(override) == 0: + context["_ovrd"] = override twoway.initiateCallback(twowayR, context) elif c == 'o': - context = {} - context["_fwd"] = "o" - if not len(override) == 0: - context["_ovrd"] = override + context = {} + context["_fwd"] = "o" + if not len(override) == 0: + context["_ovrd"] = override oneway.initiateCallback(onewayR, context) elif c == 'O': - context = {} - context["_fwd"] = "O" - if not len(override) == 0: - context["_ovrd"] = override + context = {} + context["_fwd"] = "O" + if not len(override) == 0: + context["_ovrd"] = override batchOneway.initiateCallback(onewayR, context) - elif c == 'f': - self.communicator().flushBatchRequests() - elif c == 'v': - if len(override) == 0: - override = "some_value" - print "override context field is now `" + override + "'" - else: - override = '' - print "override context field is empty" - elif c == 'F': - fake = not fake - - if fake: - twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverFakeIdent)) - onewayR = Demo.CallbackReceiverPrx.uncheckedCast(onewayR.ice_identity(callbackReceiverFakeIdent)) - else: - twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverIdent)) - onewayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverIdent)) + elif c == 'f': + self.communicator().flushBatchRequests() + elif c == 'v': + if len(override) == 0: + override = "some_value" + print "override context field is now `" + override + "'" + else: + override = '' + print "override context field is empty" + elif c == 'F': + fake = not fake + + if fake: + twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverFakeIdent)) + onewayR = Demo.CallbackReceiverPrx.uncheckedCast(onewayR.ice_identity(callbackReceiverFakeIdent)) + else: + twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverIdent)) + onewayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_identity(callbackReceiverIdent)) elif c == 's': twoway.shutdown() elif c == 'x': diff --git a/py/demo/Glacier2/callback/Server.py b/py/demo/Glacier2/callback/Server.py index d6076c0dd30..61f4f81dc2c 100644 --- a/py/demo/Glacier2/callback/Server.py +++ b/py/demo/Glacier2/callback/Server.py @@ -16,10 +16,10 @@ import Demo class CallbackI(Demo.Callback): def initiateCallback(self, proxy, current=None): print "initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy) - try: - proxy.callback(current.ctx) - except: - traceback.print_exc() + try: + proxy.callback(current.ctx) + except: + traceback.print_exc() def shutdown(self, current=None): print "shutting down..." @@ -27,11 +27,11 @@ class CallbackI(Demo.Callback): class Server(Ice.Application): def run(self, args): - adapter = self.communicator().createObjectAdapter("Callback.Server") - adapter.add(CallbackI(), self.communicator().stringToIdentity("callback")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Callback.Server") + adapter.add(CallbackI(), self.communicator().stringToIdentity("callback")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/Glacier2/callback/SessionServer.py b/py/demo/Glacier2/callback/SessionServer.py index 7fcaef7cb03..af496d28652 100644 --- a/py/demo/Glacier2/callback/SessionServer.py +++ b/py/demo/Glacier2/callback/SessionServer.py @@ -13,7 +13,7 @@ import sys, traceback, Ice, Glacier2 class DummyPermissionsVerifierI(Glacier2.PermissionsVerifier): def checkPermissions(self, userId, password, current=None): print "verified user `" + userId + "' with password `" + password + "'" - return (True, "") + return (True, "") class SessionI(Glacier2.Session): def __init__(self, userId): @@ -21,22 +21,22 @@ class SessionI(Glacier2.Session): def destroy(self, current=None): print "destroying session for user `" + self.userId + "'" - current.adapter.remove(current.id) + current.adapter.remove(current.id) class SessionManagerI(Glacier2.SessionManager): def create(self, userId, control, current=None): print "creating session for user `" + userId + "'" - session = SessionI(userId) - return Glacier2.SessionPrx.uncheckedCast(current.adapter.addWithUUID(session)) + session = SessionI(userId) + return Glacier2.SessionPrx.uncheckedCast(current.adapter.addWithUUID(session)) class SessionServer(Ice.Application): def run(self, args): - adapter = self.communicator().createObjectAdapter("SessionServer") - adapter.add(DummyPermissionsVerifierI(), self.communicator().stringToIdentity("verifier")) - adapter.add(SessionManagerI(), self.communicator().stringToIdentity("sessionmanager")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("SessionServer") + adapter.add(DummyPermissionsVerifierI(), self.communicator().stringToIdentity("verifier")) + adapter.add(SessionManagerI(), self.communicator().stringToIdentity("sessionmanager")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = SessionServer() sys.exit(app.main(sys.argv, "config.sessionserver")) diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py index 9590f67ca46..96676a4f560 100644 --- a/py/demo/Ice/async/Client.py +++ b/py/demo/Ice/async/Client.py @@ -32,38 +32,38 @@ x: exit class Client(Ice.Application): def run(self, args): - hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) - if not hello: - print args[0] + ": invalid proxy" - return False + hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) + if not hello: + print args[0] + ": invalid proxy" + return False - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 'i': - hello.sayHello(0) - elif c == 'd': - hello.sayHello_async(AMI_Hello_sayHelloI(), 5000) - elif c == 's': - hello.shutdown() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break - except KeyboardInterrupt: - break - except Ice.Exception, ex: - print ex + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 'i': + hello.sayHello(0) + elif c == 'd': + hello.sayHello_async(AMI_Hello_sayHelloI(), 5000) + elif c == 's': + hello.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except KeyboardInterrupt: + break + except Ice.Exception, ex: + print ex - return True + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/async/Server.py b/py/demo/Ice/async/Server.py index 386dd77bb59..28ef53d796d 100755 --- a/py/demo/Ice/async/Server.py +++ b/py/demo/Ice/async/Server.py @@ -15,99 +15,99 @@ import Demo class CallbackEntry(object): def __init__(self, cb, delay): - self.cb = cb + self.cb = cb self.delay = delay class WorkQueue(threading.Thread): def __init__(self): threading.Thread.__init__(self) - self._callbacks = [] - self._done = False - self._cond = threading.Condition() + self._callbacks = [] + self._done = False + self._cond = threading.Condition() def run(self): self._cond.acquire() - try: - while not self._done: - if len(self._callbacks) == 0: - self._cond.wait() + try: + while not self._done: + if len(self._callbacks) == 0: + self._cond.wait() - if not len(self._callbacks) == 0: - self._cond.wait(self._callbacks[0].delay / 1000.0) + if not len(self._callbacks) == 0: + self._cond.wait(self._callbacks[0].delay / 1000.0) - if not self._done: - print "Belated Hello World!" - self._callbacks[0].cb.ice_response() - del self._callbacks[0] + if not self._done: + print "Belated Hello World!" + self._callbacks[0].cb.ice_response() + del self._callbacks[0] - for i in range(0, len(self._callbacks)): - self._callbacks[i].cb.ice_exception(Demo.RequestCanceledException()) - finally: - self._cond.release() + for i in range(0, len(self._callbacks)): + self._callbacks[i].cb.ice_exception(Demo.RequestCanceledException()) + finally: + self._cond.release() def add(self, cb, delay): self._cond.acquire() - try: - if not self._done: - entry = CallbackEntry(cb, delay) - if len(self._callbacks) == 0: - self._cond.notify() - self._callbacks.append(entry) - else: - cb.ice_exception(Demo.RequestCanceledException()) - finally: - self._cond.release() + try: + if not self._done: + entry = CallbackEntry(cb, delay) + if len(self._callbacks) == 0: + self._cond.notify() + self._callbacks.append(entry) + else: + cb.ice_exception(Demo.RequestCanceledException()) + finally: + self._cond.release() def destroy(self): self._cond.acquire() - try: - self._done = True - self._cond.notify() - finally: - self._cond.release() + try: + self._done = True + self._cond.notify() + finally: + self._cond.release() class HelloI(Demo.Hello): def __init__(self, workQueue): - self._workQueue = workQueue + self._workQueue = workQueue def sayHello_async(self, cb, delay, current=None): if delay == 0: - print "Hello World!" - cb.ice_response() - else: - self._workQueue.add(cb, delay) + print "Hello World!" + cb.ice_response() + else: + self._workQueue.add(cb, delay) def shutdown(self, current=None): self._workQueue.destroy() - self._workQueue.join() + self._workQueue.join() - current.adpater.getCommunicator().shutdown(); + current.adpater.getCommunicator().shutdown(); class Server(Ice.Application): def run(self, args): self.callbackOnInterrupt() - adapter = self.communicator().createObjectAdapter("Hello") - self._workQueue = WorkQueue() - adapter.add(HelloI(self._workQueue), self.communicator().stringToIdentity("hello")) - - self._workQueue.start() - adapter.activate() - - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Hello") + self._workQueue = WorkQueue() + adapter.add(HelloI(self._workQueue), self.communicator().stringToIdentity("hello")) + + self._workQueue.start() + adapter.activate() + + self.communicator().waitForShutdown() + return True def interruptCallback(self, sig): self._workQueue.destroy() - self._workQueue.join() + self._workQueue.join() - try: - self._communicator.destroy() - except: - traceback.print_exc() + try: + self._communicator.destroy() + except: + traceback.print_exc() app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/Ice/bidir/Client.py b/py/demo/Ice/bidir/Client.py index 0d10f0a107d..5c52c0185a1 100644 --- a/py/demo/Ice/bidir/Client.py +++ b/py/demo/Ice/bidir/Client.py @@ -34,14 +34,14 @@ class Client(Ice.Application): return 1 adapter = self.communicator().createObjectAdapter("") - ident = Ice.Identity() - ident.name = Ice.generateUUID() - ident.category = "" + ident = Ice.Identity() + ident.name = Ice.generateUUID() + ident.category = "" adapter.add(CallbackReceiverI(), ident) adapter.activate() - server.ice_getConnection().setAdapter(adapter) - server.addClient(ident) - self.communicator().waitForShutdown() + server.ice_getConnection().setAdapter(adapter) + server.addClient(ident) + self.communicator().waitForShutdown() return 0 diff --git a/py/demo/Ice/bidir/Server.py b/py/demo/Ice/bidir/Server.py index 68e983f7c91..05dfbaf7f88 100644 --- a/py/demo/Ice/bidir/Server.py +++ b/py/demo/Ice/bidir/Server.py @@ -25,68 +25,68 @@ import Demo class CallbackSenderI(Demo.CallbackSender, threading.Thread): def __init__(self, communicator): - threading.Thread.__init__(self) - self._communicator = communicator - self._destroy = False - self._num = 0 - self._clients = [] - self._cond = threading.Condition() + threading.Thread.__init__(self) + self._communicator = communicator + self._destroy = False + self._num = 0 + self._clients = [] + self._cond = threading.Condition() def destroy(self): - self._cond.acquire() + self._cond.acquire() - print "destroying callback sender" - self._destroy = True + print "destroying callback sender" + self._destroy = True - try: - self._cond.notify() - finally: - self._cond.release() + try: + self._cond.notify() + finally: + self._cond.release() - self.join() + self.join() def addClient(self, ident, current=None): - self._cond.acquire() + self._cond.acquire() print "adding client `" + self._communicator.identityToString(ident) + "'" - client = Demo.CallbackReceiverPrx.uncheckedCast(current.con.createProxy(ident)) - self._clients.append(client) + client = Demo.CallbackReceiverPrx.uncheckedCast(current.con.createProxy(ident)) + self._clients.append(client) - self._cond.release() + self._cond.release() def run(self): - self._cond.acquire() + self._cond.acquire() - try: - while not self._destroy: - self._cond.wait(2) + try: + while not self._destroy: + self._cond.wait(2) - if not self._destroy and len(self._clients) > 0: - self._num = self._num + 1 + if not self._destroy and len(self._clients) > 0: + self._num = self._num + 1 - for p in self._clients[:]: # Iterate over a copy so we can modify the original list. - try: - p.callback(self._num) - except: - print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" - traceback.print_exc() - self._clients.remove(p) - finally: - self._cond.release() + for p in self._clients[:]: # Iterate over a copy so we can modify the original list. + try: + p.callback(self._num) + except: + print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" + traceback.print_exc() + self._clients.remove(p) + finally: + self._cond.release() class Server(Ice.Application): def run(self, args): adapter = self.communicator().createObjectAdapter("Callback.Server") - sender = CallbackSenderI(self.communicator()) + sender = CallbackSenderI(self.communicator()) adapter.add(sender, self.communicator().stringToIdentity("sender")) adapter.activate() - sender.start() - try: - self.communicator().waitForShutdown() - finally: - sender.destroy() + sender.start() + try: + self.communicator().waitForShutdown() + finally: + sender.destroy() return 0 diff --git a/py/demo/Ice/hello/Client.py b/py/demo/Ice/hello/Client.py index 271143a1ee3..f0c79b73cea 100644 --- a/py/demo/Ice/hello/Client.py +++ b/py/demo/Ice/hello/Client.py @@ -32,99 +32,99 @@ x: exit class Client(Ice.Application): def run(self, args): - twoway = Demo.HelloPrx.checkedCast(\ - self.communicator().propertyToProxy('Hello.Proxy').ice_twoway().ice_timeout(-1).ice_secure(False)) - if not twoway: - print args[0] + ": invalid proxy" - return False + twoway = Demo.HelloPrx.checkedCast(\ + self.communicator().propertyToProxy('Hello.Proxy').ice_twoway().ice_timeout(-1).ice_secure(False)) + if not twoway: + print args[0] + ": invalid proxy" + return False - oneway = Demo.HelloPrx.uncheckedCast(twoway.ice_oneway()) - batchOneway = Demo.HelloPrx.uncheckedCast(twoway.ice_batchOneway()) - datagram = Demo.HelloPrx.uncheckedCast(twoway.ice_datagram()) - batchDatagram = Demo.HelloPrx.uncheckedCast(twoway.ice_batchDatagram()) + oneway = Demo.HelloPrx.uncheckedCast(twoway.ice_oneway()) + batchOneway = Demo.HelloPrx.uncheckedCast(twoway.ice_batchOneway()) + datagram = Demo.HelloPrx.uncheckedCast(twoway.ice_datagram()) + batchDatagram = Demo.HelloPrx.uncheckedCast(twoway.ice_batchDatagram()) - secure = False - timeout = -1 - delay = 0 + secure = False + timeout = -1 + delay = 0 - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 't': - twoway.sayHello(delay) - elif c == 'o': - oneway.sayHello(delay) - elif c == 'O': - batchOneway.sayHello(delay) - elif c == 'd': - if secure: - print "secure datagrams are not supported" - else: - datagram.sayHello(delay) - elif c == 'D': - if secure: - print "secure datagrams are not supported" - else: - batchDatagram.sayHello(delay) - elif c == 'f': - self.communicator().flushBatchRequests() - elif c == 'T': - if timeout == -1: - timeout = 2000 - else: - timeout = -1 + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + twoway.sayHello(delay) + elif c == 'o': + oneway.sayHello(delay) + elif c == 'O': + batchOneway.sayHello(delay) + elif c == 'd': + if secure: + print "secure datagrams are not supported" + else: + datagram.sayHello(delay) + elif c == 'D': + if secure: + print "secure datagrams are not supported" + else: + batchDatagram.sayHello(delay) + elif c == 'f': + self.communicator().flushBatchRequests() + elif c == 'T': + if timeout == -1: + timeout = 2000 + else: + timeout = -1 - twoway = Demo.HelloPrx.uncheckedCast(twoway.ice_timeout(timeout)) - oneway = Demo.HelloPrx.uncheckedCast(oneway.ice_timeout(timeout)) - batchOneway = Demo.HelloPrx.uncheckedCast(batchOneway.ice_timeout(timeout)) + twoway = Demo.HelloPrx.uncheckedCast(twoway.ice_timeout(timeout)) + oneway = Demo.HelloPrx.uncheckedCast(oneway.ice_timeout(timeout)) + batchOneway = Demo.HelloPrx.uncheckedCast(batchOneway.ice_timeout(timeout)) - if timeout == -1: - print "timeout is now switched off" - else: - print "timeout is now set to 2000ms" - elif c == 'P': - if delay == 0: - delay = 2500 - else: - delay = 0 + if timeout == -1: + print "timeout is now switched off" + else: + print "timeout is now set to 2000ms" + elif c == 'P': + if delay == 0: + delay = 2500 + else: + delay = 0 - if delay == 0: - print "server delay is now deactivated" - else: - print "server delay is now set to 2500ms" - elif c == 'S': - secure = not secure + if delay == 0: + print "server delay is now deactivated" + else: + print "server delay is now set to 2500ms" + elif c == 'S': + secure = not secure - twoway = Demo.HelloPrx.uncheckedCast(twoway.ice_secure(secure)) - oneway = Demo.HelloPrx.uncheckedCast(oneway.ice_secure(secure)) - batchOneway = Demo.HelloPrx.uncheckedCast(batchOneway.ice_secure(secure)) - datagram = Demo.HelloPrx.uncheckedCast(datagram.ice_secure(secure)) - batchDatagram = Demo.HelloPrx.uncheckedCast(batchDatagram.ice_secure(secure)) + twoway = Demo.HelloPrx.uncheckedCast(twoway.ice_secure(secure)) + oneway = Demo.HelloPrx.uncheckedCast(oneway.ice_secure(secure)) + batchOneway = Demo.HelloPrx.uncheckedCast(batchOneway.ice_secure(secure)) + datagram = Demo.HelloPrx.uncheckedCast(datagram.ice_secure(secure)) + batchDatagram = Demo.HelloPrx.uncheckedCast(batchDatagram.ice_secure(secure)) - if secure: - print "secure mode is now on" - else: - print "secure mode is now off" - elif c == 's': - twoway.shutdown() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except KeyboardInterrupt: - break - except EOFError: - break - except Ice.Exception, ex: - print ex + if secure: + print "secure mode is now on" + else: + print "secure mode is now off" + elif c == 's': + twoway.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except KeyboardInterrupt: + break + except EOFError: + break + except Ice.Exception, ex: + print ex - return True + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/hello/Server.py b/py/demo/Ice/hello/Server.py index 6e9e7e7a7bf..411be791aa8 100644 --- a/py/demo/Ice/hello/Server.py +++ b/py/demo/Ice/hello/Server.py @@ -16,7 +16,7 @@ import Demo class HelloI(Demo.Hello): def sayHello(self, delay, current=None): if delay != 0: - time.sleep(delay / 1000.0) + time.sleep(delay / 1000.0) print "Hello World!" def shutdown(self, current=None): @@ -24,11 +24,11 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): - adapter = self.communicator().createObjectAdapter("Hello") - adapter.add(HelloI(), self.communicator().stringToIdentity("hello")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Hello") + adapter.add(HelloI(), self.communicator().stringToIdentity("hello")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/Ice/latency/Client.py b/py/demo/Ice/latency/Client.py index 8e185e19efc..fd6cf0b705e 100644 --- a/py/demo/Ice/latency/Client.py +++ b/py/demo/Ice/latency/Client.py @@ -15,31 +15,31 @@ import Demo class Client(Ice.Application): def run(self, args): - ping = Demo.PingPrx.checkedCast(self.communicator().propertyToProxy('Latency.Ping')) - if not ping: - print "invalid proxy" - return False + ping = Demo.PingPrx.checkedCast(self.communicator().propertyToProxy('Latency.Ping')) + if not ping: + print "invalid proxy" + return False - # Initial ping to setup the connection. - ping.ice_ping(); + # Initial ping to setup the connection. + ping.ice_ping(); - repetitions = 100000 - print "pinging server " + str(repetitions) + " times (this may take a while)" + repetitions = 100000 + print "pinging server " + str(repetitions) + " times (this may take a while)" - tsec = time.time() + tsec = time.time() - i = repetitions - while(i >= 0): - ping.ice_ping() - i = i - 1 + i = repetitions + while(i >= 0): + ping.ice_ping() + i = i - 1 - tsec = time.time() - tsec - tmsec = tsec * 1000.0 + tsec = time.time() - tsec + tmsec = tsec * 1000.0 - print "time for %d pings: %.3fms" % (repetitions, tmsec) - print "time per ping: %.3fms" % (tmsec / repetitions) + print "time for %d pings: %.3fms" % (repetitions, tmsec) + print "time per ping: %.3fms" % (tmsec / repetitions) - return True + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/latency/Server.py b/py/demo/Ice/latency/Server.py index c828ee161c2..78bcde29a8e 100644 --- a/py/demo/Ice/latency/Server.py +++ b/py/demo/Ice/latency/Server.py @@ -15,11 +15,11 @@ import Demo class Server(Ice.Application): def run(self, args): - adapter = self.communicator().createObjectAdapter("Latency") - adapter.add(Demo.Ping(), self.communicator().stringToIdentity("ping")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Latency") + adapter.add(Demo.Ping(), self.communicator().stringToIdentity("ping")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/Ice/minimal/Client.py b/py/demo/Ice/minimal/Client.py index 27edac09f77..e28df0fa862 100644 --- a/py/demo/Ice/minimal/Client.py +++ b/py/demo/Ice/minimal/Client.py @@ -20,9 +20,9 @@ try: hello = Demo.HelloPrx.checkedCast(communicator.stringToProxy("hello:tcp -p 10000")) if not hello: print args[0] + ": invalid proxy" - status = 1 + status = 1 else: - hello.sayHello() + hello.sayHello() except: traceback.print_exc() status = 1 @@ -32,6 +32,6 @@ if communicator: communicator.destroy() except: traceback.print_exc() - status = 1 + status = 1 sys.exit(status) diff --git a/py/demo/Ice/session/Client.py b/py/demo/Ice/session/Client.py index 7935526b785..63f7ef9997a 100644 --- a/py/demo/Ice/session/Client.py +++ b/py/demo/Ice/session/Client.py @@ -27,22 +27,22 @@ class SessionRefreshThread(threading.Thread): try: while not self._terminated: self._cond.wait(self._timeout) - if not self._terminated: + if not self._terminated: try: self._session.refresh() except Ice.LocalException, ex: self._logger.warning("SessionRefreshThread: " + str(ex)) self._terminated = True - finally: - self._cond.release() + finally: + self._cond.release() def terminate(self): - self._cond.acquire() - try: + self._cond.acquire() + try: self._terminated = True - self._cond.notify() - finally: - self._cond.release() + self._cond.notify() + finally: + self._cond.release() class Client(Ice.Application): def run(self, args): @@ -82,10 +82,10 @@ class Client(Ice.Application): "Use `c' to create a new hello object." elif c == 'c': hellos.append(session.createHello()) - print "Created hello object",len(hellos) - 1 + print "Created hello object",len(hellos) - 1 elif c == 's': - destroy = False - shutdown = True + destroy = False + shutdown = True break elif c == 'x': break @@ -99,8 +99,8 @@ class Client(Ice.Application): self.menu() except EOFError: break - except KeyboardInterrupt: - break + except KeyboardInterrupt: + break # # The refresher thread must be terminated before destroy is # called, otherwise it might get ObjectNotExistException. refresh diff --git a/py/demo/Ice/session/Server.py b/py/demo/Ice/session/Server.py index c29f49c399a..56cd7e2def8 100644 --- a/py/demo/Ice/session/Server.py +++ b/py/demo/Ice/session/Server.py @@ -19,13 +19,13 @@ class HelloI(Demo.Hello): self._id = id def sayHello(self, c): - print "Hello object #" + str(self._id) + " for session `" + self._name + "' says:\n" + \ + print "Hello object #" + str(self._id) + " for session `" + self._name + "' says:\n" + \ "Hello " + self._name + "!" class SessionI(Demo.Session): def __init__(self, name): - self._timestamp = time.time() - self._name = name + self._timestamp = time.time() + self._name = name self._lock = threading.Lock() self._destroy = False # true if destroy() was called, false otherwise. self._nextId = 0 # The id of the next hello object. This is used for tracing purposes. @@ -44,7 +44,7 @@ class SessionI(Demo.Session): self._objs.append(hello) return hello finally: - self._lock.release() + self._lock.release() def refresh(self, c): self._lock.acquire() @@ -53,7 +53,7 @@ class SessionI(Demo.Session): raise Ice.ObjectNotExistException() self._timestamp = time.time() finally: - self._lock.release() + self._lock.release() def getName(self, c): self._lock.acquire() @@ -62,7 +62,7 @@ class SessionI(Demo.Session): raise Ice.ObjectNotExistException() return self._name finally: - self._lock.release() + self._lock.release() def destroy(self, c): self._lock.acquire() @@ -81,7 +81,7 @@ class SessionI(Demo.Session): pass self._objs = [] finally: - self._lock.release() + self._lock.release() def timestamp(self): self._lock.acquire() @@ -90,7 +90,7 @@ class SessionI(Demo.Session): raise Ice.ObjectNotExistException() return self._timestamp finally: - self._lock.release() + self._lock.release() class SessionProxyPair: def __init__(self, p, s): @@ -126,28 +126,28 @@ class ReapThread(threading.Thread): except Ice.ObjectNotExistException: self._sessions.remove(p) finally: - self._cond.release() + self._cond.release() def terminate(self): - self._cond.acquire() - try: + self._cond.acquire() + try: self._terminated = True - self._cond.notify() + self._cond.notify() self._sessions = [] finally: - self._cond.release() + self._cond.release() def add(self, proxy, session): - self._cond.acquire() - try: + self._cond.acquire() + try: self._sessions.append(SessionProxyPair(proxy, session)) finally: - self._cond.release() + self._cond.release() class SessionFactoryI(Demo.SessionFactory): def __init__(self, reaper): - self._reaper = reaper + self._reaper = reaper self._lock = threading.Lock() def create(self, name, c): @@ -161,8 +161,8 @@ class SessionFactoryI(Demo.SessionFactory): self._lock.release() def shutdown(self, c): - print "Shutting down..." - c.adapter.getCommunicator().shutdown() + print "Shutting down..." + c.adapter.getCommunicator().shutdown() class Server(Ice.Application): def run(self, args): diff --git a/py/demo/Ice/throughput/Client.py b/py/demo/Ice/throughput/Client.py index 8f198ceca84..fc5ff5de065 100644 --- a/py/demo/Ice/throughput/Client.py +++ b/py/demo/Ice/throughput/Client.py @@ -37,160 +37,160 @@ x: exit class Client(Ice.Application): def run(self, args): - throughput = Demo.ThroughputPrx.checkedCast(self.communicator().propertyToProxy('Throughput.Throughput')) - if not throughput: - print args[0] + ": invalid proxy" - return False - throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway()) - - bytes = [] - bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) - bytes = ['\x00' for x in bytes] - byteSeq = ''.join(bytes) - - stringSeq = [] - stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) - stringSeq = ["hello" for x in stringSeq] - - structSeq = [] - structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize) - for i in range(0, Demo.StringDoubleSeqSize): - structSeq[i] = Demo.StringDouble() - structSeq[i].s = "hello" - structSeq[i].d = 3.14 - - fixedSeq = [] - fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize) - for i in range(0, Demo.FixedSeqSize): - fixedSeq[i] = Demo.Fixed() - fixedSeq[i].i = 0 - fixedSeq[i].j = 0 - fixedSeq[i].d = 0.0 - - menu() - - throughput.endWarmup() # Initial ping to setup the connection. - - currentType = '1' - seqSize = Demo.ByteSeqSize - - c = None - while c != 'x': - try: - c = raw_input("==> ") - - repetitions = 100 - - if c == '1' or c == '2' or c == '3' or c == '4': - currentType = c - if c == '1': - print "using byte sequences" - seqSize = Demo.ByteSeqSize - elif c == '2': - print "using string sequences" - seqSize = Demo.StringSeqSize - elif c == '3': - print "using variable-length struct sequences" - seqSize = Demo.StringDoubleSeqSize - elif c == '4': - print "using fixed-length struct sequences" - seqSize = Demo.FixedSeqSize - elif c == 't' or c == 'o' or c == 'r' or c == 'e': - if c == 't' or c == 'o': - print "sending", - elif c == 'r': - print "receiving", - elif c == 'e': - print "sending and receiving", - - print repetitions, - if currentType == '1': - print "byte", - elif currentType == '2': - print "string", - elif currentType == '3': - print "variable-length struct", - elif currentType == '4': - print "fixed-length struct", - - if c == 'o': - print "sequences of size %d as oneway..." % seqSize - else: - print "sequences of size %d..." % seqSize - - tsec = time.time() - - for i in range(0, repetitions): - if currentType == '1': - if c == 't': - throughput.sendByteSeq(byteSeq) - elif c == 'o': - throughputOneway.sendByteSeq(byteSeq) - elif c == 'r': - throughput.recvByteSeq() - elif c == 'e': - throughput.echoByteSeq(byteSeq) - elif currentType == '2': - if c == 't': - throughput.sendStringSeq(stringSeq) - elif c == 'o': - throughputOneway.sendStringSeq(stringSeq) - elif c == 'r': - throughput.recvStringSeq() - elif c == 'e': - throughput.echoStringSeq(stringSeq) - elif currentType == '3': - if c == 't': - throughput.sendStructSeq(structSeq) - elif c == 'o': - throughputOneway.sendStructSeq(structSeq) - elif c == 'r': - throughput.recvStructSeq() - elif c == 'e': - throughput.echoStructSeq(structSeq) - elif currentType == '4': - if c == 't': - throughput.sendFixedSeq(fixedSeq) - elif c == 'o': - throughputOneway.sendFixedSeq(fixedSeq) - elif c == 'r': - throughput.recvFixedSeq() - elif c == 'e': - throughput.echoFixedSeq(fixedSeq) - - tsec = time.time() - tsec - tmsec = tsec * 1000.0 - print "time for %d sequences: %.3fms" % (repetitions, tmsec) - print "time per sequence: %.3fms" % (tmsec / repetitions) - wireSize = 0 - if currentType == '1': - wireSize = 1 - elif currentType == '2': - wireSize = len(stringSeq[0]) - elif currentType == '3': - wireSize = len(structSeq[0].s) - wireSize += 8 - elif currentType == '4': - wireSize = 16 - mbit = repetitions * seqSize * wireSize * 8.0 / tsec / 1000000.0 - if c == 'e': - mbit = mbit * 2 - print "throughput: %.3fMbps" % mbit - elif c == 's': - throughput.shutdown() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break + throughput = Demo.ThroughputPrx.checkedCast(self.communicator().propertyToProxy('Throughput.Throughput')) + if not throughput: + print args[0] + ": invalid proxy" + return False + throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway()) + + bytes = [] + bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) + bytes = ['\x00' for x in bytes] + byteSeq = ''.join(bytes) + + stringSeq = [] + stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) + stringSeq = ["hello" for x in stringSeq] + + structSeq = [] + structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize) + for i in range(0, Demo.StringDoubleSeqSize): + structSeq[i] = Demo.StringDouble() + structSeq[i].s = "hello" + structSeq[i].d = 3.14 + + fixedSeq = [] + fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize) + for i in range(0, Demo.FixedSeqSize): + fixedSeq[i] = Demo.Fixed() + fixedSeq[i].i = 0 + fixedSeq[i].j = 0 + fixedSeq[i].d = 0.0 + + menu() + + throughput.endWarmup() # Initial ping to setup the connection. + + currentType = '1' + seqSize = Demo.ByteSeqSize + + c = None + while c != 'x': + try: + c = raw_input("==> ") + + repetitions = 100 + + if c == '1' or c == '2' or c == '3' or c == '4': + currentType = c + if c == '1': + print "using byte sequences" + seqSize = Demo.ByteSeqSize + elif c == '2': + print "using string sequences" + seqSize = Demo.StringSeqSize + elif c == '3': + print "using variable-length struct sequences" + seqSize = Demo.StringDoubleSeqSize + elif c == '4': + print "using fixed-length struct sequences" + seqSize = Demo.FixedSeqSize + elif c == 't' or c == 'o' or c == 'r' or c == 'e': + if c == 't' or c == 'o': + print "sending", + elif c == 'r': + print "receiving", + elif c == 'e': + print "sending and receiving", + + print repetitions, + if currentType == '1': + print "byte", + elif currentType == '2': + print "string", + elif currentType == '3': + print "variable-length struct", + elif currentType == '4': + print "fixed-length struct", + + if c == 'o': + print "sequences of size %d as oneway..." % seqSize + else: + print "sequences of size %d..." % seqSize + + tsec = time.time() + + for i in range(0, repetitions): + if currentType == '1': + if c == 't': + throughput.sendByteSeq(byteSeq) + elif c == 'o': + throughputOneway.sendByteSeq(byteSeq) + elif c == 'r': + throughput.recvByteSeq() + elif c == 'e': + throughput.echoByteSeq(byteSeq) + elif currentType == '2': + if c == 't': + throughput.sendStringSeq(stringSeq) + elif c == 'o': + throughputOneway.sendStringSeq(stringSeq) + elif c == 'r': + throughput.recvStringSeq() + elif c == 'e': + throughput.echoStringSeq(stringSeq) + elif currentType == '3': + if c == 't': + throughput.sendStructSeq(structSeq) + elif c == 'o': + throughputOneway.sendStructSeq(structSeq) + elif c == 'r': + throughput.recvStructSeq() + elif c == 'e': + throughput.echoStructSeq(structSeq) + elif currentType == '4': + if c == 't': + throughput.sendFixedSeq(fixedSeq) + elif c == 'o': + throughputOneway.sendFixedSeq(fixedSeq) + elif c == 'r': + throughput.recvFixedSeq() + elif c == 'e': + throughput.echoFixedSeq(fixedSeq) + + tsec = time.time() - tsec + tmsec = tsec * 1000.0 + print "time for %d sequences: %.3fms" % (repetitions, tmsec) + print "time per sequence: %.3fms" % (tmsec / repetitions) + wireSize = 0 + if currentType == '1': + wireSize = 1 + elif currentType == '2': + wireSize = len(stringSeq[0]) + elif currentType == '3': + wireSize = len(structSeq[0].s) + wireSize += 8 + elif currentType == '4': + wireSize = 16 + mbit = repetitions * seqSize * wireSize * 8.0 / tsec / 1000000.0 + if c == 'e': + mbit = mbit * 2 + print "throughput: %.3fMbps" % mbit + elif c == 's': + throughput.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break except KeyboardInterrupt: break - return True + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/throughput/Server.py b/py/demo/Ice/throughput/Server.py index b7009b0a9c2..9f03be11d3b 100644 --- a/py/demo/Ice/throughput/Server.py +++ b/py/demo/Ice/throughput/Server.py @@ -16,11 +16,11 @@ import Demo class ThroughputI(Demo.Throughput): def __init__(self): warmup = True - - bytes = [] - bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) - bytes = ['\x00' for x in bytes] - self.byteSeq = ''.join(bytes) + + bytes = [] + bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) + bytes = ['\x00' for x in bytes] + self.byteSeq = ''.join(bytes) self.stringSeq = [] self.stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) @@ -28,29 +28,29 @@ class ThroughputI(Demo.Throughput): self.structSeq = [] self.structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize) - for i in range(0, Demo.StringDoubleSeqSize): - self.structSeq[i] = Demo.StringDouble() - self.structSeq[i].s = "hello" - self.structSeq[i].d = 3.14 + for i in range(0, Demo.StringDoubleSeqSize): + self.structSeq[i] = Demo.StringDouble() + self.structSeq[i].s = "hello" + self.structSeq[i].d = 3.14 self.fixedSeq = [] self.fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize) - for i in range(0, Demo.FixedSeqSize): - self.fixedSeq[i] = Demo.Fixed() - self.fixedSeq[i].i = 0 - self.fixedSeq[i].j = 0 - self.fixedSeq[i].d = 0.0 + for i in range(0, Demo.FixedSeqSize): + self.fixedSeq[i] = Demo.Fixed() + self.fixedSeq[i].i = 0 + self.fixedSeq[i].j = 0 + self.fixedSeq[i].d = 0.0 def endWarmup(self, current=None): self.warmup = False - + def sendByteSeq(self, seq, current=None): pass def recvByteSeq(self, current=None): if self.warmup: - return [] - else: + return [] + else: return self.byteSeq def echoByteSeq(self, seq, current=None): @@ -61,8 +61,8 @@ class ThroughputI(Demo.Throughput): def recvStringSeq(self, current=None): if self.warmup: - return [] - else: + return [] + else: return self.stringSeq def echoStringSeq(self, seq, current=None): @@ -73,8 +73,8 @@ class ThroughputI(Demo.Throughput): def recvStructSeq(self, current=None): if self.warmup: - return [] - else: + return [] + else: return self.structSeq def echoStructSeq(self, seq, current=None): @@ -85,8 +85,8 @@ class ThroughputI(Demo.Throughput): def recvFixedSeq(self, current=None): if self.warmup: - return [] - else: + return [] + else: return self.fixedSeq def echoFixedSeq(self, seq, current=None): @@ -97,11 +97,11 @@ class ThroughputI(Demo.Throughput): class Server(Ice.Application): def run(self, args): - adapter = self.communicator().createObjectAdapter("Throughput") - adapter.add(ThroughputI(), self.communicator().stringToIdentity("throughput")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Throughput") + adapter.add(ThroughputI(), self.communicator().stringToIdentity("throughput")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/Ice/value/Client.py b/py/demo/Ice/value/Client.py index 4b1698fc3fe..f779d014868 100644 --- a/py/demo/Ice/value/Client.py +++ b/py/demo/Ice/value/Client.py @@ -29,126 +29,126 @@ class ObjectFactory(Ice.ObjectFactory): class Client(Ice.Application): def run(self, args): - base = self.communicator().propertyToProxy('Value.Initial') - initial = Demo.InitialPrx.checkedCast(base) - if not initial: - print args[0] + ": invalid proxy" - return False - - print '\n'\ - "Let's first transfer a simple object, for a class without\n"\ - "operations, and print its contents. No factory is required\n"\ - "for this.\n"\ - "[press enter]" - raw_input() - - simple = initial.getSimple() - print "==> " + simple.message - - print '\n'\ - "Yes, this worked. Now let's try to transfer an object for a class\n"\ - "with operations as type ::Demo::Printer, without installing a factory\n"\ - "first. This should give us a `no factory' exception.\n"\ - "[press enter]" - raw_input() - - try: - printer, printerProxy = initial.getPrinter() - print args[0] + ": Did not get the expected NoObjectFactoryException!" - sys.exit(false) - except Ice.NoObjectFactoryException, ex: - print "==>", ex - - print '\n'\ - "Yep, that's what we expected. Now let's try again, but with\n"\ - "installing an appropriate factory first. If successful, we print\n"\ - "the object's content.\n"\ - "[press enter]" - raw_input() - - factory = ObjectFactory() - self.communicator().addObjectFactory(factory, "::Demo::Printer") - - printer, printerProxy = initial.getPrinter() - print "==> " + printer.message - - print '\n'\ - "Cool, it worked! Let's try calling the printBackwards() method\n"\ - "on the object we just received locally.\n"\ - "[press enter]" - raw_input() - - print "==>", - printer.printBackwards() - - print '\n'\ - "Now we call the same method, but on the remote object. Watch the\n"\ - "server's output.\n"\ - "[press enter]" - raw_input() - - printerProxy.printBackwards() - - print '\n'\ - "Next, we transfer a derived object from the server as a base\n"\ - "object. Since we haven't yet installed a factory for the derived\n"\ - "class, the derived class (::Demo::DerivedPrinter) is sliced\n"\ - "to its base class (::Demo::Printer).\n"\ - "[press enter]" - raw_input() - - derivedAsBase = initial.getDerivedPrinter() - print "==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\"" - assert(derivedAsBase.ice_id() == "::Demo::Printer") - - print '\n'\ - "Now we install a factory for the derived class, and try again.\n"\ - "Because we receive the derived object as a base object, we\n"\ - "we need to do a dynamic_cast<> to get from the base to the derived object.\n"\ - "[press enter]" - raw_input() - - self.communicator().addObjectFactory(factory, "::Demo::DerivedPrinter") - - derived = initial.getDerivedPrinter() - print "==> The type ID of the received object is \"" + derived.ice_id() + "\"" - - print '\n'\ - "Let's print the message contained in the derived object, and\n"\ - "call the operation printUppercase() on the derived object\n"\ - "locally.\n"\ - "[press enter]" - raw_input() - - print "==> " + derived.derivedMessage - print "==>", - derived.printUppercase() - - print '\n'\ - "Finally, we try the same again, but instead of returning the\n"\ - "derived object, we throw an exception containing the derived\n"\ - "object.\n"\ - "[press enter]" - raw_input() - - try: - initial.throwDerivedPrinter() - print args[0] + "Did not get the expected DerivedPrinterException!" - sys.exit(false) - except Demo.DerivedPrinterException, ex: - derived = ex.derived - assert(derived) - - print "==> " + derived.derivedMessage - print "==>", - derived.printUppercase() - - print '\n'\ - "That's it for this demo. Have fun with Ice!" - - initial.shutdown() - - return True + base = self.communicator().propertyToProxy('Value.Initial') + initial = Demo.InitialPrx.checkedCast(base) + if not initial: + print args[0] + ": invalid proxy" + return False + + print '\n'\ + "Let's first transfer a simple object, for a class without\n"\ + "operations, and print its contents. No factory is required\n"\ + "for this.\n"\ + "[press enter]" + raw_input() + + simple = initial.getSimple() + print "==> " + simple.message + + print '\n'\ + "Yes, this worked. Now let's try to transfer an object for a class\n"\ + "with operations as type ::Demo::Printer, without installing a factory\n"\ + "first. This should give us a `no factory' exception.\n"\ + "[press enter]" + raw_input() + + try: + printer, printerProxy = initial.getPrinter() + print args[0] + ": Did not get the expected NoObjectFactoryException!" + sys.exit(false) + except Ice.NoObjectFactoryException, ex: + print "==>", ex + + print '\n'\ + "Yep, that's what we expected. Now let's try again, but with\n"\ + "installing an appropriate factory first. If successful, we print\n"\ + "the object's content.\n"\ + "[press enter]" + raw_input() + + factory = ObjectFactory() + self.communicator().addObjectFactory(factory, "::Demo::Printer") + + printer, printerProxy = initial.getPrinter() + print "==> " + printer.message + + print '\n'\ + "Cool, it worked! Let's try calling the printBackwards() method\n"\ + "on the object we just received locally.\n"\ + "[press enter]" + raw_input() + + print "==>", + printer.printBackwards() + + print '\n'\ + "Now we call the same method, but on the remote object. Watch the\n"\ + "server's output.\n"\ + "[press enter]" + raw_input() + + printerProxy.printBackwards() + + print '\n'\ + "Next, we transfer a derived object from the server as a base\n"\ + "object. Since we haven't yet installed a factory for the derived\n"\ + "class, the derived class (::Demo::DerivedPrinter) is sliced\n"\ + "to its base class (::Demo::Printer).\n"\ + "[press enter]" + raw_input() + + derivedAsBase = initial.getDerivedPrinter() + print "==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\"" + assert(derivedAsBase.ice_id() == "::Demo::Printer") + + print '\n'\ + "Now we install a factory for the derived class, and try again.\n"\ + "Because we receive the derived object as a base object, we\n"\ + "we need to do a dynamic_cast<> to get from the base to the derived object.\n"\ + "[press enter]" + raw_input() + + self.communicator().addObjectFactory(factory, "::Demo::DerivedPrinter") + + derived = initial.getDerivedPrinter() + print "==> The type ID of the received object is \"" + derived.ice_id() + "\"" + + print '\n'\ + "Let's print the message contained in the derived object, and\n"\ + "call the operation printUppercase() on the derived object\n"\ + "locally.\n"\ + "[press enter]" + raw_input() + + print "==> " + derived.derivedMessage + print "==>", + derived.printUppercase() + + print '\n'\ + "Finally, we try the same again, but instead of returning the\n"\ + "derived object, we throw an exception containing the derived\n"\ + "object.\n"\ + "[press enter]" + raw_input() + + try: + initial.throwDerivedPrinter() + print args[0] + "Did not get the expected DerivedPrinterException!" + sys.exit(false) + except Demo.DerivedPrinterException, ex: + derived = ex.derived + assert(derived) + + print "==> " + derived.derivedMessage + print "==>", + derived.printUppercase() + + print '\n'\ + "That's it for this demo. Have fun with Ice!" + + initial.shutdown() + + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/value/Server.py b/py/demo/Ice/value/Server.py index 9a7fd7e7b14..bc1aa5557e4 100644 --- a/py/demo/Ice/value/Server.py +++ b/py/demo/Ice/value/Server.py @@ -46,11 +46,11 @@ class InitialI(Demo.Initial): class Server(Ice.Application): def run(self, argv): - adapter = self.communicator().createObjectAdapter("Value") - adapter.add(InitialI(adapter), self.communicator().stringToIdentity("initial")) - adapter.activate() - self.communicator().waitForShutdown() - return True + adapter = self.communicator().createObjectAdapter("Value") + adapter.add(InitialI(adapter), self.communicator().stringToIdentity("initial")) + adapter.activate() + self.communicator().waitForShutdown() + return True app = Server() sys.exit(app.main(sys.argv, "config.server")) diff --git a/py/demo/IceGrid/allocate/Client.py b/py/demo/IceGrid/allocate/Client.py index 49e89489524..8614d638c5f 100644 --- a/py/demo/IceGrid/allocate/Client.py +++ b/py/demo/IceGrid/allocate/Client.py @@ -36,11 +36,11 @@ class SessionKeepAliveThread(threading.Thread): while not self._terminated: self._cond.wait(self._timeout) if self._terminated: - break + break try: self._session.keepAlive() except Ice.LocalException, ex: - break + break finally: self._cond.release() @@ -54,70 +54,70 @@ class SessionKeepAliveThread(threading.Thread): class Client(Ice.Application): def run(self, args): - status = True - registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) - if registry == None: - print self.appName() + ": could not contact registry" - return False + status = True + registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) + if registry == None: + print self.appName() + ": could not contact registry" + return False - while True: - print "This demo accepts any user-id / password combination." - id = raw_input("user id: ").strip() - pw = raw_input("password: ").strip() - try: - session = registry.createSession(id, pw) - break - except IceGrid.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason + while True: + print "This demo accepts any user-id / password combination." + id = raw_input("user id: ").strip() + pw = raw_input("password: ").strip() + try: + session = registry.createSession(id, pw) + break + except IceGrid.PermissionDeniedException, ex: + print "permission denied:\n" + ex.reason - keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) - keepAlive.start() + keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) + keepAlive.start() - try: - try: - hello = Demo.HelloPrx.checkedCast(\ - session.allocateObjectById(self.communicator().stringToIdentity("hello"))) - except IceGrid.ObjectNotRegisteredException: - hello = Demo.HelloPrx.checkedCast(session.allocateObjectByType("::Demo::Hello")) + try: + try: + hello = Demo.HelloPrx.checkedCast(\ + session.allocateObjectById(self.communicator().stringToIdentity("hello"))) + except IceGrid.ObjectNotRegisteredException: + hello = Demo.HelloPrx.checkedCast(session.allocateObjectByType("::Demo::Hello")) - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 't': - hello.sayHello() - elif c == 's': - hello.shutdown() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break - except KeyboardInterrupt: - break - except IceGrid.AllocationException, ex: + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + hello.sayHello() + elif c == 's': + hello.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except KeyboardInterrupt: + break + except IceGrid.AllocationException, ex: print self.appName() + ": could not allocate object: " + ex.reason status = False - except: + except: print self.appName() + ": could not allocate object: " + str(sys.exc_info()[0]) status = False - # - # Destroy the keepAlive thread and the sesion object otherwise - # the session will be kept allocated until the timeout occurs. - # Destroying the session will release all allocated objects. - # - keepAlive.terminate() - keepAlive.join() - session.destroy(); + # + # Destroy the keepAlive thread and the sesion object otherwise + # the session will be kept allocated until the timeout occurs. + # Destroying the session will release all allocated objects. + # + keepAlive.terminate() + keepAlive.join() + session.destroy(); - return status + return status app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/IceGrid/allocate/Server.py b/py/demo/IceGrid/allocate/Server.py index 973e3cb415e..bf2dc212601 100644 --- a/py/demo/IceGrid/allocate/Server.py +++ b/py/demo/IceGrid/allocate/Server.py @@ -27,12 +27,12 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): properties = self.communicator().getProperties() - adapter = self.communicator().createObjectAdapter("Hello") - id = self.communicator().stringToIdentity(properties.getProperty("Identity")) - adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) - adapter.activate() - self.communicator().waitForShutdown() - return 0 + adapter = self.communicator().createObjectAdapter("Hello") + id = self.communicator().stringToIdentity(properties.getProperty("Identity")) + adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) + adapter.activate() + self.communicator().waitForShutdown() + return 0 app = Server() sys.exit(app.main(sys.argv)) diff --git a/py/demo/IceGrid/sessionActivation/Client.py b/py/demo/IceGrid/sessionActivation/Client.py index 78cb1ee6130..3710280f11d 100644 --- a/py/demo/IceGrid/sessionActivation/Client.py +++ b/py/demo/IceGrid/sessionActivation/Client.py @@ -35,11 +35,11 @@ class SessionKeepAliveThread(threading.Thread): while not self._terminated: self._cond.wait(self._timeout) if self._terminated: - break + break try: self._session.keepAlive() except Ice.LocalException, ex: - break + break finally: self._cond.release() @@ -53,67 +53,67 @@ class SessionKeepAliveThread(threading.Thread): class Client(Ice.Application): def run(self, args): - status = True - registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) - if registry == None: - print self.appName() + ": could not contact registry" - return False + status = True + registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) + if registry == None: + print self.appName() + ": could not contact registry" + return False - while True: - print "This demo accepts any user-id / password combination." - id = raw_input("user id: ").strip() - pw = raw_input("password: ").strip() - try: - session = registry.createSession(id, pw) - break - except IceGrid.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason + while True: + print "This demo accepts any user-id / password combination." + id = raw_input("user id: ").strip() + pw = raw_input("password: ").strip() + try: + session = registry.createSession(id, pw) + break + except IceGrid.PermissionDeniedException, ex: + print "permission denied:\n" + ex.reason - keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) - keepAlive.start() + keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) + keepAlive.start() - try: - hello = Demo.HelloPrx.checkedCast(session.allocateObjectById(self.communicator().stringToIdentity("hello"))) + try: + hello = Demo.HelloPrx.checkedCast(session.allocateObjectById(self.communicator().stringToIdentity("hello"))) - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 't': - hello.sayHello() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break - except KeyboardInterrupt: - break - except IceGrid.AllocationException, ex: - print self.appName() + ": could not allocate object: " + ex.reason - status = False - except IceGrid.ObjectNotRegisteredException: - print self.appName() + ": object not registered with registry" - status = False - except: + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + hello.sayHello() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except KeyboardInterrupt: + break + except IceGrid.AllocationException, ex: + print self.appName() + ": could not allocate object: " + ex.reason + status = False + except IceGrid.ObjectNotRegisteredException: + print self.appName() + ": object not registered with registry" + status = False + except: print self.appName() + ": could not allocate object: " + str(sys.exc_info()[0]) status = False - # - # Destroy the keepAlive thread and the sesion object otherwise - # the session will be kept allocated until the timeout occurs. - # Destroying the session will release all allocated objects. - # - keepAlive.terminate() - keepAlive.join() - session.destroy(); + # + # Destroy the keepAlive thread and the sesion object otherwise + # the session will be kept allocated until the timeout occurs. + # Destroying the session will release all allocated objects. + # + keepAlive.terminate() + keepAlive.join() + session.destroy(); - return status + return status app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/IceGrid/sessionActivation/Server.py b/py/demo/IceGrid/sessionActivation/Server.py index 6e2a8738be6..d4e4008a98d 100644 --- a/py/demo/IceGrid/sessionActivation/Server.py +++ b/py/demo/IceGrid/sessionActivation/Server.py @@ -23,12 +23,12 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): properties = self.communicator().getProperties() - adapter = self.communicator().createObjectAdapter("Hello") - id = self.communicator().stringToIdentity(properties.getProperty("Identity")) - adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) - adapter.activate() - self.communicator().waitForShutdown() - return 0 + adapter = self.communicator().createObjectAdapter("Hello") + id = self.communicator().stringToIdentity(properties.getProperty("Identity")) + adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) + adapter.activate() + self.communicator().waitForShutdown() + return 0 app = Server() sys.exit(app.main(sys.argv)) diff --git a/py/demo/IceGrid/simple/Client.py b/py/demo/IceGrid/simple/Client.py index c0dad5d49b4..7651802c658 100644 --- a/py/demo/IceGrid/simple/Client.py +++ b/py/demo/IceGrid/simple/Client.py @@ -26,39 +26,39 @@ x: exit class Client(Ice.Application): def run(self, args): hello = None - try: - hello = Demo.HelloPrx.checkedCast(self.communicator().stringToProxy("hello")) - except Ice.NotRegisteredException: - query = IceGrid.QueryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Query")) - hello = Demo.HelloPrx.checkedCast(query.findObjectByType("::Demo::Hello")) + try: + hello = Demo.HelloPrx.checkedCast(self.communicator().stringToProxy("hello")) + except Ice.NotRegisteredException: + query = IceGrid.QueryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Query")) + hello = Demo.HelloPrx.checkedCast(query.findObjectByType("::Demo::Hello")) - if not hello: - print self.appName() + ": couldn't find a `::Demo::Hello' object." - return False + if not hello: + print self.appName() + ": couldn't find a `::Demo::Hello' object." + return False - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 't': - hello.sayHello() - elif c == 's': - hello.shutdown() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + hello.sayHello() + elif c == 's': + hello.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break except KeyboardInterrupt: break - return True + return True app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/IceGrid/simple/Server.py b/py/demo/IceGrid/simple/Server.py index 973e3cb415e..bf2dc212601 100644 --- a/py/demo/IceGrid/simple/Server.py +++ b/py/demo/IceGrid/simple/Server.py @@ -27,12 +27,12 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): properties = self.communicator().getProperties() - adapter = self.communicator().createObjectAdapter("Hello") - id = self.communicator().stringToIdentity(properties.getProperty("Identity")) - adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) - adapter.activate() - self.communicator().waitForShutdown() - return 0 + adapter = self.communicator().createObjectAdapter("Hello") + id = self.communicator().stringToIdentity(properties.getProperty("Identity")) + adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) + adapter.activate() + self.communicator().waitForShutdown() + return 0 app = Server() sys.exit(app.main(sys.argv)) diff --git a/py/demo/IceStorm/clock/Publisher.py b/py/demo/IceStorm/clock/Publisher.py index 118aaa585e8..ab0af650156 100644 --- a/py/demo/IceStorm/clock/Publisher.py +++ b/py/demo/IceStorm/clock/Publisher.py @@ -15,46 +15,46 @@ import Demo class Publisher(Ice.Application): def run(self, args): - properties = self.communicator().getProperties() - - manager = IceStorm.TopicManagerPrx.checkedCast(\ - self.communicator().propertyToProxy('IceStorm.TopicManager.Proxy')) - if not manager: - print args[0] + ": invalid proxy" - return False - - topicName = "time" - if len(args) != 1: - topicName = args[1] - - # - # Retrieve the topic. - # - try: - topic = manager.retrieve(topicName) - except IceStorm.NoSuchTopic, e: - try: - topic = manager.create(topicName) - except IceStorm.TopicExists, ex: - print self.appName() + ": temporay error. try again" - return False - - # - # Get the topic's publisher object, the Clock type, and create a - # oneway Clock proxy (for efficiency reasons). - # - clock = Demo.ClockPrx.uncheckedCast(topic.getPublisher().ice_oneway()) - - print "publishing tick events. Press ^C to terminate the application." - try: - while 1: - clock.tick(time.strftime("%m/%d/%Y %H:%M:%S")) - time.sleep(1) - except Ice.CommunicatorDestroyedException, e: - # Ignore - pass - - return True + properties = self.communicator().getProperties() + + manager = IceStorm.TopicManagerPrx.checkedCast(\ + self.communicator().propertyToProxy('IceStorm.TopicManager.Proxy')) + if not manager: + print args[0] + ": invalid proxy" + return False + + topicName = "time" + if len(args) != 1: + topicName = args[1] + + # + # Retrieve the topic. + # + try: + topic = manager.retrieve(topicName) + except IceStorm.NoSuchTopic, e: + try: + topic = manager.create(topicName) + except IceStorm.TopicExists, ex: + print self.appName() + ": temporay error. try again" + return False + + # + # Get the topic's publisher object, the Clock type, and create a + # oneway Clock proxy (for efficiency reasons). + # + clock = Demo.ClockPrx.uncheckedCast(topic.getPublisher().ice_oneway()) + + print "publishing tick events. Press ^C to terminate the application." + try: + while 1: + clock.tick(time.strftime("%m/%d/%Y %H:%M:%S")) + time.sleep(1) + except Ice.CommunicatorDestroyedException, e: + # Ignore + pass + + return True app = Publisher() sys.exit(app.main(sys.argv, "config.pub")) diff --git a/py/demo/IceStorm/clock/Subscriber.py b/py/demo/IceStorm/clock/Subscriber.py index 9dcacf2b0ff..17fb94ad222 100644 --- a/py/demo/IceStorm/clock/Subscriber.py +++ b/py/demo/IceStorm/clock/Subscriber.py @@ -22,7 +22,7 @@ class Subscriber(Ice.Application): properties = self.communicator().getProperties() manager = IceStorm.TopicManagerPrx.checkedCast(\ - self.communicator().propertyToProxy('IceStorm.TopicManager.Proxy')) + self.communicator().propertyToProxy('IceStorm.TopicManager.Proxy')) if not manager: print args[0] + ": invalid proxy" return False @@ -43,18 +43,18 @@ class Subscriber(Ice.Application): print self.appName() + ": temporay error. try again" return False - adapter = self.communicator().createObjectAdapter("Clock.Subscriber") + adapter = self.communicator().createObjectAdapter("Clock.Subscriber") - # - # Add a Servant for the Ice Object. - # - subscriber = adapter.addWithUUID(ClockI()); + # + # Add a Servant for the Ice Object. + # + subscriber = adapter.addWithUUID(ClockI()); - # - # This demo requires no quality of service, so it will use - # the defaults. - # - qos = {} + # + # This demo requires no quality of service, so it will use + # the defaults. + # + qos = {} topic.subscribe(qos, subscriber) adapter.activate() @@ -66,8 +66,8 @@ class Subscriber(Ice.Application): # Unsubscribe all subscribed objects. # topic.unsubscribe(subscriber) - - return True + + return True app = Subscriber() sys.exit(app.main(sys.argv, "config.sub")) diff --git a/py/makebindist.py b/py/makebindist.py index 13f8301280d..ede9be3dca0 100755 --- a/py/makebindist.py +++ b/py/makebindist.py @@ -47,7 +47,7 @@ def copyLibrary(src, dst, name, python): soVer = name + '.' + version + ".dylib" soInt = name + '.' + intVer + ".dylib" soLib = name + ".dylib" - else: + else: soVer = soBase + '.' + version soInt = soBase + '.' + intVer @@ -241,21 +241,21 @@ if symlinks: copyLibrary(topdir + "/lib", libdir, so, 1) else: for lib in iceLibraries: - if platform == "aix": - shutil.copyfile(icehome + "/lib/" + lib + ".a", libdir + "/" + lib + ".a") - else: - shutil.copyfile(icehome + "/lib/" + lib, libdir + "/" + lib) + if platform == "aix": + shutil.copyfile(icehome + "/lib/" + lib + ".a", libdir + "/" + lib + ".a") + else: + shutil.copyfile(icehome + "/lib/" + lib, libdir + "/" + lib) for lib in pyLibraries: - if platform == "aix": - shutil.copyfile("lib/" + lib + ".a", libdir + "/" + lib + ".a") - else: - shutil.copyfile(topdir + "/lib", libdir + "/" + lib) + if platform == "aix": + shutil.copyfile("lib/" + lib + ".a", libdir + "/" + lib + ".a") + else: + shutil.copyfile(topdir + "/lib", libdir + "/" + lib) if strip: stripOpts="" if platform == "macosx": - stripOpts="-x" + stripOpts="-x" for x in iceExecutables: os.system("strip " + stripOpts + " " + bindir + "/" + x) @@ -263,9 +263,9 @@ if strip: for x in iceLibraries: if platform == "hpux": soLib = x + ".sl" - elif platform == "macosx": + elif platform == "macosx": soLib = x + ".dylib" - elif platform == "aix": + elif platform == "aix": soLib = x + ".a" else: soLib = x + ".so" @@ -273,7 +273,7 @@ if strip: for x in pyLibraries: if platform == "hpux": soLib = x + ".sl" - elif platform == "aix": + elif platform == "aix": soLib = x + ".a" else: soLib = x + ".so" diff --git a/py/makedist.py b/py/makedist.py index 73350ec889c..a6675991a81 100755 --- a/py/makedist.py +++ b/py/makedist.py @@ -122,7 +122,7 @@ for x in slicedirs: shutil.copytree(os.path.join("ice", "slice", x), os.path.join("icepy", "slice", x), 1) for x in glob.glob(os.path.join("ice", "config", "Make.rules.*")): if not os.path.exists(os.path.join("icepy", "config", os.path.basename(x))): - shutil.copyfile(x, os.path.join("icepy", "config", os.path.basename(x))) + shutil.copyfile(x, os.path.join("icepy", "config", os.path.basename(x))) # # Remove files. @@ -211,13 +211,13 @@ if not skipTranslator: os.environ["PATH"] = os.path.join(cwd, "ice", "bin") + ":" + os.getenv("PATH", "") if isHpUx(): - os.environ["SHLIB_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("SHLIB_PATH", "") + os.environ["SHLIB_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("SHLIB_PATH", "") elif isDarwin(): - os.environ["DYLD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("DYLD_LIBRRARY_PATH", "") + os.environ["DYLD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("DYLD_LIBRRARY_PATH", "") elif isAIX(): - os.environ["LIBPATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LIBPATH", "") + os.environ["LIBPATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LIBPATH", "") else: - os.environ["LD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LD_LIBRARY_PATH", "") + os.environ["LD_LIBRARY_PATH"] = os.path.join(cwd, "ice", "lib") + ":" + os.getenv("LD_LIBRARY_PATH", "") os.environ["ICE_HOME"] = os.path.join(cwd, "ice") @@ -243,14 +243,14 @@ versionMinor = "" versionPatch = "" for l in config.readlines(): if l.startswith("VERSION_MAJOR"): - n, v = l.split('=') - versionMajor = v.strip() + n, v = l.split('=') + versionMajor = v.strip() elif l.startswith("VERSION_MINOR"): - n, v = l.split('=') - versionMinor = v.strip() + n, v = l.split('=') + versionMinor = v.strip() elif l.startswith("VERSION_PATCH"): - n, v = l.split('=') - versionPatch = v.strip() + n, v = l.split('=') + versionPatch = v.strip() config.close() diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index 28e020669c9..29b3d80d0c7 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -105,29 +105,29 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) Ice::InitializationData data; if(initData) { - PyObjectHandle properties = PyObject_GetAttrString(initData, STRCAST("properties")); - PyObjectHandle logger = PyObject_GetAttrString(initData, STRCAST("logger")); - PyObjectHandle threadHook = PyObject_GetAttrString(initData, STRCAST("threadHook")); + PyObjectHandle properties = PyObject_GetAttrString(initData, STRCAST("properties")); + PyObjectHandle logger = PyObject_GetAttrString(initData, STRCAST("logger")); + PyObjectHandle threadHook = PyObject_GetAttrString(initData, STRCAST("threadHook")); - if(properties.get() && properties.get() != Py_None) - { - // - // Get the properties implementation. - // - PyObjectHandle impl = PyObject_GetAttrString(properties.get(), STRCAST("_impl")); - assert(impl.get() != NULL); - data.properties = getProperties(impl.get()); - } + if(properties.get() && properties.get() != Py_None) + { + // + // Get the properties implementation. + // + PyObjectHandle impl = PyObject_GetAttrString(properties.get(), STRCAST("_impl")); + assert(impl.get() != NULL); + data.properties = getProperties(impl.get()); + } - if(logger.get() && logger.get() != Py_None) - { - data.logger = new LoggerWrapper(logger.get()); - } + if(logger.get() && logger.get() != Py_None) + { + data.logger = new LoggerWrapper(logger.get()); + } - if(threadHook.get() && threadHook.get() != Py_None) - { - data.threadHook = new ThreadNotificationWrapper(threadHook.get()); - } + if(threadHook.get() && threadHook.get() != Py_None) + { + data.threadHook = new ThreadNotificationWrapper(threadHook.get()); + } } @@ -149,32 +149,32 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) int i = 0; for(Ice::StringSeq::const_iterator s = seq.begin(); s != seq.end(); ++s, ++i) { - argv[i] = strdup(s->c_str()); + argv[i] = strdup(s->c_str()); } argv[argc] = 0; Ice::CommunicatorPtr communicator; try { - if(hasArgs) - { - communicator = Ice::initialize(argc, argv, data); - } - else - { - communicator = Ice::initialize(data); - } + if(hasArgs) + { + communicator = Ice::initialize(argc, argv, data); + } + else + { + communicator = Ice::initialize(data); + } } catch(const Ice::Exception& ex) { - for(i = 0; i < argc + 1; ++i) - { - free(argv[i]); - } - delete[] argv; + for(i = 0; i < argc + 1; ++i) + { + free(argv[i]); + } + delete[] argv; - setPythonException(ex); - return -1; + setPythonException(ex); + return -1; } // @@ -182,18 +182,18 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) // if(arglist) { - PyList_SetSlice(arglist, 0, PyList_Size(arglist), NULL); // Clear the list. + PyList_SetSlice(arglist, 0, PyList_Size(arglist), NULL); // Clear the list. - for(i = 0; i < argc; ++i) - { - PyObjectHandle str = Py_BuildValue(STRCAST("s"), argv[i]); - PyList_Append(arglist, str.get()); - } + for(i = 0; i < argc; ++i) + { + PyObjectHandle str = Py_BuildValue(STRCAST("s"), argv[i]); + PyList_Append(arglist, str.get()); + } } for(i = 0; i < argc + 1; ++i) { - free(argv[i]); + free(argv[i]); } delete[] argv; @@ -204,7 +204,7 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) CommunicatorMap::iterator p = _communicatorMap.find(communicator); if(p != _communicatorMap.end()) { - _communicatorMap.erase(p); + _communicatorMap.erase(p); } _communicatorMap.insert(CommunicatorMap::value_type(communicator, (PyObject*)self)); @@ -223,7 +223,7 @@ communicatorDealloc(CommunicatorObject* self) // if(p != _communicatorMap.end()) { - _communicatorMap.erase(p); + _communicatorMap.erase(p); } if(self->shutdownThread) @@ -246,7 +246,7 @@ communicatorDestroy(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->destroy(); } catch(const Ice::Exception& ex) @@ -268,7 +268,7 @@ communicatorShutdown(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->shutdown(); } catch(const Ice::Exception& ex) @@ -324,20 +324,20 @@ communicatorWaitForShutdown(CommunicatorObject* self, PyObject* args) t->start(); } - while(!self->shutdown) - { - bool done; - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. - done = (*self->shutdownMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); - } - - if(!done) - { - Py_INCREF(Py_False); - return Py_False; - } - } + while(!self->shutdown) + { + bool done; + { + AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. + done = (*self->shutdownMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); + } + + if(!done) + { + Py_INCREF(Py_False); + return Py_False; + } + } } assert(self->shutdown); @@ -541,7 +541,7 @@ communicatorFlushBatchRequests(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->flushBatchRequests(); } catch(const Ice::Exception& ex) @@ -634,9 +634,9 @@ communicatorGetLogger(CommunicatorObject* self) LoggerWrapperPtr wrapper = LoggerWrapperPtr::dynamicCast(logger); if(wrapper) { - PyObject* obj = wrapper->getObject(); - Py_INCREF(obj); - return obj; + PyObject* obj = wrapper->getObject(); + Py_INCREF(obj); + return obj; } return createLogger(logger); @@ -725,7 +725,7 @@ communicatorSetDefaultContext(CommunicatorObject* self, PyObject* args) Ice::Context ctx; if(!dictionaryToContext(dict, ctx)) { - return NULL; + return NULL; } try @@ -765,12 +765,12 @@ communicatorGetDefaultContext(CommunicatorObject* self) PyObjectHandle dict = PyDict_New(); if(dict.get() == NULL) { - return NULL; + return NULL; } if(!contextToDictionary(ctx, dict.get())) { - return NULL; + return NULL; } return dict.release(); @@ -786,7 +786,7 @@ communicatorGetImplicitContext(CommunicatorObject* self) if(implicitContext == 0) { - return 0; + return 0; } return createImplicitContext(implicitContext); @@ -882,7 +882,7 @@ communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* ar PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("sO"), &name, &proxy)) { - return NULL; + return NULL; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -890,12 +890,12 @@ communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* ar Ice::RouterPrx router; if(PyObject_IsInstance(proxy, routerProxyType)) { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_createObjectAdapterWithRouter requires None or Ice.RouterPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_createObjectAdapterWithRouter requires None or Ice.RouterPrx")); + return NULL; } AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. @@ -947,8 +947,8 @@ communicatorGetDefaultRouter(CommunicatorObject* self) if(!router) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -965,7 +965,7 @@ communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -973,23 +973,23 @@ communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) Ice::RouterPrx router; if(PyObject_IsInstance(proxy, routerProxyType)) { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultRouter requires None or Ice.RouterPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultRouter requires None or Ice.RouterPrx")); + return NULL; } assert(self->communicator); try { - (*self->communicator)->setDefaultRouter(router); + (*self->communicator)->setDefaultRouter(router); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -1016,8 +1016,8 @@ communicatorGetDefaultLocator(CommunicatorObject* self) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1034,7 +1034,7 @@ communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1042,23 +1042,23 @@ communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) Ice::LocatorPrx locator; if(PyObject_IsInstance(proxy, locatorProxyType)) { - locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); + locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultLocator requires None or Ice.LocatorPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultLocator requires None or Ice.LocatorPrx")); + return NULL; } assert(self->communicator); try { - (*self->communicator)->setDefaultLocator(locator); + (*self->communicator)->setDefaultLocator(locator); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -1088,11 +1088,11 @@ static PyMethodDef CommunicatorMethods[] = { STRCAST("createObjectAdapter"), (PyCFunction)communicatorCreateObjectAdapter, METH_VARARGS, PyDoc_STR(STRCAST("createObjectAdapter(name) -> Ice.ObjectAdapter")) }, { STRCAST("createObjectAdapterWithEndpoints"), (PyCFunction)communicatorCreateObjectAdapterWithEndpoints, - METH_VARARGS, - PyDoc_STR(STRCAST("createObjectAdapterWithEndpoints(name, endpoints) -> Ice.ObjectAdapter")) }, + METH_VARARGS, + PyDoc_STR(STRCAST("createObjectAdapterWithEndpoints(name, endpoints) -> Ice.ObjectAdapter")) }, { STRCAST("createObjectAdapterWithRouter"), (PyCFunction)communicatorCreateObjectAdapterWithRouter, - METH_VARARGS, - PyDoc_STR(STRCAST("createObjectAdapterWithRouter(name, router) -> Ice.ObjectAdapter")) }, + METH_VARARGS, + PyDoc_STR(STRCAST("createObjectAdapterWithRouter(name, router) -> Ice.ObjectAdapter")) }, { STRCAST("addObjectFactory"), (PyCFunction)communicatorAddObjectFactory, METH_VARARGS, PyDoc_STR(STRCAST("addObjectFactory(factory, id) -> None")) }, { STRCAST("findObjectFactory"), (PyCFunction)communicatorFindObjectFactory, METH_VARARGS, @@ -1208,8 +1208,8 @@ IcePy::createCommunicator(const Ice::CommunicatorPtr& communicator) CommunicatorMap::iterator p = _communicatorMap.find(communicator); if(p != _communicatorMap.end()) { - Py_INCREF(p->second); - return p->second; + Py_INCREF(p->second); + return p->second; } CommunicatorObject* obj = communicatorNew(NULL); diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp index 335cd75929c..3ee67e29878 100644 --- a/py/modules/IcePy/Connection.cpp +++ b/py/modules/IcePy/Connection.cpp @@ -152,7 +152,7 @@ connectionSetAdapter(ConnectionObject* self, PyObject* args) PyObject* adapter; if(!PyArg_ParseTuple(args, STRCAST("O!"), adapterType, &adapter)) { - return NULL; + return NULL; } Ice::ObjectAdapterPtr oa = unwrapObjectAdapter(adapter); @@ -162,12 +162,12 @@ connectionSetAdapter(ConnectionObject* self, PyObject* args) assert(self->communicator); try { - (*self->connection)->setAdapter(oa); + (*self->connection)->setAdapter(oa); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -186,12 +186,12 @@ connectionGetAdapter(ConnectionObject* self) assert(self->communicator); try { - adapter = (*self->connection)->getAdapter(); + adapter = (*self->connection)->getAdapter(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return wrapObjectAdapter(adapter); diff --git a/py/modules/IcePy/Current.cpp b/py/modules/IcePy/Current.cpp index ed96092a761..8336c8147ea 100644 --- a/py/modules/IcePy/Current.cpp +++ b/py/modules/IcePy/Current.cpp @@ -112,7 +112,7 @@ currentGetter(CurrentObject* self, void* closure) { if(self->adapter == NULL) { - self->adapter = wrapObjectAdapter(self->current->adapter); + self->adapter = wrapObjectAdapter(self->current->adapter); if(self->adapter == NULL) { return NULL; @@ -124,14 +124,14 @@ currentGetter(CurrentObject* self, void* closure) } case CURRENT_CONNECTION: { - if(self->con == NULL) - { - self->con = createConnection(self->current->con, self->current->adapter->getCommunicator()); - if(self->con == NULL) - { - return NULL; - } - } + if(self->con == NULL) + { + self->con = createConnection(self->current->con, self->current->adapter->getCommunicator()); + if(self->con == NULL) + { + return NULL; + } + } Py_INCREF(self->con); result = self->con; break; diff --git a/py/modules/IcePy/ImplicitContext.cpp b/py/modules/IcePy/ImplicitContext.cpp index 4f1900eb9a1..598f88d5395 100644 --- a/py/modules/IcePy/ImplicitContext.cpp +++ b/py/modules/IcePy/ImplicitContext.cpp @@ -88,12 +88,12 @@ implicitContextGetContext(ImplicitContextObject* self) PyObjectHandle dict = PyDict_New(); if(dict.get() == NULL) { - return NULL; + return NULL; } if(!contextToDictionary(ctx, dict.get())) { - return NULL; + return NULL; } return dict.release(); @@ -115,7 +115,7 @@ implicitContextSetContext(ImplicitContextObject* self, PyObject* args) Ice::Context ctx; if(!dictionaryToContext(dict, ctx)) { - return NULL; + return NULL; } (*self->implicitContext)->setContext(ctx); @@ -139,11 +139,11 @@ implicitContextGet(ImplicitContextObject* self, PyObject* args) string val; try { - val = (*self->implicitContext)->get(key); + val = (*self->implicitContext)->get(key); } catch(const Ice::Exception& ex) { - setPythonException(ex); + setPythonException(ex); return NULL; } return PyString_FromString(const_cast<char*>(val.c_str())); @@ -200,11 +200,11 @@ implicitContextRemove(ImplicitContextObject* self, PyObject* args) try { - (*self->implicitContext)->remove(key); + (*self->implicitContext)->remove(key); } catch(const Ice::Exception& ex) { - setPythonException(ex); + setPythonException(ex); return NULL; } diff --git a/py/modules/IcePy/Logger.cpp b/py/modules/IcePy/Logger.cpp index c8da57220ea..2cde5545ac0 100644 --- a/py/modules/IcePy/Logger.cpp +++ b/py/modules/IcePy/Logger.cpp @@ -53,7 +53,7 @@ IcePy::LoggerWrapper::trace(const string& category, const string& message) AdoptThread adoptThread; // Ensure the current thread is able to call into Python. PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), STRCAST("trace"), STRCAST("ss"), category.c_str(), - message.c_str()); + message.c_str()); if(tmp.get() == NULL) { throwPythonException(); diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp index be4d95d0abd..25def843246 100644 --- a/py/modules/IcePy/ObjectAdapter.cpp +++ b/py/modules/IcePy/ObjectAdapter.cpp @@ -175,7 +175,7 @@ IcePy::ServantWrapper::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& cb, } } - __checkMode(op->mode(), current.mode); + __checkMode(op->mode(), current.mode); op->dispatch(_servant, cb, inParams, current); } @@ -281,7 +281,7 @@ IcePy::ServantLocatorWrapper::finished(const Ice::Current&, const Ice::ObjectPtr PyObjectHandle servantObj = wrapper->getObject(); PyObjectHandle res = PyObject_CallMethod(_locator, STRCAST("finished"), STRCAST("OOO"), c->current, - servantObj.get(), c->cookie); + servantObj.get(), c->cookie); if(PyErr_Occurred()) { throwPythonException(); @@ -594,21 +594,21 @@ adapterWaitForDeactivate(ObjectAdapterObject* self, PyObject* args) self->deactivateThread = new AdapterInvokeThreadPtr(t); t->start(); } - - while(!self->deactivated) - { - bool done; - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. - done = (*self->deactivateMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); - } - - if(!done) - { - Py_INCREF(Py_False); - return Py_False; - } - } + + while(!self->deactivated) + { + bool done; + { + AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. + done = (*self->deactivateMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); + } + + if(!done) + { + Py_INCREF(Py_False); + return Py_False; + } + } } assert(self->deactivated); @@ -868,8 +868,8 @@ adapterRemove(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -911,8 +911,8 @@ adapterRemoveFacet(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1004,8 +1004,8 @@ adapterFind(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1047,8 +1047,8 @@ adapterFindFacet(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1136,8 +1136,8 @@ adapterFindByProxy(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1202,8 +1202,8 @@ adapterFindServantLocator(ObjectAdapterObject* self, PyObject* args) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantLocatorWrapperPtr wrapper = ServantLocatorWrapperPtr::dynamicCast(locator); @@ -1541,14 +1541,14 @@ IcePy::wrapObjectAdapter(const Ice::ObjectAdapterPtr& adapter) PyObjectHandle adapterI = createObjectAdapter(adapter); if(adapterI.get() == NULL) { - return NULL; + return NULL; } PyObject* wrapperType = lookupType("Ice.ObjectAdapterI"); assert(wrapperType != NULL); PyObjectHandle args = PyTuple_New(1); if(args.get() == NULL) { - return NULL; + return NULL; } PyTuple_SET_ITEM(args.get(), 0, adapterI.release()); return PyObject_Call(wrapperType, args.get(), NULL); diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 15e6d1cbb55..6404dac4e56 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -158,8 +158,8 @@ operationInit(OperationObject* self, PyObject* args, PyObject* /*kwds*/) PyObject* returnType; PyObject* exceptions; if(!PyArg_ParseTuple(args, STRCAST("sO!O!iO!O!O!OO!"), &name, modeType, &mode, modeType, &sendMode, &amd, - &PyTuple_Type, &meta, &PyTuple_Type, &inParams, &PyTuple_Type, &outParams, &returnType, - &PyTuple_Type, &exceptions)) + &PyTuple_Type, &meta, &PyTuple_Type, &inParams, &PyTuple_Type, &outParams, &returnType, + &PyTuple_Type, &exceptions)) { return -1; } @@ -323,8 +323,8 @@ amdCallbackIceException(AMDCallbackObject* self, PyObject* args) try { assert(self->op); - PyException pye(ex); // No traceback information available. - (*self->op)->sendException(*self->cb, pye, *self->communicator); + PyException pye(ex); // No traceback information available. + (*self->op)->sendException(*self->cb, pye, *self->communicator); } catch(const Ice::Exception& ex) { @@ -400,7 +400,7 @@ IcePy::AMICallback::ice_exception(const Ice::Exception& ex) // OperationI implementation. // IcePy::OperationI::OperationI(const char* name, PyObject* mode, PyObject* sendMode, int amd, PyObject* meta, - PyObject* inParams, PyObject* outParams, PyObject* returnType, PyObject* exceptions) + PyObject* inParams, PyObject* outParams, PyObject* returnType, PyObject* exceptions) { _name = name; @@ -491,13 +491,13 @@ IcePy::OperationI::invoke(const Ice::ObjectPrx& proxy, PyObject* args, PyObject* if(!_deprecateMessage.empty()) { - PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); - _deprecateMessage.clear(); // Only show the warning once. + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + _deprecateMessage.clear(); // Only show the warning once. } try { - checkTwowayOnly(proxy); + checkTwowayOnly(proxy); // // Invoke the operation. @@ -545,7 +545,7 @@ IcePy::OperationI::invoke(const Ice::ObjectPrx& proxy, PyObject* args, PyObject* // // Set the Python exception. // - setPythonException(ex.get()); + setPythonException(ex.get()); return NULL; } else if(_outParams.size() > 0 || _returnType) @@ -603,14 +603,14 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, if(!_deprecateMessage.empty()) { - PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); - _deprecateMessage.clear(); // Only show the warning once. + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + _deprecateMessage.clear(); // Only show the warning once. } Ice::AMI_Object_ice_invokePtr cb = new AMICallback(this, communicator, callback); try { - checkTwowayOnly(proxy); + checkTwowayOnly(proxy); // // Invoke the operation asynchronously. @@ -641,7 +641,7 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, } catch(const Ice::Exception& ex) { - cb->ice_exception(ex); + cb->ice_exception(ex); } Py_INCREF(Py_None); @@ -653,11 +653,11 @@ IcePy::OperationI::deprecate(const string& msg) { if(!msg.empty()) { - _deprecateMessage = msg; + _deprecateMessage = msg; } else { - _deprecateMessage = "operation " + _name + " is deprecated"; + _deprecateMessage = "operation " + _name + " is deprecated"; } } @@ -699,7 +699,7 @@ IcePy::OperationI::dispatch(PyObject* servant, const Ice::AMD_Object_ice_invokeP Py_ssize_t i = start; for(ParamInfoList::iterator p = _inParams.begin(); p != _inParams.end(); ++p, ++i) { - void* closure = reinterpret_cast<void*>(i); + void* closure = reinterpret_cast<void*>(i); (*p)->type->unmarshal(is, *p, args.get(), closure, &(*p)->metaData); } if(_sendsClasses) @@ -766,8 +766,8 @@ IcePy::OperationI::dispatch(PyObject* servant, const Ice::AMD_Object_ice_invokeP // if(PyErr_Occurred()) { - PyException ex; // Retrieve it before another Python API call clears it. - sendException(cb, ex, communicator); + PyException ex; // Retrieve it before another Python API call clears it. + sendException(cb, ex, communicator); return; } @@ -785,26 +785,26 @@ IcePy::OperationI::responseAsync(PyObject* callback, bool ok, const vector<Ice:: { if(ok) { - // - // Unmarshal the results. - // - PyObjectHandle args; - try - { - args = unmarshalResults(results, communicator); - if(args.get() == NULL) - { - assert(PyErr_Occurred()); - PyErr_Print(); - return; - } - } - catch(const Ice::Exception& ex) - { - PyObjectHandle h = convertException(ex); - responseAsyncException(callback, h.get()); - return; - } + // + // Unmarshal the results. + // + PyObjectHandle args; + try + { + args = unmarshalResults(results, communicator); + if(args.get() == NULL) + { + assert(PyErr_Occurred()); + PyErr_Print(); + return; + } + } + catch(const Ice::Exception& ex) + { + PyObjectHandle h = convertException(ex); + responseAsyncException(callback, h.get()); + return; + } PyObjectHandle method = PyObject_GetAttrString(callback, STRCAST("ice_response")); if(method.get() == NULL) @@ -968,14 +968,14 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce // However, we have no way to pass this exception to the interpreter, // so we act on it directly. // - if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit)) + if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit)) { handleSystemExit(ex.ex.get()); // Does not return. } PyObject* userExceptionType = lookupType("Ice.UserException"); - if(PyObject_IsInstance(ex.ex.get(), userExceptionType)) + if(PyObject_IsInstance(ex.ex.get(), userExceptionType)) { // // Get the exception's type and verify that it is legal to be thrown from this operation. @@ -986,7 +986,7 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce assert(info); if(!validateException(ex.ex.get())) { - ex.raise(); // Raises UnknownUserException. + ex.raise(); // Raises UnknownUserException. } else { @@ -1006,7 +1006,7 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce } else { - ex.raise(); + ex.raise(); } } catch(const AbortMarshaling&) @@ -1030,7 +1030,7 @@ IcePy::OperationI::prepareRequest(const Ice::CommunicatorPtr& communicator, PyOb { string fixedName = fixIdent(_name); PyErr_Format(PyExc_RuntimeError, STRCAST("%s expects %d in parameters"), fixedName.c_str(), - static_cast<int>(paramCount)); + static_cast<int>(paramCount)); return false; } @@ -1103,7 +1103,7 @@ IcePy::OperationI::unmarshalResults(const vector<Ice::Byte>& bytes, const Ice::C Ice::InputStreamPtr is = Ice::createInputStream(communicator, bytes); for(ParamInfoList::iterator p = _outParams.begin(); p != _outParams.end(); ++p, ++i) { - void* closure = reinterpret_cast<void*>(i); + void* closure = reinterpret_cast<void*>(i); (*p)->type->unmarshal(is, *p, results.get(), closure, &(*p)->metaData); } @@ -1146,8 +1146,8 @@ IcePy::OperationI::unmarshalException(const vector<Ice::Byte>& bytes, const Ice: } else { - PyException pye(ex.get()); // No traceback information available. - pye.raise(); + PyException pye(ex.get()); // No traceback information available. + pye.raise(); } } else @@ -1185,9 +1185,9 @@ IcePy::OperationI::checkTwowayOnly(const Ice::ObjectPrx& proxy) const { if((_returnType != 0 || !_outParams.empty()) && !proxy->ice_isTwoway()) { - Ice::TwowayOnlyException ex(__FILE__, __LINE__); - ex.operation = _name; - throw ex; + Ice::TwowayOnlyException ex(__FILE__, __LINE__); + ex.operation = _name; + throw ex; } } @@ -1198,32 +1198,32 @@ IcePy::OperationI::convertParams(PyObject* p, ParamInfoList& params, bool& usesC int sz = PyTuple_GET_SIZE(p); for(int i = 0; i < sz; ++i) { - PyObject* item = PyTuple_GET_ITEM(p, i); - assert(PyTuple_Check(item)); - assert(PyTuple_GET_SIZE(item) == 2); + PyObject* item = PyTuple_GET_ITEM(p, i); + assert(PyTuple_Check(item)); + assert(PyTuple_GET_SIZE(item) == 2); - ParamInfoPtr param = new ParamInfo; + ParamInfoPtr param = new ParamInfo; - // - // metaData - // - PyObject* meta = PyTuple_GET_ITEM(item, 0); - assert(PyTuple_Check(meta)); + // + // metaData + // + PyObject* meta = PyTuple_GET_ITEM(item, 0); + assert(PyTuple_Check(meta)); #ifndef NDEBUG - bool b = + bool b = #endif - tupleToStringSeq(meta, param->metaData); - assert(b); - - // - // type - // - param->type = getType(PyTuple_GET_ITEM(item, 1)); - params.push_back(param); - if(!usesClasses) - { - usesClasses = param->type->usesClasses(); - } + tupleToStringSeq(meta, param->metaData); + assert(b); + + // + // type + // + param->type = getType(PyTuple_GET_ITEM(item, 1)); + params.push_back(param); + if(!usesClasses) + { + usesClasses = param->type->usesClasses(); + } } } diff --git a/py/modules/IcePy/Properties.cpp b/py/modules/IcePy/Properties.cpp index 040b6e77a43..b6097394264 100644 --- a/py/modules/IcePy/Properties.cpp +++ b/py/modules/IcePy/Properties.cpp @@ -61,35 +61,35 @@ propertiesInit(PropertiesObject* self, PyObject* args, PyObject* /*kwds*/) Ice::StringSeq seq; if(arglist) { - if(PyObject_IsInstance(arglist, (PyObject*)&PyList_Type)) - { - if(!listToStringSeq(arglist, seq)) - { - return -1; - } - } - else if(arglist != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("args must be None or a list")); - return -1; - } + if(PyObject_IsInstance(arglist, (PyObject*)&PyList_Type)) + { + if(!listToStringSeq(arglist, seq)) + { + return -1; + } + } + else if(arglist != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("args must be None or a list")); + return -1; + } } Ice::PropertiesPtr defaults; if(defaultsObj) { - PyObject* propType = lookupType("Ice.PropertiesI"); - assert(propType != NULL); - if(PyObject_IsInstance(defaultsObj, propType)) - { - PyObjectHandle impl = PyObject_GetAttrString(defaultsObj, STRCAST("_impl")); - defaults = getProperties(impl.get()); - } - else if(defaultsObj != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("defaults must be None or a Ice.Properties")); - return -1; - } + PyObject* propType = lookupType("Ice.PropertiesI"); + assert(propType != NULL); + if(PyObject_IsInstance(defaultsObj, propType)) + { + PyObjectHandle impl = PyObject_GetAttrString(defaultsObj, STRCAST("_impl")); + defaults = getProperties(impl.get()); + } + else if(defaultsObj != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("defaults must be None or a Ice.Properties")); + return -1; + } } diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp index 2041e9cee9b..8b2263dbb33 100644 --- a/py/modules/IcePy/Proxy.cpp +++ b/py/modules/IcePy/Proxy.cpp @@ -222,19 +222,19 @@ proxyIceIsA(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - b = (*self->proxy)->ice_isA(type, context); - } - else - { - b = (*self->proxy)->ice_isA(type); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + b = (*self->proxy)->ice_isA(type, context); + } + else + { + b = (*self->proxy)->ice_isA(type); + } } catch(const Ice::Exception& ex) { @@ -264,19 +264,19 @@ proxyIcePing(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - (*self->proxy)->ice_ping(context); - } - else - { - (*self->proxy)->ice_ping(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + (*self->proxy)->ice_ping(context); + } + else + { + (*self->proxy)->ice_ping(); + } } catch(const Ice::Exception& ex) { @@ -306,19 +306,19 @@ proxyIceIds(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - ids = (*self->proxy)->ice_ids(context); - } - else - { - ids = (*self->proxy)->ice_ids(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + ids = (*self->proxy)->ice_ids(context); + } + else + { + ids = (*self->proxy)->ice_ids(); + } } catch(const Ice::Exception& ex) { @@ -353,19 +353,19 @@ proxyIceId(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - id = (*self->proxy)->ice_id(context); - } - else - { - id = (*self->proxy)->ice_id(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + id = (*self->proxy)->ice_id(context); + } + else + { + id = (*self->proxy)->ice_id(); + } } catch(const Ice::Exception& ex) { @@ -608,12 +608,12 @@ proxyIceGetAdapterId(ProxyObject* self) string id; try { - id = (*self->proxy)->ice_getAdapterId(); + id = (*self->proxy)->ice_getAdapterId(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return PyString_FromString(const_cast<char*>(id.c_str())); @@ -668,12 +668,12 @@ proxyIceGetEndpoints(ProxyObject* self) Ice::EndpointSeq endpoints; try { - endpoints = (*self->proxy)->ice_getEndpoints(); + endpoints = (*self->proxy)->ice_getEndpoints(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } int count = static_cast<int>(endpoints.size()); @@ -681,12 +681,12 @@ proxyIceGetEndpoints(ProxyObject* self) int i = 0; for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p, ++i) { - PyObjectHandle endp = (PyObject*)allocateEndpoint(*p); - if(endp.get() == NULL) - { - return NULL; - } - PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference. + PyObjectHandle endp = (PyObject*)allocateEndpoint(*p); + if(endp.get() == NULL) + { + return NULL; + } + PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference. } return result.release(); @@ -706,8 +706,8 @@ proxyIceEndpoints(ProxyObject* self, PyObject* args) if(!PyTuple_Check(endpoints) && !PyList_Check(endpoints)) { - PyErr_Format(PyExc_ValueError, STRCAST("argument must be a tuple or list")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("argument must be a tuple or list")); + return NULL; } assert(self->proxy); @@ -717,20 +717,20 @@ proxyIceEndpoints(ProxyObject* self, PyObject* args) for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* p = PySequence_Fast_GET_ITEM(endpoints, i); - if(!PyObject_IsInstance(p, (PyObject*)&EndpointType)) - { - PyErr_Format(PyExc_ValueError, STRCAST("expected element of type Ice.Endpoint")); - return NULL; - } - EndpointObject* o = (EndpointObject*)p; - assert(*o->endpoint); - seq.push_back(*o->endpoint); + if(!PyObject_IsInstance(p, (PyObject*)&EndpointType)) + { + PyErr_Format(PyExc_ValueError, STRCAST("expected element of type Ice.Endpoint")); + return NULL; + } + EndpointObject* o = (EndpointObject*)p; + assert(*o->endpoint); + seq.push_back(*o->endpoint); } Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_endpoints(seq); + newProxy = (*self->proxy)->ice_endpoints(seq); } catch(const Ice::Exception& ex) { @@ -761,13 +761,13 @@ proxyIceGetLocatorCacheTimeout(ProxyObject* self) try { - Ice::Int timeout = (*self->proxy)->ice_getLocatorCacheTimeout(); - return PyInt_FromLong(timeout); + Ice::Int timeout = (*self->proxy)->ice_getLocatorCacheTimeout(); + return PyInt_FromLong(timeout); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } } @@ -780,7 +780,7 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) int timeout; if(!PyArg_ParseTuple(args, STRCAST("i"), &timeout)) { - return NULL; + return NULL; } assert(self->proxy); @@ -788,12 +788,12 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_locatorCacheTimeout(timeout); + newProxy = (*self->proxy)->ice_locatorCacheTimeout(timeout); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -810,12 +810,12 @@ proxyIceIsConnectionCached(ProxyObject* self) PyObject* b; try { - b = (*self->proxy)->ice_isConnectionCached() ? Py_True : Py_False; + b = (*self->proxy)->ice_isConnectionCached() ? Py_True : Py_False; } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(b); @@ -845,12 +845,12 @@ proxyIceConnectionCached(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_connectionCached(n == 1); + newProxy = (*self->proxy)->ice_connectionCached(n == 1); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -875,20 +875,20 @@ proxyIceGetEndpointSelection(ProxyObject* self) PyObject* type; try { - Ice::EndpointSelectionType val = (*self->proxy)->ice_getEndpointSelection(); - if(val == Ice::Random) - { - type = rnd.get(); - } - else - { - type = ord.get(); - } + Ice::EndpointSelectionType val = (*self->proxy)->ice_getEndpointSelection(); + if(val == Ice::Random) + { + type = rnd.get(); + } + else + { + type = ord.get(); + } } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(type); @@ -916,11 +916,11 @@ proxyIceEndpointSelection(ProxyObject* self, PyObject* args) assert(ord.get() != NULL); if(rnd.get() == type) { - val = Ice::Random; + val = Ice::Random; } else if(ord.get() == type) { - val = Ice::Ordered; + val = Ice::Ordered; } else { @@ -933,12 +933,12 @@ proxyIceEndpointSelection(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_endpointSelection(val); + newProxy = (*self->proxy)->ice_endpointSelection(val); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -1079,8 +1079,8 @@ proxyIceGetRouter(ProxyObject* self) if(!router) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -1150,8 +1150,8 @@ proxyIceGetLocator(ProxyObject* self) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1595,12 +1595,12 @@ proxyIceGetConnection(ProxyObject* self) if(con) { - return createConnection(con, *self->communicator); + return createConnection(con, *self->communicator); } else { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } } @@ -1625,12 +1625,12 @@ proxyIceGetCachedConnection(ProxyObject* self) if(con) { - return createConnection(con, *self->communicator); + return createConnection(con, *self->communicator); } else { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } } @@ -1747,42 +1747,42 @@ proxyIceCheckedCast(PyObject* type, PyObject* args) if(PyString_Check(facetOrCtx)) { - facet = PyString_AS_STRING(facetOrCtx); + facet = PyString_AS_STRING(facetOrCtx); } else if(PyDict_Check(facetOrCtx)) { - if(ctx != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); - return NULL; - } - ctx = facetOrCtx; + if(ctx != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); + return NULL; + } + ctx = facetOrCtx; } else if(facetOrCtx != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); + return NULL; } if(ctx != Py_None && !PyDict_Check(ctx)) { - PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); + return NULL; } if(ctx == Py_None) { - return checkedCastImpl((ProxyObject*)obj, id, facet, type); + return checkedCastImpl((ProxyObject*)obj, id, facet, type); } else { - Ice::Context c; - if(!dictionaryToContext(ctx, c)) - { - return NULL; - } + Ice::Context c; + if(!dictionaryToContext(ctx, c)) + { + return NULL; + } - return checkedCastImpl((ProxyObject*)obj, id, facet, c, type); + return checkedCastImpl((ProxyObject*)obj, id, facet, c, type); } } @@ -1854,63 +1854,63 @@ proxyCheckedCast(PyObject* /*self*/, PyObject* args) if(arg1 != 0 && arg2 != 0) { - if(arg1 == Py_None) - { - arg1 = 0; - } - - if(arg2 == Py_None) - { - arg2 = 0; - } - - if(arg1 != 0) - { - if(!PyString_Check(arg1)) - { - PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); - return NULL; - } - facet = PyString_AS_STRING(arg1); - } - - if(arg2 != 0 && !PyDict_Check(arg2)) - { - PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); - return NULL; - } - ctx = arg2; + if(arg1 == Py_None) + { + arg1 = 0; + } + + if(arg2 == Py_None) + { + arg2 = 0; + } + + if(arg1 != 0) + { + if(!PyString_Check(arg1)) + { + PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); + return NULL; + } + facet = PyString_AS_STRING(arg1); + } + + if(arg2 != 0 && !PyDict_Check(arg2)) + { + PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); + return NULL; + } + ctx = arg2; } else if(arg1 != 0 && arg1 != Py_None) { - if(PyString_Check(arg1)) - { - facet = PyString_AS_STRING(arg1); - } - else if(PyDict_Check(arg1)) - { - ctx = arg1; - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); - return NULL; - } + if(PyString_Check(arg1)) + { + facet = PyString_AS_STRING(arg1); + } + else if(PyDict_Check(arg1)) + { + ctx = arg1; + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); + return NULL; + } } if(ctx == 0) { - return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, NULL); + return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, NULL); } else { - Ice::Context c; - if(!dictionaryToContext(ctx, c)) - { - return NULL; - } + Ice::Context c; + if(!dictionaryToContext(ctx, c)) + { + return NULL; + } - return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, c, NULL); + return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, c, NULL); } } diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp index 715d6f5fd55..a401aaf829c 100644 --- a/py/modules/IcePy/Slice.cpp +++ b/py/modules/IcePy/Slice.cpp @@ -41,17 +41,17 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) vector<string> argSeq; try { - argSeq = IceUtil::Options::split(cmd); + argSeq = IceUtil::Options::split(cmd); } catch(const IceUtil::BadOptException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } catch(const IceUtil::APIException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } if(list != NULL) @@ -72,23 +72,23 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) vector<string> files; try { - argSeq.insert(argSeq.begin(), ""); // dummy argv[0] - files = opts.parse(argSeq); - if(files.empty()) - { - PyErr_Format(PyExc_RuntimeError, "no Slice files specified in `%s'", cmd); - return NULL; - } + argSeq.insert(argSeq.begin(), ""); // dummy argv[0] + files = opts.parse(argSeq); + if(files.empty()) + { + PyErr_Format(PyExc_RuntimeError, "no Slice files specified in `%s'", cmd); + return NULL; + } } catch(const IceUtil::BadOptException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } catch(const IceUtil::APIException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } string cppArgs; @@ -100,27 +100,27 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) bool checksum = false; if(opts.isSet("D")) { - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -D" + *i; - } + vector<string> optargs = opts.argVec("D"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -D" + *i; + } } if(opts.isSet("U")) { - vector<string> optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -U" + *i; - } + vector<string> optargs = opts.argVec("U"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -U" + *i; + } } if(opts.isSet("I")) { - includePaths = opts.argVec("I"); - for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) - { - cppArgs += " -I" + *i; - } + includePaths = opts.argVec("I"); + for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) + { + cppArgs += " -I" + *i; + } } debug = opts.isSet("d") || opts.isSet("debug"); caseSensitive = opts.isSet("case-sensitive"); diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp index 078763a49a0..2f496d117e5 100644 --- a/py/modules/IcePy/Types.cpp +++ b/py/modules/IcePy/Types.cpp @@ -141,7 +141,7 @@ addClassInfo(const string& id, const ClassInfoPtr& info) ClassInfoMap::iterator p = _classInfoMap.find(id); if(p != _classInfoMap.end()) { - _classInfoMap.erase(p); + _classInfoMap.erase(p); } _classInfoMap.insert(ClassInfoMap::value_type(id, info)); } @@ -161,7 +161,7 @@ addProxyInfo(const string& id, const ProxyInfoPtr& info) ProxyInfoMap::iterator p = _proxyInfoMap.find(id); if(p != _proxyInfoMap.end()) { - _proxyInfoMap.erase(p); + _proxyInfoMap.erase(p); } _proxyInfoMap.insert(ProxyInfoMap::value_type(id, info)); } @@ -593,13 +593,13 @@ IcePy::PrimitiveInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHi { if(!validate(value)) { - out << "<invalid value - expected " << getId() << ">"; - return; + out << "<invalid value - expected " << getId() << ">"; + return; } PyObjectHandle p = PyObject_Str(value); if(p.get() == NULL) { - return; + return; } assert(PyString_Check(p.get())); out << PyString_AS_STRING(p.get()); @@ -695,13 +695,13 @@ IcePy::EnumInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistory { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } PyObjectHandle p = PyObject_Str(value); if(p.get() == NULL) { - return; + return; } assert(PyString_Check(p.get())); out << PyString_AS_STRING(p.get()); @@ -801,24 +801,24 @@ IcePy::StructInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHisto { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } out.sb(); for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } out.eb(); } @@ -856,7 +856,7 @@ IcePy::SequenceInfo::usesClasses() void IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq* metaData) + const Ice::StringSeq* metaData) { if(p == Py_None) { @@ -867,7 +867,7 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - marshalPrimitiveSequence(pi, p, os); + marshalPrimitiveSequence(pi, p, os); return; } @@ -889,7 +889,7 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object if(!elementType->validate(item)) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of `%s'"), static_cast<int>(i), - const_cast<char*>(id.c_str())); + const_cast<char*>(id.c_str())); throw AbortMarshaling(); } elementType->marshal(item, os, objectMap); @@ -908,25 +908,25 @@ IcePy::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCal SequenceMappingPtr sm; if(metaData) { - SequenceMapping::Type type; - if(!SequenceMapping::getType(*metaData, type) || type == mapping->type) - { - sm = mapping; - } - else - { - sm = new SequenceMapping(type); - } + SequenceMapping::Type type; + if(!SequenceMapping::getType(*metaData, type) || type == mapping->type) + { + sm = mapping; + } + else + { + sm = new SequenceMapping(type); + } } else { - sm = mapping; + sm = mapping; } PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - unmarshalPrimitiveSequence(pi, is, cb, target, closure, sm); + unmarshalPrimitiveSequence(pi, is, cb, target, closure, sm); return; } @@ -940,8 +940,8 @@ IcePy::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCal for(Ice::Int i = 0; i < sz; ++i) { - void* cl = reinterpret_cast<void*>(i); - elementType->unmarshal(is, sm, result.get(), cl); + void* cl = reinterpret_cast<void*>(i); + elementType->unmarshal(is, sm, result.get(), cl); } cb->unmarshaled(result.get(), target, closure); @@ -952,36 +952,36 @@ IcePy::SequenceInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHis { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "{}"; + out << "{}"; } else { - PyObjectHandle fastSeq = PySequence_Fast(value, STRCAST("expected a sequence value")); - if(fastSeq.get() == NULL) - { - return; - } + PyObjectHandle fastSeq = PySequence_Fast(value, STRCAST("expected a sequence value")); + if(fastSeq.get() == NULL) + { + return; + } - Py_ssize_t sz = PySequence_Fast_GET_SIZE(fastSeq.get()); + Py_ssize_t sz = PySequence_Fast_GET_SIZE(fastSeq.get()); - out.sb(); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fastSeq.get(), i); - if(item == NULL) - { - break; - } - out << nl << '[' << static_cast<int>(i) << "] = "; - elementType->print(item, out, history); - } - out.eb(); + out.sb(); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fastSeq.get(), i); + if(item == NULL) + { + break; + } + out << nl << '[' << static_cast<int>(i) << "] = "; + elementType->print(item, out, history); + } + out.eb(); } } @@ -1006,52 +1006,52 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje Py_ssize_t sz; if(PyObject_AsReadBuffer(p, &buf, &sz) == 0) { - const Ice::Byte* b = reinterpret_cast<const Ice::Byte*>(buf); - switch(pi->kind) - { - case PrimitiveInfo::KindBool: - { - os->writeBoolSeq(reinterpret_cast<const bool*>(b), reinterpret_cast<const bool*>(b + sz)); - break; - } - case PrimitiveInfo::KindByte: - { - os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(b), reinterpret_cast<const Ice::Byte*>(b + sz)); - break; - } - case PrimitiveInfo::KindShort: - { - os->writeShortSeq(reinterpret_cast<const Ice::Short*>(b), reinterpret_cast<const Ice::Short*>(b + sz)); - break; - } - case PrimitiveInfo::KindInt: - { - os->writeIntSeq(reinterpret_cast<const Ice::Int*>(b), reinterpret_cast<const Ice::Int*>(b + sz)); - break; - } - case PrimitiveInfo::KindLong: - { - PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); - throw AbortMarshaling(); - } - case PrimitiveInfo::KindFloat: - { - os->writeFloatSeq(reinterpret_cast<const Ice::Float*>(b), reinterpret_cast<const Ice::Float*>(b + sz)); - break; - } - case PrimitiveInfo::KindDouble: - { - os->writeDoubleSeq(reinterpret_cast<const Ice::Double*>(b), - reinterpret_cast<const Ice::Double*>(b + sz)); - break; - } - case PrimitiveInfo::KindString: - { - PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); - throw AbortMarshaling(); - } - } - return; + const Ice::Byte* b = reinterpret_cast<const Ice::Byte*>(buf); + switch(pi->kind) + { + case PrimitiveInfo::KindBool: + { + os->writeBoolSeq(reinterpret_cast<const bool*>(b), reinterpret_cast<const bool*>(b + sz)); + break; + } + case PrimitiveInfo::KindByte: + { + os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(b), reinterpret_cast<const Ice::Byte*>(b + sz)); + break; + } + case PrimitiveInfo::KindShort: + { + os->writeShortSeq(reinterpret_cast<const Ice::Short*>(b), reinterpret_cast<const Ice::Short*>(b + sz)); + break; + } + case PrimitiveInfo::KindInt: + { + os->writeIntSeq(reinterpret_cast<const Ice::Int*>(b), reinterpret_cast<const Ice::Int*>(b + sz)); + break; + } + case PrimitiveInfo::KindLong: + { + PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); + throw AbortMarshaling(); + } + case PrimitiveInfo::KindFloat: + { + os->writeFloatSeq(reinterpret_cast<const Ice::Float*>(b), reinterpret_cast<const Ice::Float*>(b + sz)); + break; + } + case PrimitiveInfo::KindDouble: + { + os->writeDoubleSeq(reinterpret_cast<const Ice::Double*>(b), + reinterpret_cast<const Ice::Double*>(b + sz)); + break; + } + case PrimitiveInfo::KindString: + { + PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); + throw AbortMarshaling(); + } + } + return; } PyErr_Clear(); // PyObject_AsReadBuffer sets an exception on failure. @@ -1059,303 +1059,303 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje PyObjectHandle fs; if(!buf) { - if(pi->kind == PrimitiveInfo::KindByte) - { - // - // Accept a string or a sequence for sequence<byte>. - // - if(!PyString_Check(p)) - { - fs = PySequence_Fast(p, STRCAST("expected a string, sequence, or buffer value")); - if(fs.get() == NULL) - { - return; - } - } - } - else - { - fs = PySequence_Fast(p, STRCAST("expected a sequence or buffer value")); - if(fs.get() == NULL) - { - return; - } - } + if(pi->kind == PrimitiveInfo::KindByte) + { + // + // Accept a string or a sequence for sequence<byte>. + // + if(!PyString_Check(p)) + { + fs = PySequence_Fast(p, STRCAST("expected a string, sequence, or buffer value")); + if(fs.get() == NULL) + { + return; + } + } + } + else + { + fs = PySequence_Fast(p, STRCAST("expected a sequence or buffer value")); + if(fs.get() == NULL) + { + return; + } + } } switch(pi->kind) { case PrimitiveInfo::KindBool: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::BoolSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - int isTrue = PyObject_IsTrue(item); - if(isTrue < 0) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<bool>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = isTrue ? true : false; - } - os->writeBoolSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::BoolSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + int isTrue = PyObject_IsTrue(item); + if(isTrue < 0) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<bool>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = isTrue ? true : false; + } + os->writeBoolSeq(seq); + break; } case PrimitiveInfo::KindByte: { - if(fs.get() == NULL) - { - assert(PyString_Check(p)); - const char* str = PyString_AS_STRING(p); - sz = PyString_GET_SIZE(p); - os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); - } - else - { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ByteSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val = -1; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - - if(PyErr_Occurred() || val < 0 || val > 255) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<byte>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Byte>(val); - } - os->writeByteSeq(seq); - } - break; + if(fs.get() == NULL) + { + assert(PyString_Check(p)); + const char* str = PyString_AS_STRING(p); + sz = PyString_GET_SIZE(p); + os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); + } + else + { + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::ByteSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val = -1; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + + if(PyErr_Occurred() || val < 0 || val > 255) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<byte>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Byte>(val); + } + os->writeByteSeq(seq); + } + break; } case PrimitiveInfo::KindShort: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ShortSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val = SHRT_MIN - 1; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - - if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<short>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Short>(val); - } - os->writeShortSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::ShortSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val = SHRT_MIN - 1; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + + if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<short>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Short>(val); + } + os->writeShortSeq(seq); + break; } case PrimitiveInfo::KindInt: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::IntSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Int>(val); - } - os->writeIntSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::IntSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Int>(val); + } + os->writeIntSeq(seq); + break; } case PrimitiveInfo::KindLong: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::LongSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - Ice::Long val; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLongLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - if(PyErr_Occurred()) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = val; - } - os->writeLongSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::LongSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + Ice::Long val; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLongLong(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + if(PyErr_Occurred()) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = val; + } + os->writeLongSeq(seq); + break; } case PrimitiveInfo::KindFloat: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::FloatSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - float val; - if(PyFloat_Check(item)) - { - val = static_cast<float>(PyFloat_AS_DOUBLE(item)); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<float>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - seq[i] = val; - } - os->writeFloatSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::FloatSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + float val; + if(PyFloat_Check(item)) + { + val = static_cast<float>(PyFloat_AS_DOUBLE(item)); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<float>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + seq[i] = val; + } + os->writeFloatSeq(seq); + break; } case PrimitiveInfo::KindDouble: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::DoubleSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - double val; - if(PyFloat_Check(item)) - { - val = PyFloat_AS_DOUBLE(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<double>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - seq[i] = val; - } - os->writeDoubleSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::DoubleSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + double val; + if(PyFloat_Check(item)) + { + val = PyFloat_AS_DOUBLE(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<double>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + seq[i] = val; + } + os->writeDoubleSeq(seq); + break; } case PrimitiveInfo::KindString: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::StringSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::StringSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } - string val; - if(PyString_Check(item)) - { - val = string(PyString_AS_STRING(item), PyString_GET_SIZE(item)); - } - else if(p != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<string>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } + string val; + if(PyString_Check(item)) + { + val = string(PyString_AS_STRING(item), PyString_GET_SIZE(item)); + } + else if(p != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<string>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } - seq[i] = val; - } - os->writeStringSeq(seq); - break; + seq[i] = val; + } + os->writeStringSeq(seq); + break; } } } void IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, const Ice::InputStreamPtr& is, - const UnmarshalCallbackPtr& cb, PyObject* target, void* closure, - const SequenceMappingPtr& sm) + const UnmarshalCallbackPtr& cb, PyObject* target, void* closure, + const SequenceMappingPtr& sm) { PyObjectHandle result; @@ -1363,184 +1363,184 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons { case PrimitiveInfo::KindBool: { - pair<const bool*, const bool*> p; - IceUtil::ScopedArray<bool> arr(is->readBoolSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - sm->setItem(result.get(), i, p.first[i] ? Py_True : Py_False); - } - break; + pair<const bool*, const bool*> p; + IceUtil::ScopedArray<bool> arr(is->readBoolSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + sm->setItem(result.get(), i, p.first[i] ? Py_True : Py_False); + } + break; } case PrimitiveInfo::KindByte: { - pair<const Ice::Byte*, const Ice::Byte*> p; - is->readByteSeq(p); - int sz = static_cast<int>(p.second - p.first); - if(sm->type == SequenceMapping::SEQ_DEFAULT) - { - result = PyString_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - } - else - { - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - } - break; + pair<const Ice::Byte*, const Ice::Byte*> p; + is->readByteSeq(p); + int sz = static_cast<int>(p.second - p.first); + if(sm->type == SequenceMapping::SEQ_DEFAULT) + { + result = PyString_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + } + else + { + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + } + break; } case PrimitiveInfo::KindShort: { - pair<const Ice::Short*, const Ice::Short*> p; - IceUtil::ScopedArray<Ice::Short> arr(is->readShortSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Short*, const Ice::Short*> p; + IceUtil::ScopedArray<Ice::Short> arr(is->readShortSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindInt: { - pair<const Ice::Int*, const Ice::Int*> p; - IceUtil::ScopedArray<Ice::Int> arr(is->readIntSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Int*, const Ice::Int*> p; + IceUtil::ScopedArray<Ice::Int> arr(is->readIntSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindLong: { - pair<const Ice::Long*, const Ice::Long*> p; - IceUtil::ScopedArray<Ice::Long> arr(is->readLongSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyLong_FromLongLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Long*, const Ice::Long*> p; + IceUtil::ScopedArray<Ice::Long> arr(is->readLongSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyLong_FromLongLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindFloat: { - pair<const Ice::Float*, const Ice::Float*> p; - IceUtil::ScopedArray<Ice::Float> arr(is->readFloatSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyFloat_FromDouble(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Float*, const Ice::Float*> p; + IceUtil::ScopedArray<Ice::Float> arr(is->readFloatSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyFloat_FromDouble(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindDouble: { - pair<const Ice::Double*, const Ice::Double*> p; - IceUtil::ScopedArray<Ice::Double> arr(is->readDoubleSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyFloat_FromDouble(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Double*, const Ice::Double*> p; + IceUtil::ScopedArray<Ice::Double> arr(is->readDoubleSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyFloat_FromDouble(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindString: { - Ice::StringSeq seq = is->readStringSeq(); - int sz = static_cast<int>(seq.size()); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyString_FromString(seq[i].c_str()); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + Ice::StringSeq seq = is->readStringSeq(); + int sz = static_cast<int>(seq.size()); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyString_FromString(seq[i].c_str()); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } } cb->unmarshaled(result.get(), target, closure); @@ -1551,24 +1551,24 @@ IcePy::SequenceInfo::SequenceMapping::getType(const Ice::StringSeq& metaData, Ty { if(!metaData.empty()) { - for(Ice::StringSeq::const_iterator p = metaData.begin(); p != metaData.end(); ++p) - { - if((*p) == "python:seq:default") - { - t = SEQ_DEFAULT; - return true; - } - else if((*p) == "python:seq:tuple") - { - t = SEQ_TUPLE; - return true; - } - else if((*p) == "python:seq:list") - { - t = SEQ_LIST; - return true; - } - } + for(Ice::StringSeq::const_iterator p = metaData.begin(); p != metaData.end(); ++p) + { + if((*p) == "python:seq:default") + { + t = SEQ_DEFAULT; + return true; + } + else if((*p) == "python:seq:tuple") + { + t = SEQ_TUPLE; + return true; + } + else if((*p) == "python:seq:list") + { + t = SEQ_LIST; + return true; + } + } } return false; @@ -1583,7 +1583,7 @@ IcePy::SequenceInfo::SequenceMapping::SequenceMapping(const Ice::StringSeq& meta { if(!getType(meta, type)) { - type = SEQ_DEFAULT; + type = SEQ_DEFAULT; } } @@ -1593,14 +1593,14 @@ IcePy::SequenceInfo::SequenceMapping::unmarshaled(PyObject* val, PyObject* targe long i = reinterpret_cast<long>(closure); if(type == SEQ_DEFAULT || type == SEQ_LIST) { - PyList_SET_ITEM(target, i, val); - Py_INCREF(val); // PyList_SET_ITEM steals a reference. + PyList_SET_ITEM(target, i, val); + Py_INCREF(val); // PyList_SET_ITEM steals a reference. } else { - assert(type == SEQ_TUPLE); - PyTuple_SET_ITEM(target, i, val); - Py_INCREF(val); // PyTuple_SET_ITEM steals a reference. + assert(type == SEQ_TUPLE); + PyTuple_SET_ITEM(target, i, val); + Py_INCREF(val); // PyTuple_SET_ITEM steals a reference. } } @@ -1609,12 +1609,12 @@ IcePy::SequenceInfo::SequenceMapping::createContainer(int sz) const { if(type == SEQ_DEFAULT || type == SEQ_LIST) { - return PyList_New(sz); + return PyList_New(sz); } else { - assert(type == SEQ_TUPLE); - return PyTuple_New(sz); + assert(type == SEQ_TUPLE); + return PyTuple_New(sz); } } @@ -1623,14 +1623,14 @@ IcePy::SequenceInfo::SequenceMapping::setItem(PyObject* cont, int i, PyObject* v { if(type == SEQ_DEFAULT || type == SEQ_LIST) { - Py_INCREF(val); - PyList_SET_ITEM(cont, i, val); // PyList_SET_ITEM steals a reference. + Py_INCREF(val); + PyList_SET_ITEM(cont, i, val); // PyList_SET_ITEM steals a reference. } else { - assert(type == SEQ_TUPLE); - Py_INCREF(val); - PyTuple_SET_ITEM(cont, i, val); // PyTuple_SET_ITEM steals a reference. + assert(type == SEQ_TUPLE); + Py_INCREF(val); + PyTuple_SET_ITEM(cont, i, val); // PyTuple_SET_ITEM steals a reference. } } @@ -1657,7 +1657,7 @@ IcePy::DictionaryInfo::usesClasses() void IcePy::DictionaryInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq*) + const Ice::StringSeq*) { if(p == Py_None) { @@ -1731,7 +1731,7 @@ IcePy::DictionaryInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalC // The callback will reset the dictionary entry with the unmarshaled value, // so we pass it the key. // - void* cl = reinterpret_cast<void*>(keyCB->key.get()); + void* cl = reinterpret_cast<void*>(keyCB->key.get()); valueType->unmarshal(is, this, p.get(), cl); } @@ -1753,37 +1753,37 @@ IcePy::DictionaryInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectH { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "{}"; + out << "{}"; } else { - Py_ssize_t pos = 0; - PyObject* elemKey; - PyObject* elemValue; - out.sb(); - bool first = true; - while(PyDict_Next(value, &pos, &elemKey, &elemValue)) - { - if(first) - { - first = false; - } - else - { - out << nl; - } - out << nl << "key = "; - keyType->print(elemKey, out, history); - out << nl << "value = "; - valueType->print(elemValue, out, history); - } - out.eb(); + Py_ssize_t pos = 0; + PyObject* elemKey; + PyObject* elemValue; + out.sb(); + bool first = true; + while(PyDict_Next(value, &pos, &elemKey, &elemValue)) + { + if(first) + { + first = false; + } + else + { + out << nl; + } + out << nl << "key = "; + keyType->print(elemKey, out, history); + out << nl << "value = "; + valueType->print(elemValue, out, history); + } + out.eb(); } } @@ -1832,7 +1832,7 @@ IcePy::ClassInfo::usesClasses() void IcePy::ClassInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq*) + const Ice::StringSeq*) { if(pythonType.get() == NULL) { @@ -1902,34 +1902,34 @@ IcePy::ClassInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistor { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "<nil>"; + out << "<nil>"; } else { - map<PyObject*, int>::iterator q = history->objects.find(value); - if(q != history->objects.end()) - { - out << "<object #" << q->second << ">"; - } - else - { - PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("ice_type")); - assert(iceType.get() != NULL); - ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(iceType.get())); - assert(info); - out << "object #" << history->index << " (" << info->id << ')'; - history->objects.insert(map<PyObject*, int>::value_type(value, history->index)); - ++history->index; - out.sb(); - info->printMembers(value, out, history); - out.eb(); - } + map<PyObject*, int>::iterator q = history->objects.find(value); + if(q != history->objects.end()) + { + out << "<object #" << q->second << ">"; + } + else + { + PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("ice_type")); + assert(iceType.get() != NULL); + ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(iceType.get())); + assert(info); + out << "object #" << history->index << " (" << info->id << ')'; + history->objects.insert(map<PyObject*, int>::value_type(value, history->index)); + ++history->index; + out.sb(); + info->printMembers(value, out, history); + out.eb(); + } } } @@ -1955,23 +1955,23 @@ IcePy::ClassInfo::printMembers(PyObject* value, IceUtil::Output& out, PrintObjec { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } } @@ -2034,23 +2034,23 @@ IcePy::ProxyInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistor { if(!validate(value)) { - out << "<invalid value - expected " << getId() << ">"; - return; + out << "<invalid value - expected " << getId() << ">"; + return; } if(value == Py_None) { - out << "<nil>"; + out << "<nil>"; } else { - PyObjectHandle p = PyObject_Str(value); - if(p.get() == NULL) - { - return; - } - assert(PyString_Check(p.get())); - out << PyString_AS_STRING(p.get()); + PyObjectHandle p = PyObject_Str(value); + if(p.get() == NULL) + { + return; + } + assert(PyString_Check(p.get())); + out << PyString_AS_STRING(p.get()); } } @@ -2270,9 +2270,9 @@ IcePy::ReadObjectCallback::invoke(const Ice::ObjectPtr& p) if(!PyObject_IsInstance(obj, _info->pythonType.get())) { Ice::UnexpectedObjectException ex(__FILE__, __LINE__); - ex.reason = "unmarshaled object is not an instance of " + _info->id; + ex.reason = "unmarshaled object is not an instance of " + _info->id; ex.type = reader->getInfo()->getId(); - ex.expectedType = _info->id; + ex.expectedType = _info->id; throw ex; } @@ -2321,7 +2321,7 @@ IcePy::ExceptionInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec if(!member->type->validate(val.get())) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for %s member `%s'"), - const_cast<char*>(id.c_str()), memberName); + const_cast<char*>(id.c_str()), memberName); throw AbortMarshaling(); } @@ -2367,8 +2367,8 @@ IcePy::ExceptionInfo::print(PyObject* value, IceUtil::Output& out) { if(!PyObject_IsInstance(value, pythonType.get())) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } PrintObjectHistory history; @@ -2385,23 +2385,23 @@ IcePy::ExceptionInfo::printMembers(PyObject* value, IceUtil::Output& out, PrintO { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } } @@ -2708,25 +2708,25 @@ convertDataMembers(PyObject* members, DataMemberList& l) Py_ssize_t sz = PyTuple_GET_SIZE(members); for(Py_ssize_t i = 0; i < sz; ++i) { - PyObject* m = PyTuple_GET_ITEM(members, i); - assert(PyTuple_Check(m)); - assert(PyTuple_GET_SIZE(m) == 3); + PyObject* m = PyTuple_GET_ITEM(members, i); + assert(PyTuple_Check(m)); + assert(PyTuple_GET_SIZE(m) == 3); - PyObject* name = PyTuple_GET_ITEM(m, 0); // Member name. - assert(PyString_Check(name)); - PyObject* meta = PyTuple_GET_ITEM(m, 1); // Member metadata. - assert(PyTuple_Check(meta)); - PyObject* t = PyTuple_GET_ITEM(m, 2); // Member type. + PyObject* name = PyTuple_GET_ITEM(m, 0); // Member name. + assert(PyString_Check(name)); + PyObject* meta = PyTuple_GET_ITEM(m, 1); // Member metadata. + assert(PyTuple_Check(meta)); + PyObject* t = PyTuple_GET_ITEM(m, 2); // Member type. - DataMemberPtr member = new DataMember; - member->name = string(PyString_AS_STRING(name), PyString_GET_SIZE(name)); + DataMemberPtr member = new DataMember; + member->name = string(PyString_AS_STRING(name), PyString_GET_SIZE(name)); #ifndef NDEBUG - bool b = + bool b = #endif - tupleToStringSeq(meta, member->metaData); - assert(b); - member->type = getType(t); - l.push_back(member); + tupleToStringSeq(meta, member->metaData); + assert(b); + member->type = getType(t); + l.push_back(member); } } @@ -2883,7 +2883,7 @@ IcePy_declareClass(PyObject*, PyObject* args) info = new ClassInfo; info->id = id; info->typeObj = createType(info); - info->defined = false; + info->defined = false; addClassInfo(id, info); } diff --git a/py/modules/IcePy/Types.h b/py/modules/IcePy/Types.h index a1d91919746..4decb6741ef 100644 --- a/py/modules/IcePy/Types.h +++ b/py/modules/IcePy/Types.h @@ -93,7 +93,7 @@ public: // virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0) = 0; virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0) = 0; + const Ice::StringSeq* = 0) = 0; virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*) = 0; }; @@ -112,7 +112,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -147,7 +147,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -185,7 +185,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -212,7 +212,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -220,19 +220,19 @@ public: struct SequenceMapping : public UnmarshalCallback { - enum Type { SEQ_DEFAULT, SEQ_TUPLE, SEQ_LIST }; + enum Type { SEQ_DEFAULT, SEQ_TUPLE, SEQ_LIST }; - SequenceMapping(Type); - SequenceMapping(const Ice::StringSeq&); + SequenceMapping(Type); + SequenceMapping(const Ice::StringSeq&); - static bool getType(const Ice::StringSeq&, Type&); + static bool getType(const Ice::StringSeq&, Type&); - virtual void unmarshaled(PyObject*, PyObject*, void*); + virtual void unmarshaled(PyObject*, PyObject*, void*); - PyObject* createContainer(int) const; - void setItem(PyObject*, int, PyObject*) const; + PyObject* createContainer(int) const; + void setItem(PyObject*, int, PyObject*) const; - Type type; + Type type; }; typedef IceUtil::Handle<SequenceMapping> SequenceMappingPtr; @@ -244,7 +244,7 @@ private: void marshalPrimitiveSequence(const PrimitiveInfoPtr&, PyObject*, const Ice::OutputStreamPtr&); void unmarshalPrimitiveSequence(const PrimitiveInfoPtr&, const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, - PyObject*, void*, const SequenceMappingPtr&); + PyObject*, void*, const SequenceMappingPtr&); }; typedef IceUtil::Handle<SequenceInfo> SequenceInfoPtr; @@ -263,7 +263,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void unmarshaled(PyObject*, PyObject*, void*); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -300,7 +300,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -331,7 +331,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp index fa313ffe5cf..32d587532d3 100644 --- a/py/modules/IcePy/Util.cpp +++ b/py/modules/IcePy/Util.cpp @@ -101,54 +101,54 @@ IcePy::PyException::raise() if(PyObject_IsInstance(ex.get(), userExceptionType)) { - Ice::UnknownUserException e(__FILE__, __LINE__); - string tb = getTraceback(); - if(!tb.empty()) - { - e.unknown = tb; - } - else - { - PyObjectHandle name = PyObject_CallMethod(ex.get(), STRCAST("ice_name"), NULL); - PyErr_Clear(); - if(name.get() == NULL) - { - e.unknown = getTypeName(); - } - else - { - e.unknown = PyString_AS_STRING(name.get()); - } - } - throw e; + Ice::UnknownUserException e(__FILE__, __LINE__); + string tb = getTraceback(); + if(!tb.empty()) + { + e.unknown = tb; + } + else + { + PyObjectHandle name = PyObject_CallMethod(ex.get(), STRCAST("ice_name"), NULL); + PyErr_Clear(); + if(name.get() == NULL) + { + e.unknown = getTypeName(); + } + else + { + e.unknown = PyString_AS_STRING(name.get()); + } + } + throw e; } else if(PyObject_IsInstance(ex.get(), localExceptionType)) { - raiseLocalException(); + raiseLocalException(); } else { - Ice::UnknownException e(__FILE__, __LINE__); - string tb = getTraceback(); - if(!tb.empty()) - { - e.unknown = tb; - } - else - { - ostringstream ostr; + Ice::UnknownException e(__FILE__, __LINE__); + string tb = getTraceback(); + if(!tb.empty()) + { + e.unknown = tb; + } + else + { + ostringstream ostr; - ostr << getTypeName(); + ostr << getTypeName(); - IcePy::PyObjectHandle msg = PyObject_Str(ex.get()); - if(msg.get() != NULL && strlen(PyString_AsString(msg.get())) > 0) - { - ostr << ": " << PyString_AsString(msg.get()); - } + IcePy::PyObjectHandle msg = PyObject_Str(ex.get()); + if(msg.get() != NULL && strlen(PyString_AsString(msg.get())) > 0) + { + ostr << ": " << PyString_AsString(msg.get()); + } - e.unknown = ostr.str(); - } - throw e; + e.unknown = ostr.str(); + } + throw e; } } @@ -159,67 +159,67 @@ IcePy::PyException::raiseLocalException() try { - if(typeName == "Ice.ObjectNotExistException") - { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.OperationNotExistException") - { - throw Ice::OperationNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.FacetNotExistException") - { - throw Ice::FacetNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.RequestFailedException") - { - throw Ice::RequestFailedException(__FILE__, __LINE__); - } + if(typeName == "Ice.ObjectNotExistException") + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.OperationNotExistException") + { + throw Ice::OperationNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.FacetNotExistException") + { + throw Ice::FacetNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.RequestFailedException") + { + throw Ice::RequestFailedException(__FILE__, __LINE__); + } } catch(Ice::RequestFailedException& e) { - IcePy::PyObjectHandle member; - member = PyObject_GetAttrString(ex.get(), STRCAST("id")); - if(member.get() != NULL && IcePy::checkIdentity(member.get())) - { - IcePy::getIdentity(member.get(), e.id); - } - member = PyObject_GetAttrString(ex.get(), STRCAST("facet")); - if(member.get() != NULL && PyString_Check(member.get())) - { - e.facet = PyString_AS_STRING(member.get()); - } - member = PyObject_GetAttrString(ex.get(), STRCAST("operation")); - if(member.get() != NULL && PyString_Check(member.get())) - { - e.operation = PyString_AS_STRING(member.get()); - } - throw; + IcePy::PyObjectHandle member; + member = PyObject_GetAttrString(ex.get(), STRCAST("id")); + if(member.get() != NULL && IcePy::checkIdentity(member.get())) + { + IcePy::getIdentity(member.get(), e.id); + } + member = PyObject_GetAttrString(ex.get(), STRCAST("facet")); + if(member.get() != NULL && PyString_Check(member.get())) + { + e.facet = PyString_AS_STRING(member.get()); + } + member = PyObject_GetAttrString(ex.get(), STRCAST("operation")); + if(member.get() != NULL && PyString_Check(member.get())) + { + e.operation = PyString_AS_STRING(member.get()); + } + throw; } try { - if(typeName == "Ice.UnknownLocalException") - { - throw Ice::UnknownLocalException(__FILE__, __LINE__); - } - else if(typeName == "Ice.UnknownUserException") - { - throw Ice::UnknownUserException(__FILE__, __LINE__); - } - else if(typeName == "Ice.UnknownException") - { - throw Ice::UnknownException(__FILE__, __LINE__); - } + if(typeName == "Ice.UnknownLocalException") + { + throw Ice::UnknownLocalException(__FILE__, __LINE__); + } + else if(typeName == "Ice.UnknownUserException") + { + throw Ice::UnknownUserException(__FILE__, __LINE__); + } + else if(typeName == "Ice.UnknownException") + { + throw Ice::UnknownException(__FILE__, __LINE__); + } } catch(Ice::UnknownException& e) { - IcePy::PyObjectHandle member; - member = PyObject_GetAttrString(ex.get(), STRCAST("unknown")); - if(member.get() != NULL && PyString_Check(member.get()) && strlen(PyString_AS_STRING(member.get())) > 0) - { - e.unknown = PyString_AS_STRING(member.get()); - } + IcePy::PyObjectHandle member; + member = PyObject_GetAttrString(ex.get(), STRCAST("unknown")); + if(member.get() != NULL && PyString_Check(member.get()) && strlen(PyString_AS_STRING(member.get())) > 0) + { + e.unknown = PyString_AS_STRING(member.get()); + } throw; } @@ -227,11 +227,11 @@ IcePy::PyException::raiseLocalException() string tb = getTraceback(); if(!tb.empty()) { - e.unknown = tb; + e.unknown = tb; } else { - e.unknown = typeName; + e.unknown = typeName; } throw e; } @@ -241,7 +241,7 @@ IcePy::PyException::getTraceback() { if(_tb.get() == NULL) { - return string(); + return string(); } // @@ -262,7 +262,7 @@ IcePy::PyException::getTraceback() string result; for(Py_ssize_t i = 0; i < PyList_GET_SIZE(list.get()); ++i) { - result += PyString_AsString(PyList_GetItem(list.get(), i)); + result += PyString_AsString(PyList_GetItem(list.get(), i)); } return result; @@ -314,16 +314,16 @@ IcePy::listToStringSeq(PyObject* l, Ice::StringSeq& seq) Py_ssize_t sz = PyList_GET_SIZE(l); for(Py_ssize_t i = 0; i < sz; ++i) { - PyObject* item = PyList_GET_ITEM(l, i); - if(item == NULL) - { - return false; - } - if(!PyString_Check(item)) - { - return false; - } - seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); + PyObject* item = PyList_GET_ITEM(l, i); + if(item == NULL) + { + return false; + } + if(!PyString_Check(item)) + { + return false; + } + seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); } return true; @@ -362,16 +362,16 @@ IcePy::tupleToStringSeq(PyObject* t, Ice::StringSeq& seq) int sz = PyTuple_GET_SIZE(t); for(int i = 0; i < sz; ++i) { - PyObject* item = PyTuple_GET_ITEM(t, i); - if(item == NULL) - { - return false; - } - if(!PyString_Check(item)) - { - return false; - } - seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); + PyObject* item = PyTuple_GET_ITEM(t, i); + if(item == NULL) + { + return false; + } + if(!PyString_Check(item)) + { + return false; + } + seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); } return true; @@ -493,34 +493,34 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::InitializationException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::PluginInitializationException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::AlreadyRegisteredException& e) { - IcePy::PyObjectHandle m; - m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); - PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); - m = PyString_FromString(const_cast<char*>(e.id.c_str())); - PyObject_SetAttrString(p, STRCAST("id"), m.get()); + IcePy::PyObjectHandle m; + m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); + PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); + m = PyString_FromString(const_cast<char*>(e.id.c_str())); + PyObject_SetAttrString(p, STRCAST("id"), m.get()); } catch(const Ice::NotRegisteredException& e) { - IcePy::PyObjectHandle m; - m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); - PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); - m = PyString_FromString(const_cast<char*>(e.id.c_str())); - PyObject_SetAttrString(p, STRCAST("id"), m.get()); + IcePy::PyObjectHandle m; + m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); + PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); + m = PyString_FromString(const_cast<char*>(e.id.c_str())); + PyObject_SetAttrString(p, STRCAST("id"), m.get()); } catch(const Ice::TwowayOnlyException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.operation.c_str())); - PyObject_SetAttrString(p, STRCAST("operation"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.operation.c_str())); + PyObject_SetAttrString(p, STRCAST("operation"), m.get()); } catch(const Ice::UnknownException& e) { @@ -574,15 +574,15 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::FileException& e) { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); - PyObject_SetAttrString(p, STRCAST("error"), m.get()); - m = PyString_FromString(const_cast<char*>(e.path.c_str())); - PyObject_SetAttrString(p, STRCAST("path"), m.get()); + IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + PyObject_SetAttrString(p, STRCAST("error"), m.get()); + m = PyString_FromString(const_cast<char*>(e.path.c_str())); + PyObject_SetAttrString(p, STRCAST("path"), m.get()); } catch(const Ice::SyscallException& e) // This must appear after all subclasses of SyscallException. { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); - PyObject_SetAttrString(p, STRCAST("error"), m.get()); + IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + PyObject_SetAttrString(p, STRCAST("error"), m.get()); } catch(const Ice::DNSException& e) { @@ -641,18 +641,18 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::FeatureNotSupportedException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.unsupportedFeature.c_str())); - PyObject_SetAttrString(p, STRCAST("unsupportedFeature"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.unsupportedFeature.c_str())); + PyObject_SetAttrString(p, STRCAST("unsupportedFeature"), m.get()); } catch(const Ice::NotSetException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.key.c_str())); - PyObject_SetAttrString(p, STRCAST("key"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.key.c_str())); + PyObject_SetAttrString(p, STRCAST("key"), m.get()); } catch(const Ice::SecurityException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::LocalException&) { @@ -731,7 +731,7 @@ IcePy::setPythonException(const Ice::Exception& ex) PyObjectHandle p = convertException(ex); if(p.get() != NULL) { - setPythonException(p.get()); + setPythonException(p.get()); } } diff --git a/py/python/Ice.py b/py/python/Ice.py index cfbedd550dc..55b1fa278e6 100644 --- a/py/python/Ice.py +++ b/py/python/Ice.py @@ -176,10 +176,10 @@ class ThreadNotification(object): # class InitializationData(object): def __init__(self): - self.properties = None - self.logger = None - #self.stats = None # Stats not currently supported in Python. - self.threadHook = None + self.properties = None + self.logger = None + #self.stats = None # Stats not currently supported in Python. + self.threadHook = None # # Communicator wrapper. @@ -187,7 +187,7 @@ class InitializationData(object): class CommunicatorI(Communicator): def __init__(self, impl): self._impl = impl - impl._setWrapper(self) + impl._setWrapper(self) def destroy(self): self._impl.destroy() @@ -255,10 +255,10 @@ class CommunicatorI(Communicator): def getLogger(self): logger = self._impl.getLogger() - if isinstance(logger, Logger): - return logger - else: - return LoggerI(logger) + if isinstance(logger, Logger): + return logger + else: + return LoggerI(logger) def getStats(self): raise RuntimeError("operation `getStats' not implemented") @@ -311,7 +311,7 @@ def initializeWithLogger(args, logger): # def initializeWithPropertiesAndLogger(args, properties, logger): warnings.warn("initializeWithPropertiesAndLogger has been deprecated, use initialize instead", - DeprecationWarning, 2) + DeprecationWarning, 2) data = InitializationData() data.properties = properties data.logger = logger @@ -546,82 +546,82 @@ class CtrlCHandler(threading.Thread): _self = None def __init__(self): - threading.Thread.__init__(self) + threading.Thread.__init__(self) if CtrlCHandler._self != None: raise RuntimeError("Only a single instance of a CtrlCHandler can be instantiated.") - CtrlCHandler._self = self + CtrlCHandler._self = self - # State variables. These are not class static variables. - self._condVar = threading.Condition() - self._queue = [] - self._done = False - self._callback = None + # State variables. These are not class static variables. + self._condVar = threading.Condition() + self._queue = [] + self._done = False + self._callback = None - # - # Setup and install signal handlers - # + # + # Setup and install signal handlers + # if signal.__dict__.has_key('SIGHUP'): signal.signal(signal.SIGHUP, CtrlCHandler.signalHandler) signal.signal(signal.SIGINT, CtrlCHandler.signalHandler) signal.signal(signal.SIGTERM, CtrlCHandler.signalHandler) - # Start the thread once everything else is done. - self.start() + # Start the thread once everything else is done. + self.start() # Dequeue and dispatch signals. def run(self): - while True: - self._condVar.acquire() - while len(self._queue) == 0 and not self._done: - self._condVar.wait() - if self._done: - self._condVar.release() - break - sig, callback = self._queue.pop() - self._condVar.release() - if callback: - callback(sig) + while True: + self._condVar.acquire() + while len(self._queue) == 0 and not self._done: + self._condVar.wait() + if self._done: + self._condVar.release() + break + sig, callback = self._queue.pop() + self._condVar.release() + if callback: + callback(sig) # Destroy the object. Wait for the thread to terminate and cleanup # the internal state. def destroy(self): - self._condVar.acquire() - self._done = True - self._condVar.notify() - self._condVar.release() - - # Wait for the thread to terminate - self.join() - # - # Cleanup any state set by the CtrlCHandler. - # + self._condVar.acquire() + self._done = True + self._condVar.notify() + self._condVar.release() + + # Wait for the thread to terminate + self.join() + # + # Cleanup any state set by the CtrlCHandler. + # if signal.__dict__.has_key('SIGHUP'): signal.signal(signal.SIGHUP, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) - self._self = None + self._self = None def setCallback(self, callback): - self._condVar.acquire() - self._callback = callback - self._condVar.release() + self._condVar.acquire() + self._callback = callback + self._condVar.release() def getCallback(self): - self._condVar.acquire() - callback = self._callback - self._condVar.release() - return callback + self._condVar.acquire() + callback = self._callback + self._condVar.release() + return callback # Private. Only called by the signal handling mechanism. def signalHandler(self, sig, frame): - self._self._condVar.acquire() - # - # The signal AND the current callback are queued together. - # - self._self._queue.append([sig, self._self._callback]) - self._self._condVar.notify() - self._self._condVar.release() + self._self._condVar.acquire() + # + # The signal AND the current callback are queued together. + # + self._self._queue.append([sig, self._self._callback]) + self._self._condVar.notify() + self._self._condVar.release() signalHandler = classmethod(signalHandler) # @@ -643,22 +643,22 @@ class Application(object): # Install our handler for the signals we are interested in. We assume main() # is called from the main thread. # - Application._ctrlCHandler = CtrlCHandler() + Application._ctrlCHandler = CtrlCHandler() try: - status = 0 + status = 0 - Application._interrupted = False - Application._appName = args[0] + Application._interrupted = False + Application._appName = args[0] - if not initData: - initData = InitializationData() + if not initData: + initData = InitializationData() if configFile: initData.properties = createProperties() initData.properties.load(configFile) - Application._application = self - Application._communicator = initialize(args, initData) - Application._destroyed = False + Application._application = self + Application._communicator = initialize(args, initData) + Application._destroyed = False # # Used by destroyOnInterruptCallback and shutdownOnInterruptCallback. @@ -675,27 +675,27 @@ class Application(object): traceback.print_exc() status = 1 - # - # Don't want any new interrupt and at this point (post-run), - # it would not make sense to release a held signal to run - # shutdown or destroy. - # - Application.ignoreInterrupt() + # + # Don't want any new interrupt and at this point (post-run), + # it would not make sense to release a held signal to run + # shutdown or destroy. + # + Application.ignoreInterrupt() Application._condVar.acquire() - while Application._callbackInProgress: - Application._condVar.wait() - if Application._destroyed: - Application._communicator = None - else: - Application._destroyed = True - # - # And _communicator != 0, meaning will be destroyed - # next, _destroyed = true also ensures that any - # remaining callback won't do anything - # - Application._application = None - Application._condVar.release() + while Application._callbackInProgress: + Application._condVar.wait() + if Application._destroyed: + Application._communicator = None + else: + Application._destroyed = True + # + # And _communicator != 0, meaning will be destroyed + # next, _destroyed = true also ensures that any + # remaining callback won't do anything + # + Application._application = None + Application._condVar.release() if Application._communicator: try: @@ -706,12 +706,12 @@ class Application(object): Application._communicator = None - # - # Set _ctrlCHandler to 0 only once communicator.destroy() has - # completed. - # - Application._ctrlCHandler.destroy() - Application._ctrlCHandler = None + # + # Set _ctrlCHandler to 0 only once communicator.destroy() has + # completed. + # + Application._ctrlCHandler.destroy() + Application._ctrlCHandler = None return status @@ -719,7 +719,7 @@ class Application(object): raise RuntimeError('run() not implemented') def interruptCallback(self, sig): - pass + pass def appName(self): return self._appName @@ -734,7 +734,7 @@ class Application(object): if self._ctrlCHandler.getCallback() == self.holdInterruptCallback: self._released = True self._condVar.notify() - self._ctrlCHandler.setCallback(self.destroyOnInterruptCallback) + self._ctrlCHandler.setCallback(self.destroyOnInterruptCallback) self._condVar.release() destroyOnInterrupt = classmethod(destroyOnInterrupt) @@ -743,7 +743,7 @@ class Application(object): if self._ctrlCHandler.getCallback() == self.holdInterruptCallback: self._released = True self._condVar.notify() - self._ctrlCHandler.setCallback(self.shutdownOnInterruptCallback) + self._ctrlCHandler.setCallback(self.shutdownOnInterruptCallback) self._condVar.release() shutdownOnInterrupt = classmethod(shutdownOnInterrupt) @@ -752,7 +752,7 @@ class Application(object): if self._ctrlCHandler.getCallback() == self.holdInterruptCallback: self._released = True self._condVar.notify() - self._ctrlCHandler.setCallback(None) + self._ctrlCHandler.setCallback(None) self._condVar.release() ignoreInterrupt = classmethod(ignoreInterrupt) @@ -761,7 +761,7 @@ class Application(object): if self._ctrlCHandler.getCallback() == self.holdInterruptCallback: self._released = True self._condVar.notify() - self._ctrlCHandler.setCallback(self.callbackOnInterruptCallback) + self._ctrlCHandler.setCallback(self.callbackOnInterruptCallback) self._condVar.release() callbackOnInterrupt = classmethod(callbackOnInterrupt) @@ -802,30 +802,30 @@ class Application(object): self._condVar.acquire() while not self._released: self._condVar.wait() - if self._destroyed: - # - # Being destroyed by main thread - # - self._condVar.release() - return - callback = self._ctrlCHandler.getCallback() + if self._destroyed: + # + # Being destroyed by main thread + # + self._condVar.release() + return + callback = self._ctrlCHandler.getCallback() self._condVar.release() - if callback: - callback(sig) + if callback: + callback(sig) holdInterruptCallback = classmethod(holdInterruptCallback) def destroyOnInterruptCallback(self, sig): self._condVar.acquire() - if self._destroyed or self._nohup and sig == signal.SIGHUP: - # - # Being destroyed by main thread, or nohup. - # - self._condVar.release() - return - - self._callbackInProcess = True + if self._destroyed or self._nohup and sig == signal.SIGHUP: + # + # Being destroyed by main thread, or nohup. + # + self._condVar.release() + return + + self._callbackInProcess = True self._interrupted = True - self._destroyed = True + self._destroyed = True self._condVar.release() try: @@ -835,21 +835,21 @@ class Application(object): traceback.print_exc() self._condVar.acquire() - self._callbackInProcess = False + self._callbackInProcess = False self._condVar.notify() self._condVar.release() destroyOnInterruptCallback = classmethod(destroyOnInterruptCallback) def shutdownOnInterruptCallback(self, sig): self._condVar.acquire() - if self._destroyed or self._nohup and sig == signal.SIGHUP: - # - # Being destroyed by main thread, or nohup. - # - self._condVar.release() - return - - self._callbackInProcess = True + if self._destroyed or self._nohup and sig == signal.SIGHUP: + # + # Being destroyed by main thread, or nohup. + # + self._condVar.release() + return + + self._callbackInProcess = True self._interrupted = True self._condVar.release() @@ -860,23 +860,23 @@ class Application(object): traceback.print_exc() self._condVar.acquire() - self._callbackInProcess = False + self._callbackInProcess = False self._condVar.notify() self._condVar.release() shutdownOnInterruptCallback = classmethod(shutdownOnInterruptCallback) def callbackOnInterruptCallback(self, sig): self._condVar.acquire() - if self._destroyed: - # - # Being destroyed by main thread. - # - self._condVar.release() - return - # For SIGHUP the user callback is always called. It can decide - # what to do. - - self._callbackInProcess = True + if self._destroyed: + # + # Being destroyed by main thread. + # + self._condVar.release() + return + # For SIGHUP the user callback is always called. It can decide + # what to do. + + self._callbackInProcess = True self._interrupted = True self._condVar.release() @@ -887,7 +887,7 @@ class Application(object): traceback.print_exc() self._condVar.acquire() - self._callbackInProcess = False + self._callbackInProcess = False self._condVar.notify() self._condVar.release() diff --git a/py/test/Ice/adapterDeactivation/AllTests.py b/py/test/Ice/adapterDeactivation/AllTests.py index c3f710815ae..d8d1015b099 100644 --- a/py/test/Ice/adapterDeactivation/AllTests.py +++ b/py/test/Ice/adapterDeactivation/AllTests.py @@ -32,8 +32,8 @@ def allTests(communicator): sys.stdout.flush() adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999") try: - communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998") - test(False) + communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998") + test(False) except Ice.LocalException: pass adapter.destroy() @@ -55,9 +55,9 @@ def allTests(communicator): print "testing whether server is gone... ", sys.stdout.flush() try: - obj.ice_ping() - test(False) + obj.ice_ping() + test(False) except Ice.LocalException: - print "ok" + print "ok" return obj diff --git a/py/test/Ice/adapterDeactivation/Client.py b/py/test/Ice/adapterDeactivation/Client.py index 7dc71fe4b4b..276ac66456c 100644 --- a/py/test/Ice/adapterDeactivation/Client.py +++ b/py/test/Ice/adapterDeactivation/Client.py @@ -26,7 +26,7 @@ import Test, AllTests class TestClient(Ice.Application): def run(self, args): - AllTests.allTests(self.communicator()) + AllTests.allTests(self.communicator()) return 0 app = TestClient() diff --git a/py/test/Ice/adapterDeactivation/Collocated.py b/py/test/Ice/adapterDeactivation/Collocated.py index cf1f6b1751b..10673221477 100644 --- a/py/test/Ice/adapterDeactivation/Collocated.py +++ b/py/test/Ice/adapterDeactivation/Collocated.py @@ -33,7 +33,7 @@ class TestServer(Ice.Application): adapter.addServantLocator(locator, "") adapter.activate() - AllTests.allTests(self.communicator()) + AllTests.allTests(self.communicator()) adapter.waitForDeactivate() return 0 diff --git a/py/test/Ice/adapterDeactivation/Server.py b/py/test/Ice/adapterDeactivation/Server.py index adaea8c1834..23e756c4c0c 100644 --- a/py/test/Ice/adapterDeactivation/Server.py +++ b/py/test/Ice/adapterDeactivation/Server.py @@ -26,7 +26,7 @@ import Test, TestI class TestServer(Ice.Application): def run(self, args): - self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000:udp") + self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000:udp") adapter = self.communicator().createObjectAdapter("TestAdapter") locator = TestI.ServantLocatorI() diff --git a/py/test/Ice/application/Client.py b/py/test/Ice/application/Client.py index 1bb86f5a958..52adb766674 100644 --- a/py/test/Ice/application/Client.py +++ b/py/test/Ice/application/Client.py @@ -12,46 +12,46 @@ import sys, Ice, time class Client(Ice.Application): def interruptCallback(self, sig): - print "handling signal " + str(sig) + print "handling signal " + str(sig) # SIGINT interrupts time.sleep so a custom method is needed to # sleep for a given interval. def sleep(self, interval): - start = time.time() - while True: - sleepTime = (start + interval) - time.time() - if sleepTime <= 0: - break - time.sleep(sleepTime) + start = time.time() + while True: + sleepTime = (start + interval) - time.time() + if sleepTime <= 0: + break + time.sleep(sleepTime) def run(self, args): - self.ignoreInterrupt() - print "Ignore CTRL+C and the like for 5 seconds (try it!)" - self.sleep(5) + self.ignoreInterrupt() + print "Ignore CTRL+C and the like for 5 seconds (try it!)" + self.sleep(5) - self.callbackOnInterrupt() + self.callbackOnInterrupt() - self.holdInterrupt() - print "Hold CTRL+C and the like for 5 seconds (try it!)" - self.sleep(5) + self.holdInterrupt() + print "Hold CTRL+C and the like for 5 seconds (try it!)" + self.sleep(5) - self.releaseInterrupt() - print "Release CTRL+C (any held signals should be released)" - self.sleep(5) + self.releaseInterrupt() + print "Release CTRL+C (any held signals should be released)" + self.sleep(5) - self.holdInterrupt() - print "Hold CTRL+C and the like for 5 seconds (try it!)" - self.sleep(5) + self.holdInterrupt() + print "Hold CTRL+C and the like for 5 seconds (try it!)" + self.sleep(5) - self.callbackOnInterrupt() - print "Release CTRL+C (any held signals should be released)" - self.sleep(5) + self.callbackOnInterrupt() + print "Release CTRL+C (any held signals should be released)" + self.sleep(5) - self.shutdownOnInterrupt() - print "Test shutdown on destroy. Press CTRL+C to shutdown & terminate" - self.communicator().waitForShutdown() + self.shutdownOnInterrupt() + print "Test shutdown on destroy. Press CTRL+C to shutdown & terminate" + self.communicator().waitForShutdown() - print "ok" + print "ok" return False app = Client() diff --git a/py/test/Ice/binding/AllTests.py b/py/test/Ice/binding/AllTests.py index 8c9bb59dbd4..6ad592646cc 100644 --- a/py/test/Ice/binding/AllTests.py +++ b/py/test/Ice/binding/AllTests.py @@ -49,14 +49,14 @@ def createTestIntfPrx(adapters): endpoints = [] test = None for p in adapters: - test = p.getTestIntf() - edpts = test.ice_getEndpoints() - endpoints.extend(edpts) + test = p.getTestIntf() + edpts = test.ice_getEndpoints() + endpoints.extend(edpts) return Test.TestIntfPrx.uncheckedCast(test.ice_endpoints(endpoints)) def deactivate(com, adapters): for p in adapters: - com.deactivateObjectAdapter(p) + com.deactivateObjectAdapter(p) def allTests(communicator): ref = "communicator:default -p 12010 -t 10000" @@ -80,10 +80,10 @@ def allTests(communicator): test(test3.ice_getConnection() == test2.ice_getConnection()) try: - test3.ice_ping() - test(False) + test3.ice_ping() + test(False) except Ice.ConnectionRefusedException: - pass + pass print "ok" @@ -100,21 +100,21 @@ def allTests(communicator): # names = ["Adapter11", "Adapter12", "Adapter13"] while len(names) > 0: - adpts = adapters[:] + adpts = adapters[:] - test1 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test2 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test3 = createTestIntfPrx(adpts) + test1 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test2 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test3 = createTestIntfPrx(adpts) - test(test1.ice_getConnection() == test2.ice_getConnection()) - test(test2.ice_getConnection() == test3.ice_getConnection()) + test(test1.ice_getConnection() == test2.ice_getConnection()) + test(test2.ice_getConnection() == test3.ice_getConnection()) - name = test1.getAdapterName() - if names.count(name) > 0: - names.remove(name) - test1.ice_getConnection().close(False) + name = test1.getAdapterName() + if names.count(name) > 0: + names.remove(name) + test1.ice_getConnection().close(False) # # Ensure that the proxy correctly caches the connection (we @@ -128,7 +128,7 @@ def allTests(communicator): i = 0 nRetry = 5 while i < nRetry and t.getAdapterName() == name: - i = i + 1 + i = i + 1 test(i == nRetry) for a in adapters: @@ -142,21 +142,21 @@ def allTests(communicator): names.append("Adapter12") names.append("Adapter13") while len(names) > 0: - adpts = adapters[:] + adpts = adapters[:] - test1 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test2 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test3 = createTestIntfPrx(adpts) + test1 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test2 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test3 = createTestIntfPrx(adpts) - test(test1.ice_getConnection() == test2.ice_getConnection()) - test(test2.ice_getConnection() == test3.ice_getConnection()) + test(test1.ice_getConnection() == test2.ice_getConnection()) + test(test2.ice_getConnection() == test3.ice_getConnection()) - name = test1.getAdapterName() - if names.count(name) > 0: - names.remove(name) - test1.ice_getConnection().close(False) + name = test1.getAdapterName() + if names.count(name) > 0: + names.remove(name) + test1.ice_getConnection().close(False) # # Deactivate an adapter and ensure that we can still @@ -183,21 +183,21 @@ def allTests(communicator): # names = ["AdapterAMI11", "AdapterAMI12", "AdapterAMI13"] while len(names) > 0: - adpts = adapters[:] + adpts = adapters[:] - test1 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test2 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test3 = createTestIntfPrx(adpts) + test1 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test2 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test3 = createTestIntfPrx(adpts) - test(test1.ice_getConnection() == test2.ice_getConnection()) - test(test2.ice_getConnection() == test3.ice_getConnection()) + test(test1.ice_getConnection() == test2.ice_getConnection()) + test(test2.ice_getConnection() == test3.ice_getConnection()) - name = getAdapterNameWithAMI(test1) - if names.count(name) > 0: - names.remove(name) - test1.ice_getConnection().close(False) + name = getAdapterNameWithAMI(test1) + if names.count(name) > 0: + names.remove(name) + test1.ice_getConnection().close(False) # # Ensure that the proxy correctly caches the connection (we @@ -211,7 +211,7 @@ def allTests(communicator): i = 0 nRetry = 5 while i < nRetry and getAdapterNameWithAMI(t) == name: - i = i + 1 + i = i + 1 test(i == nRetry) for a in adapters: @@ -225,21 +225,21 @@ def allTests(communicator): names.append("AdapterAMI12") names.append("AdapterAMI13") while len(names) > 0: - adpts = adapters[:] + adpts = adapters[:] - test1 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test2 = createTestIntfPrx(adpts) - random.shuffle(adpts) - test3 = createTestIntfPrx(adpts) + test1 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test2 = createTestIntfPrx(adpts) + random.shuffle(adpts) + test3 = createTestIntfPrx(adpts) - test(test1.ice_getConnection() == test2.ice_getConnection()) - test(test2.ice_getConnection() == test3.ice_getConnection()) + test(test1.ice_getConnection() == test2.ice_getConnection()) + test(test2.ice_getConnection() == test3.ice_getConnection()) - name = getAdapterNameWithAMI(test1) - if names.count(name) > 0: - names.remove(name) - test1.ice_getConnection().close(False) + name = getAdapterNameWithAMI(test1) + if names.count(name) > 0: + names.remove(name) + test1.ice_getConnection().close(False) # # Deactivate an adapter and ensure that we can still @@ -265,10 +265,10 @@ def allTests(communicator): names = ["Adapter21", "Adapter22", "Adapter23"] while len(names) > 0: - name = t.getAdapterName() - if names.count(name) > 0: - names.remove(name) - t.ice_getConnection().close(False) + name = t.getAdapterName() + if names.count(name) > 0: + names.remove(name) + t.ice_getConnection().close(False) t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random)) test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random) @@ -277,10 +277,10 @@ def allTests(communicator): names.append("Adapter22") names.append("Adapter23") while len(names) > 0: - name = t.getAdapterName() - if names.count(name) > 0: - names.remove(name) - t.ice_getConnection().close(False) + name = t.getAdapterName() + if names.count(name) > 0: + names.remove(name) + t.ice_getConnection().close(False) deactivate(com, adapters) @@ -304,24 +304,24 @@ def allTests(communicator): # i = 0 while i < nRetry and t.getAdapterName() == "Adapter31": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[0]) i = 0 while i < nRetry and t.getAdapterName() == "Adapter32": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[1]) i = 0 while i < nRetry and t.getAdapterName() == "Adapter33": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[2]) try: - t.getAdapterName() + t.getAdapterName() except Ice.ConnectionRefusedException: - pass + pass endpoints = t.ice_getEndpoints() @@ -334,19 +334,19 @@ def allTests(communicator): adapters.append(com.createObjectAdapter("Adapter36", endpoints[2].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter36": - i = i + 1 + i = i + 1 test(i == nRetry) t.ice_getConnection().close(True) adapters.append(com.createObjectAdapter("Adapter35", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter35": - i = i + 1 + i = i + 1 test(i == nRetry) t.ice_getConnection().close(True) adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter34": - i = i + 1 + i = i + 1 test(i == nRetry) deactivate(com, adapters) @@ -369,10 +369,10 @@ def allTests(communicator): test3 = Test.TestIntfPrx.uncheckedCast(test1) try: - test(test3.ice_getConnection() == test1.ice_getConnection()) - test(False) + test(test3.ice_getConnection() == test1.ice_getConnection()) + test(False) except Ice.ConnectionRefusedException: - pass + pass print "ok" @@ -388,18 +388,18 @@ def allTests(communicator): names = ["Adapter51", "Adapter52", "Adapter53"] while len(names) > 0: - name = t.getAdapterName() - if names.count(name) > 0: - names.remove(name) + name = t.getAdapterName() + if names.count(name) > 0: + names.remove(name) com.deactivateObjectAdapter(adapters[0]) names.append("Adapter52") names.append("Adapter53") while len(names) > 0: - name = t.getAdapterName() - if names.count(name) > 0: - names.remove(name) + name = t.getAdapterName() + if names.count(name) > 0: + names.remove(name) com.deactivateObjectAdapter(adapters[2]) @@ -421,18 +421,18 @@ def allTests(communicator): names = ["AdapterAMI51", "AdapterAMI52", "AdapterAMI53"] while len(names) > 0: - name = getAdapterNameWithAMI(t) - if names.count(name) > 0: - names.remove(name) + name = getAdapterNameWithAMI(t) + if names.count(name) > 0: + names.remove(name) com.deactivateObjectAdapter(adapters[0]) names.append("AdapterAMI52") names.append("AdapterAMI53") while len(names) > 0: - name = getAdapterNameWithAMI(t) - if names.count(name) > 0: - names.remove(name) + name = getAdapterNameWithAMI(t) + if names.count(name) > 0: + names.remove(name) com.deactivateObjectAdapter(adapters[2]) @@ -462,24 +462,24 @@ def allTests(communicator): # i = 0 while i < nRetry and t.getAdapterName() == "Adapter61": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[0]) i = 0 while i < nRetry and t.getAdapterName() == "Adapter62": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[1]) i = 0 while i < nRetry and t.getAdapterName() == "Adapter63": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[2]) try: - t.getAdapterName() + t.getAdapterName() except Ice.ConnectionRefusedException: - pass + pass endpoints = t.ice_getEndpoints() @@ -492,17 +492,17 @@ def allTests(communicator): adapters.append(com.createObjectAdapter("Adapter66", endpoints[2].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter66": - i = i + 1 + i = i + 1 test(i == nRetry) adapters.append(com.createObjectAdapter("Adapter65", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter65": - i = i + 1 + i = i + 1 test(i == nRetry) adapters.append(com.createObjectAdapter("Adapter64", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter64": - i = i + 1 + i = i + 1 test(i == nRetry) deactivate(com, adapters) @@ -529,24 +529,24 @@ def allTests(communicator): # i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI61": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[0]) i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI62": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[1]) i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI63": - i = i + 1 + i = i + 1 test(i == nRetry) com.deactivateObjectAdapter(adapters[2]) try: - t.getAdapterName() + t.getAdapterName() except Ice.ConnectionRefusedException: - pass + pass endpoints = t.ice_getEndpoints() @@ -559,17 +559,17 @@ def allTests(communicator): adapters.append(com.createObjectAdapter("AdapterAMI66", endpoints[2].toString())) i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI66": - i = i + 1 + i = i + 1 test(i == nRetry) adapters.append(com.createObjectAdapter("AdapterAMI65", endpoints[1].toString())) i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI65": - i = i + 1 + i = i + 1 test(i == nRetry) adapters.append(com.createObjectAdapter("AdapterAMI64", endpoints[0].toString())) i = 0 while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI64": - i = i + 1 + i = i + 1 test(i == nRetry) deactivate(com, adapters) @@ -588,53 +588,53 @@ def allTests(communicator): testUDP = Test.TestIntfPrx.uncheckedCast(t.ice_datagram()) test(t.ice_getConnection() != testUDP.ice_getConnection()) try: - testUDP.getAdapterName() + testUDP.getAdapterName() except Ice.TwowayOnlyException: - pass + pass print "ok" if(len(communicator.getProperties().getProperty("Ice.Plugin.IceSSL")) > 0): - print "testing unsecure vs. secure endpoints...", - - adapters = [] - adapters.append(com.createObjectAdapter("Adapter81", "ssl")) - adapters.append(com.createObjectAdapter("Adapter82", "tcp")) - - t = createTestIntfPrx(adapters) - for i in range(0, 5): - test(t.getAdapterName() == "Adapter82") - t.ice_getConnection().close(False) - - testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) - test(testSecure.ice_isSecure()) + print "testing unsecure vs. secure endpoints...", + + adapters = [] + adapters.append(com.createObjectAdapter("Adapter81", "ssl")) + adapters.append(com.createObjectAdapter("Adapter82", "tcp")) + + t = createTestIntfPrx(adapters) + for i in range(0, 5): + test(t.getAdapterName() == "Adapter82") + t.ice_getConnection().close(False) + + testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) + test(testSecure.ice_isSecure()) testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(False)) test(not testSecure.ice_isSecure()) - testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) - test(testSecure.ice_isSecure()) - test(t.ice_getConnection() != testSecure.ice_getConnection()) + testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) + test(testSecure.ice_isSecure()) + test(t.ice_getConnection() != testSecure.ice_getConnection()) - com.deactivateObjectAdapter(adapters[1]) + com.deactivateObjectAdapter(adapters[1]) - for i in range(0, 5): - test(t.getAdapterName() == "Adapter81") - t.ice_getConnection().close(False) + for i in range(0, 5): + test(t.getAdapterName() == "Adapter81") + t.ice_getConnection().close(False) - 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") - t.ice_getConnection().close(False) + for i in range(0, 5): + test(t.getAdapterName() == "Adapter83") + t.ice_getConnection().close(False) - com.deactivateObjectAdapter(adapters[0]) - try: - testSecure.ice_ping() - test(False) - except Ice.ConnectionRefusedException: - pass + com.deactivateObjectAdapter(adapters[0]) + try: + testSecure.ice_ping() + test(False) + except Ice.ConnectionRefusedException: + pass - deactivate(com, adapters) + deactivate(com, adapters) - print "ok" + print "ok" com.shutdown() diff --git a/py/test/Ice/binding/TestI.py b/py/test/Ice/binding/TestI.py index f121d01374a..d74c8285474 100644 --- a/py/test/Ice/binding/TestI.py +++ b/py/test/Ice/binding/TestI.py @@ -12,11 +12,11 @@ import Ice, Test class RemoteCommunicatorI(Test.RemoteCommunicator): def createObjectAdapter(self, name, endpoints, current=None): - com = current.adapter.getCommunicator() + com = current.adapter.getCommunicator() if com.getProperties().getPropertyAsIntWithDefault("Ice.ThreadPerConnection", 0) == 0: com.getProperties().setProperty("Ice.OA." + name + ".ThreadPool.Size", "1") - adapter = com.createObjectAdapterWithEndpoints(name, endpoints) - return Test.RemoteObjectAdapterPrx.uncheckedCast(current.adapter.addWithUUID(RemoteObjectAdapterI(adapter))) + adapter = com.createObjectAdapterWithEndpoints(name, endpoints) + return Test.RemoteObjectAdapterPrx.uncheckedCast(current.adapter.addWithUUID(RemoteObjectAdapterI(adapter))) def deactivateObjectAdapter(self, adapter, current=None): adapter.deactivate() @@ -26,19 +26,19 @@ class RemoteCommunicatorI(Test.RemoteCommunicator): class RemoteObjectAdapterI(Test.RemoteObjectAdapter): def __init__(self, adapter): - self._adapter = adapter - self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), adapter.getCommunicator().stringToIdentity("test"))) - self._adapter.activate() + self._adapter = adapter + self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), adapter.getCommunicator().stringToIdentity("test"))) + self._adapter.activate() def getTestIntf(self, current=None): - return self._testIntf + return self._testIntf def deactivate(self, current=None): - try: - self._adapter.destroy() - except Ice.ObjectAdapterDeactivatedException: - pass + try: + self._adapter.destroy() + except Ice.ObjectAdapterDeactivatedException: + pass class TestI(Test.TestIntf): def getAdapterName(self, current=None): - return current.adapter.getName() + return current.adapter.getName() diff --git a/py/test/Ice/custom/AllTests.py b/py/test/Ice/custom/AllTests.py index 651fb1fcf45..ea36daaad03 100644 --- a/py/test/Ice/custom/AllTests.py +++ b/py/test/Ice/custom/AllTests.py @@ -38,22 +38,22 @@ def allTests(communicator): test(isinstance(r, tuple)) test(isinstance(b2, list)) for i in range(0, len(byteList)): - test(r[i] == byteList[i]) - test(b2[i] == byteList[i]) + test(r[i] == byteList[i]) + test(b2[i] == byteList[i]) (r, b2) = custom.opByteList1(byteList) test(isinstance(r, list)) test(isinstance(b2, list)) for i in range(0, len(byteList)): - test(r[i] == byteList[i]) - test(b2[i] == byteList[i]) + test(r[i] == byteList[i]) + test(b2[i] == byteList[i]) (r, b2) = custom.opByteList2(byteList) test(isinstance(r, str)) test(isinstance(b2, tuple)) test(r == byteString) for i in range(0, len(byteList)): - test(b2[i] == byteList[i]) + test(b2[i] == byteList[i]) (r, b2) = custom.opStringList1(stringList) test(isinstance(r, list)) @@ -65,15 +65,15 @@ def allTests(communicator): test(isinstance(r, tuple)) test(isinstance(b2, tuple)) for i in range(0, len(stringList)): - test(r[i] == stringList[i]) - test(b2[i] == stringList[i]) + test(r[i] == stringList[i]) + test(b2[i] == stringList[i]) (r, b2) = custom.opStringTuple1(stringList) test(isinstance(r, tuple)) test(isinstance(b2, tuple)) for i in range(0, len(stringList)): - test(r[i] == stringList[i]) - test(b2[i] == stringList[i]) + test(r[i] == stringList[i]) + test(b2[i] == stringList[i]) (r, b2) = custom.opStringTuple2(stringList) test(isinstance(r, list)) diff --git a/py/test/Ice/custom/Server.py b/py/test/Ice/custom/Server.py index ce8fd72c656..b995b0b566a 100644 --- a/py/test/Ice/custom/Server.py +++ b/py/test/Ice/custom/Server.py @@ -33,56 +33,56 @@ class CustomI(Test.Custom): self._adapter = adapter def opByteString1(self, b1, current=None): - test(isinstance(b1, str)) - return (b1, b1) + test(isinstance(b1, str)) + return (b1, b1) def opByteString2(self, b1, current=None): - test(isinstance(b1, list)) - return (b1, b1) + test(isinstance(b1, list)) + return (b1, b1) def opByteList1(self, b1, current=None): - test(isinstance(b1, list)) - return (b1, b1) + test(isinstance(b1, list)) + return (b1, b1) def opByteList2(self, b1, current=None): - test(isinstance(b1, tuple)) - return (b1, b1) + test(isinstance(b1, tuple)) + return (b1, b1) def opStringList1(self, s1, current=None): - test(isinstance(s1, list)) - return (s1, s1) + test(isinstance(s1, list)) + return (s1, s1) def opStringList2(self, s1, current=None): - test(isinstance(s1, tuple)) - return (s1, s1) + test(isinstance(s1, tuple)) + return (s1, s1) def opStringTuple1(self, s1, current=None): - test(isinstance(s1, tuple)) - return (s1, s1) + test(isinstance(s1, tuple)) + return (s1, s1) def opStringTuple2(self, s1, current=None): - test(isinstance(s1, list)) - return (s1, s1) + test(isinstance(s1, list)) + return (s1, s1) def sendS(self, val, current=None): - test(isinstance(val.b1, str)) - test(isinstance(val.b2, list)) - test(isinstance(val.b3, str)) - test(isinstance(val.b4, list)) - test(isinstance(val.s1, list)) - test(isinstance(val.s2, tuple)) - test(isinstance(val.s3, tuple)) - test(isinstance(val.s4, list)) + test(isinstance(val.b1, str)) + test(isinstance(val.b2, list)) + test(isinstance(val.b3, str)) + test(isinstance(val.b4, list)) + test(isinstance(val.s1, list)) + test(isinstance(val.s2, tuple)) + test(isinstance(val.s3, tuple)) + test(isinstance(val.s4, list)) def sendC(self, val, current=None): - test(isinstance(val.b1, str)) - test(isinstance(val.b2, list)) - test(isinstance(val.b3, str)) - test(isinstance(val.b4, list)) - test(isinstance(val.s1, list)) - test(isinstance(val.s2, tuple)) - test(isinstance(val.s3, tuple)) - test(isinstance(val.s4, list)) + test(isinstance(val.b1, str)) + test(isinstance(val.b2, list)) + test(isinstance(val.b3, str)) + test(isinstance(val.b4, list)) + test(isinstance(val.s1, list)) + test(isinstance(val.s2, tuple)) + test(isinstance(val.s3, tuple)) + test(isinstance(val.s4, list)) def shutdown(self, current=None): self._adapter.getCommunicator().shutdown() diff --git a/py/test/Ice/custom/Test.ice b/py/test/Ice/custom/Test.ice index c31414f188b..a3fbf3e700a 100644 --- a/py/test/Ice/custom/Test.ice +++ b/py/test/Ice/custom/Test.ice @@ -20,50 +20,50 @@ module Test struct S { - ByteString b1; - ["python:seq:list"] ByteString b2; - ["python:seq:default"] ByteList b3; - ByteList b4; - StringList s1; - ["python:seq:tuple"] StringList s2; - StringTuple s3; - ["python:seq:default"] StringTuple s4; + ByteString b1; + ["python:seq:list"] ByteString b2; + ["python:seq:default"] ByteList b3; + ByteList b4; + StringList s1; + ["python:seq:tuple"] StringList s2; + StringTuple s3; + ["python:seq:default"] StringTuple s4; }; class C { - ByteString b1; - ["python:seq:list"] ByteString b2; - ["python:seq:default"] ByteList b3; - ByteList b4; - StringList s1; - ["python:seq:tuple"] StringList s2; - StringTuple s3; - ["python:seq:default"] StringTuple s4; + ByteString b1; + ["python:seq:list"] ByteString b2; + ["python:seq:default"] ByteList b3; + ByteList b4; + StringList s1; + ["python:seq:tuple"] StringList s2; + StringTuple s3; + ["python:seq:default"] StringTuple s4; }; interface Custom { - ByteString opByteString1(ByteString b1, out ByteString b2); - ["python:seq:tuple"] ByteString opByteString2(["python:seq:list"] ByteString b1, - out ["python:seq:list"] ByteString b2); + ByteString opByteString1(ByteString b1, out ByteString b2); + ["python:seq:tuple"] ByteString opByteString2(["python:seq:list"] ByteString b1, + out ["python:seq:list"] ByteString b2); - ByteList opByteList1(ByteList b1, out ByteList b2); - ["python:seq:default"] ByteList opByteList2(["python:seq:tuple"] ByteList b1, - out ["python:seq:tuple"] ByteList b2); + ByteList opByteList1(ByteList b1, out ByteList b2); + ["python:seq:default"] ByteList opByteList2(["python:seq:tuple"] ByteList b1, + out ["python:seq:tuple"] ByteList b2); - StringList opStringList1(StringList s1, out StringList s2); - ["python:seq:tuple"] StringList opStringList2(["python:seq:tuple"] StringList s1, - out ["python:seq:tuple"] StringList s2); + StringList opStringList1(StringList s1, out StringList s2); + ["python:seq:tuple"] StringList opStringList2(["python:seq:tuple"] StringList s1, + out ["python:seq:tuple"] StringList s2); - StringTuple opStringTuple1(StringTuple s1, out StringTuple s2); - ["python:seq:list"] StringTuple opStringTuple2(["python:seq:list"] StringTuple s1, - out ["python:seq:default"] StringTuple s2); + StringTuple opStringTuple1(StringTuple s1, out StringTuple s2); + ["python:seq:list"] StringTuple opStringTuple2(["python:seq:list"] StringTuple s1, + out ["python:seq:default"] StringTuple s2); - void sendS(S val); - void sendC(C val); + void sendS(S val); + void sendC(C val); - void shutdown(); + void shutdown(); }; }; diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py index c3ae7cd7487..d4947952ab5 100644 --- a/py/test/Ice/exceptions/AllTests.py +++ b/py/test/Ice/exceptions/AllTests.py @@ -295,14 +295,14 @@ def allTests(communicator): adapter.add(obj, communicator.stringToIdentity("x")) try: adapter.add(obj, communicator.stringToIdentity("x")) - test(false) + test(false) except Ice.AlreadyRegisteredException: pass adapter.remove(communicator.stringToIdentity("x")) try: adapter.remove(communicator.stringToIdentity("x")) - test(false) + test(false) except Ice.NotRegisteredException: pass @@ -316,7 +316,7 @@ def allTests(communicator): adapter.addServantLocator(loc, "x") try: adapter.addServantLocator(loc, "x") - test(false) + test(false) except Ice.AlreadyRegisteredException: pass @@ -328,7 +328,7 @@ def allTests(communicator): communicator.addObjectFactory(of, "x") try: communicator.addObjectFactory(of, "x") - test(false) + test(false) except Ice.AlreadyRegisteredException: pass print "ok" diff --git a/py/test/Ice/exceptions/Test.ice b/py/test/Ice/exceptions/Test.ice index 0844993df14..296d76f7005 100644 --- a/py/test/Ice/exceptions/Test.ice +++ b/py/test/Ice/exceptions/Test.ice @@ -43,7 +43,7 @@ module Mod { exception A extends ::Test::A { - int a2Mem; + int a2Mem; }; }; diff --git a/py/test/Ice/exceptions/TestAMD.ice b/py/test/Ice/exceptions/TestAMD.ice index a3efb41c18e..9c0eb3ad93b 100644 --- a/py/test/Ice/exceptions/TestAMD.ice +++ b/py/test/Ice/exceptions/TestAMD.ice @@ -39,7 +39,7 @@ module Mod { exception A extends ::Test::A { - int a2Mem; + int a2Mem; }; }; diff --git a/py/test/Ice/facets/AllTests.py b/py/test/Ice/facets/AllTests.py index 8ba5e6fd3a9..3a2ed91360e 100644 --- a/py/test/Ice/facets/AllTests.py +++ b/py/test/Ice/facets/AllTests.py @@ -26,13 +26,13 @@ def allTests(communicator): adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD") try: adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD") - test(false) + test(false) except Ice.AlreadyRegisteredException: pass adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD") try: adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD") - test(false) + test(false) except Ice.NotRegisteredException: pass print "ok" @@ -52,7 +52,7 @@ def allTests(communicator): test(fm["f2"] == obj2) try: adapter.removeAllFacets(communicator.stringToIdentity("id1")) - test(false) + test(false) except Ice.NotRegisteredException: pass fm = adapter.removeAllFacets(communicator.stringToIdentity("id2")) diff --git a/py/test/Ice/faultTolerance/run.py b/py/test/Ice/faultTolerance/run.py index c309229ad5a..58712327666 100755 --- a/py/test/Ice/faultTolerance/run.py +++ b/py/test/Ice/faultTolerance/run.py @@ -37,7 +37,7 @@ for i in range(0, num): sys.stdout.flush() command = "python " + server + TestUtil.serverOptions + " %d" % (base + i) if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", serverPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(serverPipe) TestUtil.getAdapterReady(serverPipe) diff --git a/py/test/Ice/location/AllTests.py b/py/test/Ice/location/AllTests.py index 37b7e9ab826..92afa97cf22 100644 --- a/py/test/Ice/location/AllTests.py +++ b/py/test/Ice/location/AllTests.py @@ -40,7 +40,7 @@ def allTests(communicator, ref): communicator.setDefaultLocator(locator); base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())); - + # # We also test ice_router/ice_getRouter (perhaps we should add a # test/Ice/router test?) @@ -82,87 +82,87 @@ def allTests(communicator, ref): obj.shutdown() manager.startServer() try: - obj2 = Test.TestIntfPrx.checkedCast(base2) - obj2.ice_ping() + obj2 = Test.TestIntfPrx.checkedCast(base2) + obj2.ice_ping() except Ice.LocalException: - test(False) + test(False) print "ok" print "testing identity indirect proxy...", obj.shutdown() manager.startServer() try: - obj3 = Test.TestIntfPrx.checkedCast(base3) - obj3.ice_ping() + obj3 = Test.TestIntfPrx.checkedCast(base3) + obj3.ice_ping() except Ice.LocalException: - test(False) + test(False) try: - obj2 = Test.TestIntfPrx.checkedCast(base2) - obj2.ice_ping() + obj2 = Test.TestIntfPrx.checkedCast(base2) + obj2.ice_ping() except Ice.LocalException: - test(False) + test(False) obj.shutdown() manager.startServer() try: - obj2 = Test.TestIntfPrx.checkedCast(base2) - obj2.ice_ping() + obj2 = Test.TestIntfPrx.checkedCast(base2) + obj2.ice_ping() except Ice.LocalException: - test(False) + test(False) try: - obj3 = Test.TestIntfPrx.checkedCast(base3) - obj3.ice_ping() + obj3 = Test.TestIntfPrx.checkedCast(base3) + obj3.ice_ping() except Ice.LocalException: - test(False) + test(False) obj.shutdown() manager.startServer() try: - obj2 = Test.TestIntfPrx.checkedCast(base2) - obj2.ice_ping() + obj2 = Test.TestIntfPrx.checkedCast(base2) + obj2.ice_ping() except Ice.LocalException: - test(False) + test(False) obj.shutdown() manager.startServer() try: - obj3 = Test.TestIntfPrx.checkedCast(base3) - obj3.ice_ping() + obj3 = Test.TestIntfPrx.checkedCast(base3) + obj3.ice_ping() except Ice.LocalException: - test(False) + test(False) obj.shutdown() manager.startServer() try: - obj2 = Test.TestIntfPrx.checkedCast(base2) - obj2.ice_ping() + obj2 = Test.TestIntfPrx.checkedCast(base2) + obj2.ice_ping() except Ice.LocalException: - test(False) + test(False) obj.shutdown() manager.startServer() try: - obj5 = Test.TestIntfPrx.checkedCast(base5) - obj5.ice_ping() + obj5 = Test.TestIntfPrx.checkedCast(base5) + obj5.ice_ping() except Ice.LocalException: - test(False) + test(False) print "ok" print "testing reference with unknown identity...", try: - base = communicator.stringToProxy("unknown/unknown") - base.ice_ping() - test(False) + base = communicator.stringToProxy("unknown/unknown") + base.ice_ping() + test(False) except Ice.NotRegisteredException, ex: - test(ex.kindOfObject == "object") - test(ex.id == "unknown/unknown") + test(ex.kindOfObject == "object") + test(ex.id == "unknown/unknown") print "ok" print "testing reference with unknown adapter...", try: - base = communicator.stringToProxy("test @ TestAdapterUnknown") - base.ice_ping() - test(False) + base = communicator.stringToProxy("test @ TestAdapterUnknown") + base.ice_ping() + test(False) except Ice.NotRegisteredException, ex: - test(ex.kindOfObject == "object adapter") - test(ex.id == "TestAdapterUnknown") + test(ex.kindOfObject == "object adapter") + test(ex.id == "TestAdapterUnknown") print "ok" print "testing object reference from server...", @@ -192,20 +192,20 @@ def allTests(communicator, ref): print "testing whether server is gone...", try: - obj2.ice_ping() - test(False) + obj2.ice_ping() + test(False) except Ice.LocalException: - pass + pass try: - obj3.ice_ping() - test(False) + obj3.ice_ping() + test(False) except Ice.LocalException: - pass + pass try: - obj5.ice_ping() - test(False) + obj5.ice_ping() + test(False) except Ice.LocalException: - pass + pass print "ok" # diff --git a/py/test/Ice/location/Server.py b/py/test/Ice/location/Server.py index da62de3033a..c7e839fe9ef 100644 --- a/py/test/Ice/location/Server.py +++ b/py/test/Ice/location/Server.py @@ -42,14 +42,14 @@ class ServerLocatorRegistry(Ice.LocatorRegistry): def setAdapterDirectProxy_async(self, cb, adapter, obj, current=None): self._adapters[adapter] = obj - cb.ice_response() + cb.ice_response() def setReplicatedAdapterDirectProxy_async(self, cb, adapter, replica, obj, current=None): self._adapters[adapter] = obj - cb.ice_response() + cb.ice_response() def setServerProcessProxy_async(self, id, proxy, current=None): - cb.ice_response() + cb.ice_response() def addObject(self, obj, current=None): self._objects[obj.ice_getIdentity()] = obj @@ -82,7 +82,7 @@ class ServerLocator(Ice.Locator): class ServerManagerI(Test.ServerManager): def __init__(self, adapter, registry, initData): self._adapter = adapter - self._registry = registry + self._registry = registry self._communicators = [] self._initData = initData self._initData.properties.setProperty("Ice.OA.TestAdapter.Endpoints", "default") @@ -111,8 +111,8 @@ class ServerManagerI(Test.ServerManager): adapter2.setLocator(Ice.LocatorPrx.uncheckedCast(locator)) object = TestI(adapter, adapter2, self._registry) - self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test"))) - self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test2"))) + self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test"))) + self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test2"))) adapter.activate() adapter2.activate() @@ -140,11 +140,11 @@ class TestI(Test.TestIntf): return Test.HelloPrx.uncheckedCast(self._adapter1.createProxy(communicator.stringToIdentity("hello"))) def migrateHello(self, current=None): - id = communicator.stringToIdentity("hello") - try: - self._registry.addObject(self._adapter2.add(self._adapter1.remove(id), id)) - except Ice.NotRegisteredException: - self._registry.addObject(self._adapter1.add(self._adapter2.remove(id), id)) + id = communicator.stringToIdentity("hello") + try: + self._registry.addObject(self._adapter2.add(self._adapter1.remove(id), id)) + except Ice.NotRegisteredException: + self._registry.addObject(self._adapter1.add(self._adapter2.remove(id), id)) def run(args, communicator, initData): # diff --git a/py/test/Ice/objects/AllTests.py b/py/test/Ice/objects/AllTests.py index 73ca803f4fe..f98620ce6a5 100644 --- a/py/test/Ice/objects/AllTests.py +++ b/py/test/Ice/objects/AllTests.py @@ -133,24 +133,24 @@ def allTests(communicator, collocated): print "ok" if not collocated: - print "testing UnexpectedObjectException... " - ref = "uoet:default -p 12010 -t 10000" - base = communicator.stringToProxy(ref) - test(base) - uoet = Test.UnexpectedObjectExceptionTestPrx.uncheckedCast(base) - test(uoet) - try: - uoet.op() - test(False) - except Ice.UnexpectedObjectException, ex: - test(ex.type == "::Test::AlsoEmpty") - test(ex.expectedType == "::Test::Empty") - except Ice.Exception, ex: - print ex - test(False) - except: - print sys.exc_info() - test(False) - print "ok" + print "testing UnexpectedObjectException... " + ref = "uoet:default -p 12010 -t 10000" + base = communicator.stringToProxy(ref) + test(base) + uoet = Test.UnexpectedObjectExceptionTestPrx.uncheckedCast(base) + test(uoet) + try: + uoet.op() + test(False) + except Ice.UnexpectedObjectException, ex: + test(ex.type == "::Test::AlsoEmpty") + test(ex.expectedType == "::Test::Empty") + except Ice.Exception, ex: + print ex + test(False) + except: + print sys.exc_info() + test(False) + print "ok" return initial diff --git a/py/test/Ice/operations/ServerAMD.py b/py/test/Ice/operations/ServerAMD.py index 32609fe07f3..efedfc29c3a 100644 --- a/py/test/Ice/operations/ServerAMD.py +++ b/py/test/Ice/operations/ServerAMD.py @@ -97,7 +97,7 @@ class MyDerivedClassI(Test.MyDerivedClass): cb.ice_response(p2, p1) def opByteS_async(self, cb, p1, p2, current=None): - # By default sequence<byte> maps to a string. + # By default sequence<byte> maps to a string. p3 = map(ord, p1) p3.reverse() r = map(ord, p1) @@ -219,14 +219,14 @@ class MyDerivedClassI(Test.MyDerivedClass): class TestCheckedCastI(Test.TestCheckedCast): def __init__(self): - self.ctx = None + self.ctx = None def getContext(self, current): - return self.ctx; + return self.ctx; def ice_isA(self, s, current): - self.ctx = current.ctx - return Test.TestCheckedCast.ice_isA(self, s, current) + self.ctx = current.ctx + return Test.TestCheckedCast.ice_isA(self, s, current) def run(args, communicator): communicator.getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000:udp") diff --git a/py/test/Ice/operations/Test.ice b/py/test/Ice/operations/Test.ice index 9c5e2b5d905..625066059a9 100644 --- a/py/test/Ice/operations/Test.ice +++ b/py/test/Ice/operations/Test.ice @@ -73,75 +73,75 @@ dictionary<string, MyEnum> StringMyEnumD; void opVoid(); byte opByte(byte p1, byte p2, - out byte p3); + out byte p3); bool opBool(bool p1, bool p2, - out bool p3); + out bool p3); long opShortIntLong(short p1, int p2, long p3, - out short p4, out int p5, out long p6); + out short p4, out int p5, out long p6); double opFloatDouble(float p1, double p2, - out float p3, out double p4); + out float p3, out double p4); string opString(string p1, string p2, - out string p3); + out string p3); MyEnum opMyEnum(MyEnum p1, out MyEnum p2); MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3); Structure opStruct(Structure p1, Structure p2, - out Structure p3); + out Structure p3); ByteS opByteS(ByteS p1, ByteS p2, - out ByteS p3); + out ByteS p3); BoolS opBoolS(BoolS p1, BoolS p2, - out BoolS p3); + out BoolS p3); LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3, - out ::Test::ShortS p4, out IntS p5, out LongS p6); + out ::Test::ShortS p4, out IntS p5, out LongS p6); DoubleS opFloatDoubleS(FloatS p1, DoubleS p2, - out FloatS p3, out DoubleS p4); + out FloatS p3, out DoubleS p4); StringS opStringS(StringS p1, StringS p2, - out StringS p3); + out StringS p3); ByteSS opByteSS(ByteSS p1, ByteSS p2, - out ByteSS p3); + out ByteSS p3); BoolSS opBoolSS(BoolSS p1, BoolSS p2, - out BoolSS p3); + out BoolSS p3); LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3, - out ShortSS p4, out IntSS p5, out LongSS p6); + out ShortSS p4, out IntSS p5, out LongSS p6); DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2, - out FloatSS p3, out DoubleSS p4); + out FloatSS p3, out DoubleSS p4); StringSS opStringSS(StringSS p1, StringSS p2, - out StringSS p3); + out StringSS p3); StringSSS opStringSSS(StringSSS p1, StringSSS p2, - out StringSSS p3); + out StringSSS p3); ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2, - out ByteBoolD p3); + out ByteBoolD p3); ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2, - out ShortIntD p3); + out ShortIntD p3); LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2, - out LongFloatD p3); + out LongFloatD p3); StringStringD opStringStringD(StringStringD p1, StringStringD p2, - out StringStringD p3); + out StringStringD p3); StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2, - out StringMyEnumD p3); + out StringMyEnumD p3); IntS opIntS(IntS s); diff --git a/py/test/Ice/operations/TestAMD.ice b/py/test/Ice/operations/TestAMD.ice index 1cd8bc7ec0b..7d1b34a292b 100644 --- a/py/test/Ice/operations/TestAMD.ice +++ b/py/test/Ice/operations/TestAMD.ice @@ -71,75 +71,75 @@ dictionary<string, MyEnum> StringMyEnumD; void opVoid(); byte opByte(byte p1, byte p2, - out byte p3); + out byte p3); bool opBool(bool p1, bool p2, - out bool p3); + out bool p3); long opShortIntLong(short p1, int p2, long p3, - out short p4, out int p5, out long p6); + out short p4, out int p5, out long p6); double opFloatDouble(float p1, double p2, - out float p3, out double p4); + out float p3, out double p4); string opString(string p1, string p2, - out string p3); + out string p3); MyEnum opMyEnum(MyEnum p1, out MyEnum p2); MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3); Structure opStruct(Structure p1, Structure p2, - out Structure p3); + out Structure p3); ByteS opByteS(ByteS p1, ByteS p2, - out ByteS p3); + out ByteS p3); BoolS opBoolS(BoolS p1, BoolS p2, - out BoolS p3); + out BoolS p3); LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3, - out ::Test::ShortS p4, out IntS p5, out LongS p6); + out ::Test::ShortS p4, out IntS p5, out LongS p6); DoubleS opFloatDoubleS(FloatS p1, DoubleS p2, - out FloatS p3, out DoubleS p4); + out FloatS p3, out DoubleS p4); StringS opStringS(StringS p1, StringS p2, - out StringS p3); + out StringS p3); ByteSS opByteSS(ByteSS p1, ByteSS p2, - out ByteSS p3); + out ByteSS p3); BoolSS opBoolSS(BoolSS p1, BoolSS p2, - out BoolSS p3); + out BoolSS p3); LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3, - out ShortSS p4, out IntSS p5, out LongSS p6); + out ShortSS p4, out IntSS p5, out LongSS p6); DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2, - out FloatSS p3, out DoubleSS p4); + out FloatSS p3, out DoubleSS p4); StringSS opStringSS(StringSS p1, StringSS p2, - out StringSS p3); + out StringSS p3); StringSSS opStringSSS(StringSSS p1, StringSSS p2, - out StringSSS p3); + out StringSSS p3); ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2, - out ByteBoolD p3); + out ByteBoolD p3); ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2, - out ShortIntD p3); + out ShortIntD p3); LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2, - out LongFloatD p3); + out LongFloatD p3); StringStringD opStringStringD(StringStringD p1, StringStringD p2, - out StringStringD p3); + out StringStringD p3); StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2, - out StringMyEnumD p3); + out StringMyEnumD p3); IntS opIntS(IntS s); diff --git a/py/test/Ice/operations/TestI.py b/py/test/Ice/operations/TestI.py index 5c1a43b42b6..b7462097a14 100644 --- a/py/test/Ice/operations/TestI.py +++ b/py/test/Ice/operations/TestI.py @@ -48,7 +48,7 @@ class MyDerivedClassI(Test.MyDerivedClass): return (p2, p1) def opByteS(self, p1, p2, current=None): - # By default sequence<byte> maps to a string. + # By default sequence<byte> maps to a string. p3 = map(ord, p1) p3.reverse() r = map(ord, p1) @@ -170,11 +170,11 @@ class MyDerivedClassI(Test.MyDerivedClass): class TestCheckedCastI(Test.TestCheckedCast): def __init__(self): - self.ctx = None + self.ctx = None def getContext(self, current): - return self.ctx; + return self.ctx; def ice_isA(self, s, current): - self.ctx = current.ctx - return Test.TestCheckedCast.ice_isA(self, s, current) + self.ctx = current.ctx + return Test.TestCheckedCast.ice_isA(self, s, current) diff --git a/py/test/Ice/operations/Twoways.py b/py/test/Ice/operations/Twoways.py index 23ebae4032a..e18d79e8975 100644 --- a/py/test/Ice/operations/Twoways.py +++ b/py/test/Ice/operations/Twoways.py @@ -607,7 +607,7 @@ def twoways(communicator, p): ic = Ice.initialize(data=initData) ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'} - + p = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010 -t 10000")) ic.getImplicitContext().setContext(ctx) diff --git a/py/test/Ice/operations/TwowaysAMI.py b/py/test/Ice/operations/TwowaysAMI.py index 6f1f9b2a24e..3e7ab4535da 100644 --- a/py/test/Ice/operations/TwowaysAMI.py +++ b/py/test/Ice/operations/TwowaysAMI.py @@ -148,21 +148,21 @@ class AMI_MyClass_opMyEnumI(CallbackBase): class AMI_MyClass_opMyClassI(CallbackBase): def __init__(self, communicator): CallbackBase.__init__(self) - self._communicator = communicator + self._communicator = communicator def ice_response(self, r, c1, c2): test(c1.ice_getIdentity() == self._communicator.stringToIdentity("test")) test(c2.ice_getIdentity() == self._communicator.stringToIdentity("noSuchIdentity")) test(r.ice_getIdentity() == self._communicator.stringToIdentity("test")) - # We can't do the callbacks below in thread per connection mode. - if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPerConnection") == 0: - r.opVoid() - c1.opVoid() - try: - c2.opVoid() - test(False) - except Ice.ObjectNotExistException: - pass + # We can't do the callbacks below in thread per connection mode. + if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPerConnection") == 0: + r.opVoid() + c1.opVoid() + try: + c2.opVoid() + test(False) + except Ice.ObjectNotExistException: + pass self.called() def ice_exception(self, ex): @@ -180,9 +180,9 @@ class AMI_MyClass_opStructI(CallbackBase): test(rso.s.s == "def") test(so.e == Test.MyEnum.enum3) test(so.s.s == "a new string") - # We can't do the callbacks below in thread per connection mode. - if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPerConnection") == 0: - so.p.opVoid() + # We can't do the callbacks below in thread per connection mode. + if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPerConnection") == 0: + so.p.opVoid() self.called() def ice_exception(self, ex): @@ -527,9 +527,9 @@ def twowaysAMI(communicator, p): oneway = Test.MyClassPrx.uncheckedCast(p.ice_oneway()) cb = AMI_MyClass_opVoidExI() try: - oneway.opVoid_async(cb) + oneway.opVoid_async(cb) except Ice.Exception: - test(False) + test(False) test(cb.check()) # Check that a call to a twoway operation raises TwowayOnlyException @@ -537,9 +537,9 @@ def twowaysAMI(communicator, p): oneway = Test.MyClassPrx.uncheckedCast(p.ice_oneway()) cb = AMI_MyClass_opByteExI() try: - oneway.opByte_async(cb, 0, 0) + oneway.opByte_async(cb, 0, 0) except Ice.Exception: - test(False) + test(False) test(cb.check()) # @@ -867,7 +867,7 @@ def twowaysAMI(communicator, p): ic = Ice.initialize(data=initData) ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'} - + p = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010 -t 10000")) ic.getImplicitContext().setContext(ctx) diff --git a/py/test/Ice/retry/AllTests.py b/py/test/Ice/retry/AllTests.py index 05504f1e1a7..2e2d3762bb6 100644 --- a/py/test/Ice/retry/AllTests.py +++ b/py/test/Ice/retry/AllTests.py @@ -56,7 +56,7 @@ class AMIException(CallbackBase): test(False) def ice_exception(self, ex): - test(isinstance(ex, Ice.ConnectionLostException)) + test(isinstance(ex, Ice.ConnectionLostException)) self.called() def allTests(communicator): @@ -84,7 +84,7 @@ def allTests(communicator): print "calling operation to kill connection with second proxy...", try: retry2.op(True) - test(False) + test(False) except Ice.ConnectionLostException: print "ok" diff --git a/py/test/Ice/retry/TestI.py b/py/test/Ice/retry/TestI.py index d1c3e32fee4..c646ff9403f 100644 --- a/py/test/Ice/retry/TestI.py +++ b/py/test/Ice/retry/TestI.py @@ -13,8 +13,8 @@ import Ice, Test class RetryI(Test.Retry): def op(self, kill, current=None): - if kill: - current.con.close(True) + if kill: + current.con.close(True) def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/py/test/Ice/servantLocator/AllTests.py b/py/test/Ice/servantLocator/AllTests.py index 0fc07d1f4b4..44cda40272a 100644 --- a/py/test/Ice/servantLocator/AllTests.py +++ b/py/test/Ice/servantLocator/AllTests.py @@ -17,64 +17,64 @@ def test(b): def testExceptions(obj, collocated): try: - obj.requestFailedException() - test(false) + obj.requestFailedException() + test(false) except Ice.ObjectNotExistException, ex: - if not collocated: - test(ex.id == obj.ice_getIdentity()) - test(ex.facet == obj.ice_getFacet()) - test(ex.operation == "requestFailedException") + if not collocated: + test(ex.id == obj.ice_getIdentity()) + test(ex.facet == obj.ice_getFacet()) + test(ex.operation == "requestFailedException") try: - obj.unknownUserException() - test(false) + obj.unknownUserException() + test(false) except Ice.UnknownUserException, ex: - test(ex.unknown == "reason") - pass + test(ex.unknown == "reason") + pass try: - obj.unknownLocalException() - test(false) + obj.unknownLocalException() + test(false) except Ice.UnknownLocalException, ex: - test(ex.unknown == "reason") - pass + test(ex.unknown == "reason") + pass try: - obj.unknownException() - test(false) + obj.unknownException() + test(false) except Ice.UnknownException, ex: - test(ex.unknown == "reason") - pass + test(ex.unknown == "reason") + pass try: - obj.userException() - test(false) + obj.userException() + test(false) except Ice.UnknownUserException, ex: - #print ex.unknown - test(not collocated) - test(ex.unknown.find("Test.TestIntfUserException") >= 0) + #print ex.unknown + test(not collocated) + test(ex.unknown.find("Test.TestIntfUserException") >= 0) except Test.TestIntfUserException: - test(collocated) + test(collocated) try: - obj.localException() - test(false) + obj.localException() + test(false) except Ice.UnknownLocalException, ex: - #print ex.unknown - test(not collocated) - test(ex.unknown.find("Ice.SocketException") >= 0) + #print ex.unknown + test(not collocated) + test(ex.unknown.find("Ice.SocketException") >= 0) except SocketException: - test(collocated) + test(collocated) try: - obj.pythonException() - test(false) + obj.pythonException() + test(false) except Ice.UnknownException, ex: - #print ex.unknown - test(not collocated) - test(ex.unknown.find("RuntimeError: message") >= 0) + #print ex.unknown + test(not collocated) + test(ex.unknown.find("RuntimeError: message") >= 0) except RuntimeError: - test(collocated) + test(collocated) def allTests(communicator, collocated): print "testing stringToProxy... ", @@ -95,9 +95,9 @@ def allTests(communicator, collocated): base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000") obj = Test.TestIntfPrx.checkedCast(base) try: - Test.TestIntfPrx.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000")) + Test.TestIntfPrx.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000")) except Ice.ObjectNotExistException: - pass + pass print "ok" print "testing default servant locator...", @@ -107,13 +107,13 @@ def allTests(communicator, collocated): base = communicator.stringToProxy("locate:default -p 12010 -t 10000") obj = Test.TestIntfPrx.checkedCast(base) try: - Test.TestIntfPrx.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000")) + Test.TestIntfPrx.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000")) except Ice.ObjectNotExistException: - pass + pass try: - Test.TestIntfPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")) + Test.TestIntfPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")) except Ice.ObjectNotExistException: - pass + pass print "ok" print "testing locate exceptions... ", diff --git a/py/test/Ice/servantLocator/Client.py b/py/test/Ice/servantLocator/Client.py index 47c7f18f241..f5f2023be23 100644 --- a/py/test/Ice/servantLocator/Client.py +++ b/py/test/Ice/servantLocator/Client.py @@ -26,8 +26,8 @@ import Test, AllTests class TestClient(Ice.Application): def run(self, args): - obj = AllTests.allTests(self.communicator(), False) - obj.shutdown() + obj = AllTests.allTests(self.communicator(), False) + obj.shutdown() return 0 app = TestClient() diff --git a/py/test/Ice/servantLocator/Collocated.py b/py/test/Ice/servantLocator/Collocated.py index 2c338d08126..20eaabf0a67 100644 --- a/py/test/Ice/servantLocator/Collocated.py +++ b/py/test/Ice/servantLocator/Collocated.py @@ -30,15 +30,15 @@ class TestServer(Ice.Application): self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0") adapter = self.communicator().createObjectAdapter("TestAdapter") - adapter.activate() + adapter.activate() adapter.addServantLocator(TestI.ServantLocatorI("category"), "category") adapter.addServantLocator(TestI.ServantLocatorI(""), "") - adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm")) + adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm")) - AllTests.allTests(self.communicator(), False) + AllTests.allTests(self.communicator(), False) - adapter.deactivate() - adapter.waitForDeactivate() + adapter.deactivate() + adapter.waitForDeactivate() return 0 app = TestServer() diff --git a/py/test/Ice/servantLocator/Server.py b/py/test/Ice/servantLocator/Server.py index f4714bb7b16..1a4bde4dd2a 100644 --- a/py/test/Ice/servantLocator/Server.py +++ b/py/test/Ice/servantLocator/Server.py @@ -26,13 +26,13 @@ import Test, TestI class TestServer(Ice.Application): def run(self, args): - self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000") - self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0") + self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000") + self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0") adapter = self.communicator().createObjectAdapter("TestAdapter") adapter.addServantLocator(TestI.ServantLocatorI("category"), "category") adapter.addServantLocator(TestI.ServantLocatorI(""), "") - adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm")) + adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm")) adapter.activate() adapter.waitForDeactivate() diff --git a/py/test/Ice/servantLocator/ServerAMD.py b/py/test/Ice/servantLocator/ServerAMD.py index 9e6000d5612..82cd7ea12d4 100644 --- a/py/test/Ice/servantLocator/ServerAMD.py +++ b/py/test/Ice/servantLocator/ServerAMD.py @@ -26,13 +26,13 @@ import Test, TestAMDI class TestServer(Ice.Application): def run(self, args): - self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000") - self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0") + self.communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000") + self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0") adapter = self.communicator().createObjectAdapter("TestAdapter") adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category") adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "") - adapter.add(TestAMDI.TestI(), self.communicator().stringToIdentity("asm")) + adapter.add(TestAMDI.TestI(), self.communicator().stringToIdentity("asm")) adapter.activate() adapter.waitForDeactivate() diff --git a/py/test/Ice/servantLocator/TestAMDI.py b/py/test/Ice/servantLocator/TestAMDI.py index e2b98c109a9..74a892f1554 100644 --- a/py/test/Ice/servantLocator/TestAMDI.py +++ b/py/test/Ice/servantLocator/TestAMDI.py @@ -18,29 +18,29 @@ def test(b): class TestI(Test.TestIntf): def requestFailedException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def unknownUserException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def unknownLocalException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def unknownException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def localException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def userException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def pythonException_async(self, cb, current=None): - cb.ice_response() + cb.ice_response() def shutdown_async(self, cb, current=None): current.adapter.deactivate() - cb.ice_response() + cb.ice_response() class CookieI(Test.Cookie): def message(self): @@ -49,7 +49,7 @@ class CookieI(Test.Cookie): class ServantLocatorI(Ice.ServantLocator): def __init__(self, category): self._deactivated = False - self._category = category + self._category = category def __del__(self): test(self._deactivated) @@ -57,25 +57,25 @@ class ServantLocatorI(Ice.ServantLocator): def locate(self, current): test(not self._deactivated) - test(current.id.category == self._category or self._category == "") - - if current.id.name == "unknown": - return None + test(current.id.category == self._category or self._category == "") + + if current.id.name == "unknown": + return None - test(current.id.name == "locate" or current.id.name == "finished") - if current.id.name == "locate": - self.exception(current) + test(current.id.name == "locate" or current.id.name == "finished") + if current.id.name == "locate": + self.exception(current) return (TestI(), CookieI()) def finished(self, current, servant, cookie): test(not self._deactivated) - test(current.id.category == self._category or self._category == "") - test(current.id.name == "locate" or current.id.name == "finished") - - if current.id.name == "finished": - self.exception(current) + test(current.id.category == self._category or self._category == "") + test(current.id.name == "locate" or current.id.name == "finished") + + if current.id.name == "finished": + self.exception(current) test(isinstance(cookie, Test.Cookie)) test(cookie.message() == 'blahblah') @@ -86,25 +86,25 @@ class ServantLocatorI(Ice.ServantLocator): self._deactivated = True def exception(self, current): - if current.operation == "requestFailedException": - raise Ice.ObjectNotExistException() - elif current.operation == "unknownUserException": - ex = Ice.UnknownUserException() - ex.unknown = "reason" - raise ex - elif current.operation == "unknownLocalException": - ex = Ice.UnknownLocalException() - ex.unknown = "reason" - raise ex - elif current.operation == "unknownException": - ex = Ice.UnknownException() - ex.unknown = "reason" - raise ex - elif current.operation == "userException": - raise Test.TestIntfUserException() - elif current.operation == "localException": - ex = Ice.SocketException() - ex.error = 0 - raise ex - elif current.operation == "pythonException": - raise RuntimeError("message") + if current.operation == "requestFailedException": + raise Ice.ObjectNotExistException() + elif current.operation == "unknownUserException": + ex = Ice.UnknownUserException() + ex.unknown = "reason" + raise ex + elif current.operation == "unknownLocalException": + ex = Ice.UnknownLocalException() + ex.unknown = "reason" + raise ex + elif current.operation == "unknownException": + ex = Ice.UnknownException() + ex.unknown = "reason" + raise ex + elif current.operation == "userException": + raise Test.TestIntfUserException() + elif current.operation == "localException": + ex = Ice.SocketException() + ex.error = 0 + raise ex + elif current.operation == "pythonException": + raise RuntimeError("message") diff --git a/py/test/Ice/servantLocator/TestI.py b/py/test/Ice/servantLocator/TestI.py index 4a9eabf33c8..c5768071fc2 100644 --- a/py/test/Ice/servantLocator/TestI.py +++ b/py/test/Ice/servantLocator/TestI.py @@ -18,25 +18,25 @@ def test(b): class TestI(Test.TestIntf): def requestFailedException(self, current=None): - pass + pass def unknownUserException(self, current=None): - pass + pass def unknownLocalException(self, current=None): - pass + pass def unknownException(self, current=None): - pass + pass def localException(self, current=None): - pass + pass def userException(self, current=None): - pass + pass def pythonException(self, current=None): - pass + pass def shutdown(self, current=None): current.adapter.deactivate() @@ -48,7 +48,7 @@ class CookieI(Test.Cookie): class ServantLocatorI(Ice.ServantLocator): def __init__(self, category): self._deactivated = False - self._category = category + self._category = category def __del__(self): test(self._deactivated) @@ -56,25 +56,25 @@ class ServantLocatorI(Ice.ServantLocator): def locate(self, current): test(not self._deactivated) - test(current.id.category == self._category or self._category == "") - - if current.id.name == "unknown": - return None + test(current.id.category == self._category or self._category == "") + + if current.id.name == "unknown": + return None - test(current.id.name == "locate" or current.id.name == "finished") - if current.id.name == "locate": - self.exception(current) + test(current.id.name == "locate" or current.id.name == "finished") + if current.id.name == "locate": + self.exception(current) return (TestI(), CookieI()) def finished(self, current, servant, cookie): test(not self._deactivated) - test(current.id.category == self._category or self._category == "") - test(current.id.name == "locate" or current.id.name == "finished") - - if current.id.name == "finished": - self.exception(current) + test(current.id.category == self._category or self._category == "") + test(current.id.name == "locate" or current.id.name == "finished") + + if current.id.name == "finished": + self.exception(current) test(isinstance(cookie, Test.Cookie)) test(cookie.message() == 'blahblah') @@ -85,25 +85,25 @@ class ServantLocatorI(Ice.ServantLocator): self._deactivated = True def exception(self, current): - if current.operation == "requestFailedException": - raise Ice.ObjectNotExistException() - elif current.operation == "unknownUserException": - ex = Ice.UnknownUserException() - ex.unknown = "reason" - raise ex - elif current.operation == "unknownLocalException": - ex = Ice.UnknownLocalException() - ex.unknown = "reason" - raise ex - elif current.operation == "unknownException": - ex = Ice.UnknownException() - ex.unknown = "reason" - raise ex - elif current.operation == "userException": - raise Test.TestIntfUserException() - elif current.operation == "localException": - ex = Ice.SocketException() - ex.error = 0 - raise ex - elif current.operation == "pythonException": - raise RuntimeError("message") + if current.operation == "requestFailedException": + raise Ice.ObjectNotExistException() + elif current.operation == "unknownUserException": + ex = Ice.UnknownUserException() + ex.unknown = "reason" + raise ex + elif current.operation == "unknownLocalException": + ex = Ice.UnknownLocalException() + ex.unknown = "reason" + raise ex + elif current.operation == "unknownException": + ex = Ice.UnknownException() + ex.unknown = "reason" + raise ex + elif current.operation == "userException": + raise Test.TestIntfUserException() + elif current.operation == "localException": + ex = Ice.SocketException() + ex.error = 0 + raise ex + elif current.operation == "pythonException": + raise RuntimeError("message") diff --git a/py/test/Ice/slicing/exceptions/AllTests.py b/py/test/Ice/slicing/exceptions/AllTests.py index 4be1df50191..de8e4adf6d6 100644 --- a/py/test/Ice/slicing/exceptions/AllTests.py +++ b/py/test/Ice/slicing/exceptions/AllTests.py @@ -242,7 +242,7 @@ def allTests(communicator): print "base... ", try: t.baseAsBase() - test(false) + test(false) except Test.Base, b: test(b.b == "Base.b") test(b.ice_name() == "Test::Base") @@ -259,7 +259,7 @@ def allTests(communicator): print "slicing of unknown derived... ", try: t.unknownDerivedAsBase() - test(false) + test(false) except Test.Base, b: test(b.b == "UnknownDerived.b") test(b.ice_name() == "Test::Base") @@ -276,7 +276,7 @@ def allTests(communicator): print "non-slicing of known derived as base... ", try: t.knownDerivedAsBase() - test(false) + test(false) except Test.KnownDerived, k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") @@ -294,7 +294,7 @@ def allTests(communicator): print "non-slicing of known derived as derived... ", try: t.knownDerivedAsKnownDerived() - test(false) + test(false) except Test.KnownDerived, k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") @@ -312,7 +312,7 @@ def allTests(communicator): print "slicing of unknown intermediate as base... ", try: t.unknownIntermediateAsBase() - test(false) + test(false) except Test.Base, b: test(b.b == "UnknownIntermediate.b") test(b.ice_name() == "Test::Base") @@ -329,7 +329,7 @@ def allTests(communicator): print "slicing of known intermediate as base... ", try: t.knownIntermediateAsBase() - test(false) + test(false) except Test.KnownIntermediate, ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") @@ -347,7 +347,7 @@ def allTests(communicator): print "slicing of known most derived as base... ", try: t.knownMostDerivedAsBase() - test(false) + test(false) except Test.KnownMostDerived, kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") @@ -366,7 +366,7 @@ def allTests(communicator): print "non-slicing of known intermediate as intermediate... ", try: t.knownIntermediateAsKnownIntermediate() - test(false) + test(false) except Test.KnownIntermediate, ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") @@ -384,7 +384,7 @@ def allTests(communicator): print "non-slicing of known most derived exception as intermediate... ", try: t.knownMostDerivedAsKnownIntermediate() - test(false) + test(false) except Test.KnownMostDerived, kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") @@ -403,7 +403,7 @@ def allTests(communicator): print "non-slicing of known most derived as most derived... ", try: t.knownMostDerivedAsKnownMostDerived() - test(false) + test(false) except Test.KnownMostDerived, kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") @@ -422,7 +422,7 @@ def allTests(communicator): print "slicing of unknown most derived, known intermediate as base... ", try: t.unknownMostDerived1AsBase() - test(false) + test(false) except Test.KnownIntermediate, ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") @@ -440,7 +440,7 @@ def allTests(communicator): print "slicing of unknown most derived, known intermediate as intermediate... ", try: t.unknownMostDerived1AsKnownIntermediate() - test(false) + test(false) except Test.KnownIntermediate, ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") @@ -458,7 +458,7 @@ def allTests(communicator): print "slicing of unknown most derived, unknown intermediate as base... ", try: t.unknownMostDerived2AsBase() - test(false) + test(false) except Test.Base, b: test(b.b == "UnknownMostDerived2.b") test(b.ice_name() == "Test::Base") diff --git a/py/test/Ice/slicing/objects/AllTests.py b/py/test/Ice/slicing/objects/AllTests.py index e1e5ee5c4ba..d5028bd8e79 100644 --- a/py/test/Ice/slicing/objects/AllTests.py +++ b/py/test/Ice/slicing/objects/AllTests.py @@ -456,9 +456,9 @@ def allTests(communicator): print "unknown with Object as Object (AMI)... ", try: - cb = AMI_Test_SUnknownAsObjectI() - t.SUnknownAsObject_async(cb) - test(cb.check()) + cb = AMI_Test_SUnknownAsObjectI() + t.SUnknownAsObject_async(cb) + test(cb.check()) except Ice.NoObjectFactoryException: pass except Ice.Exception: diff --git a/py/test/Ice/slicing/objects/Test.ice b/py/test/Ice/slicing/objects/Test.ice index 9d31ce660b5..01e91579311 100644 --- a/py/test/Ice/slicing/objects/Test.ice +++ b/py/test/Ice/slicing/objects/Test.ice @@ -67,7 +67,7 @@ exception DerivedException extends BaseException D1 pd1; }; -class Forward; // Forward-declared class defined in another compilation unit +class Forward; // Forward-declared class defined in another compilation unit ["ami"] interface TestIntf { @@ -104,7 +104,7 @@ class Forward; // Forward-declared class defined in another compilation unit void throwDerivedAsDerived() throws DerivedException; void throwUnknownDerivedAsBase() throws BaseException; - void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. + void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. void shutdown(); }; diff --git a/py/test/Ice/slicing/objects/TestAMD.ice b/py/test/Ice/slicing/objects/TestAMD.ice index 9303d9e8325..1fe41bec3f5 100644 --- a/py/test/Ice/slicing/objects/TestAMD.ice +++ b/py/test/Ice/slicing/objects/TestAMD.ice @@ -67,7 +67,7 @@ exception DerivedException extends BaseException D1 pd1; }; -class Forward; // Forward-declared class defined in another compilation unit +class Forward; // Forward-declared class defined in another compilation unit ["ami", "amd"] interface TestIntf { @@ -104,7 +104,7 @@ class Forward; // Forward-declared class defined in another compilation unit void throwDerivedAsDerived() throws DerivedException; void throwUnknownDerivedAsBase() throws BaseException; - void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. + void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. void shutdown(); }; |