diff options
Diffstat (limited to 'py/demo/Ice/async')
-rwxr-xr-x | py/demo/Ice/async/Client.py | 24 | ||||
-rwxr-xr-x | py/demo/Ice/async/Server.py | 6 | ||||
-rwxr-xr-x | py/demo/Ice/async/expect.py | 5 |
3 files changed, 19 insertions, 16 deletions
diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py index 06a654a9613..f41fe3bc32c 100755 --- a/py/demo/Ice/async/Client.py +++ b/py/demo/Ice/async/Client.py @@ -19,30 +19,30 @@ class Callback: def exception(self, ex): if isinstance(ex, Demo.RequestCanceledException): - print "Demo.RequestCanceledException" + print("Demo.RequestCanceledException") else: - print "sayHello AMI call failed:" - print ex + print("sayHello AMI call failed:") + print(ex) def menu(): - print """ + print(""" usage: i: send immediate greeting d: send delayed greeting s: shutdown server x: exit ?: help -""" +""") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) if not hello: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 menu() @@ -50,7 +50,9 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 'i': hello.sayHello(0) elif c == 'd': @@ -63,14 +65,14 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except EOFError: break except KeyboardInterrupt: break - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) return 0 diff --git a/py/demo/Ice/async/Server.py b/py/demo/Ice/async/Server.py index e1458be5d6f..fc011c0a1b8 100755 --- a/py/demo/Ice/async/Server.py +++ b/py/demo/Ice/async/Server.py @@ -37,7 +37,7 @@ class WorkQueue(threading.Thread): self._cond.wait(self._callbacks[0].delay / 1000.0) if not self._done: - print "Belated Hello World!" + print("Belated Hello World!") self._callbacks[0].cb.ice_response() del self._callbacks[0] @@ -75,7 +75,7 @@ class HelloI(Demo.Hello): def sayHello_async(self, cb, delay, current=None): if delay == 0: - print "Hello World!" + print("Hello World!") cb.ice_response() else: self._workQueue.add(cb, delay) @@ -87,7 +87,7 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 self.callbackOnInterrupt() diff --git a/py/demo/Ice/async/expect.py b/py/demo/Ice/async/expect.py index 3eda015ea73..082b998d0c3 100755 --- a/py/demo/Ice/async/expect.py +++ b/py/demo/Ice/async/expect.py @@ -16,10 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) +sys.path.append(os.path.join(path[0], "scripts")) -from demoscript import * +from demoscript import Util from demoscript.Ice import async server = Util.spawn('Server.py --Ice.PrintAdapterReady') |