diff options
author | Mark Spruiell <mes@zeroc.com> | 2013-04-19 14:25:08 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2013-04-19 14:25:08 -0700 |
commit | 887b627bedf2c3232a598b10a91ac9cece0aa067 (patch) | |
tree | 94b4916b8a8dd44f1cb7b5fd34983c2791ba9862 /protobuf/demo/python/Client.py | |
parent | SOCKS support for Java (diff) | |
download | ice-887b627bedf2c3232a598b10a91ac9cece0aa067.tar.bz2 ice-887b627bedf2c3232a598b10a91ac9cece0aa067.tar.xz ice-887b627bedf2c3232a598b10a91ac9cece0aa067.zip |
merging Protocol Buffers into master, updated for Ice 3.5
Diffstat (limited to 'protobuf/demo/python/Client.py')
-rw-r--r-- | protobuf/demo/python/Client.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/protobuf/demo/python/Client.py b/protobuf/demo/python/Client.py new file mode 100644 index 00000000000..cfe8b99579d --- /dev/null +++ b/protobuf/demo/python/Client.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved. +# +# This copy of Ice Protobuf is licensed to you under the terms +# described in the ICE_PROTOBUF_LICENSE file included in this +# distribution. +# +# ********************************************************************** + +import sys, traceback, Ice + +Ice.loadSlice('Hello.ice') +import Demo +from Person_pb2 import Person + +def menu(): + print """ +usage: +t: send 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" + return 1 + + hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) + if not hello: + print args[0] + ": invalid proxy" + return 1 + + menu() + + p = Person() + p.id = 1 + p.name = "Fred Jones" + p.email = "fred@jones.com" + + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + hello.sayHello(p) + elif c == 's': + hello.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 0 + +app = Client() +sys.exit(app.main(sys.argv, "config.client")) |