summaryrefslogtreecommitdiff
path: root/py/demo
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
committerBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
commitabada90e3f84dc703b8ddc9efcbed8a946fadead (patch)
tree2c6f9dccd510ea97cb927a7bd635422efaae547a /py/demo
parentremoving trace message (diff)
downloadice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip
Expanded tabs into spaces
Diffstat (limited to 'py/demo')
-rw-r--r--py/demo/Glacier2/callback/Client.py110
-rw-r--r--py/demo/Glacier2/callback/Server.py18
-rw-r--r--py/demo/Glacier2/callback/SessionServer.py20
-rw-r--r--py/demo/Ice/async/Client.py58
-rwxr-xr-xpy/demo/Ice/async/Server.py108
-rw-r--r--py/demo/Ice/bidir/Client.py12
-rw-r--r--py/demo/Ice/bidir/Server.py78
-rw-r--r--py/demo/Ice/hello/Client.py166
-rw-r--r--py/demo/Ice/hello/Server.py12
-rw-r--r--py/demo/Ice/latency/Client.py36
-rw-r--r--py/demo/Ice/latency/Server.py10
-rw-r--r--py/demo/Ice/minimal/Client.py6
-rw-r--r--py/demo/Ice/session/Client.py26
-rw-r--r--py/demo/Ice/session/Server.py38
-rw-r--r--py/demo/Ice/throughput/Client.py302
-rw-r--r--py/demo/Ice/throughput/Server.py56
-rw-r--r--py/demo/Ice/value/Client.py240
-rw-r--r--py/demo/Ice/value/Server.py10
-rw-r--r--py/demo/IceGrid/allocate/Client.py110
-rw-r--r--py/demo/IceGrid/allocate/Server.py12
-rw-r--r--py/demo/IceGrid/sessionActivation/Client.py108
-rw-r--r--py/demo/IceGrid/sessionActivation/Server.py12
-rw-r--r--py/demo/IceGrid/simple/Client.py54
-rw-r--r--py/demo/IceGrid/simple/Server.py12
-rw-r--r--py/demo/IceStorm/clock/Publisher.py80
-rw-r--r--py/demo/IceStorm/clock/Subscriber.py26
26 files changed, 860 insertions, 860 deletions
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"))