diff options
author | Robin Norwood <rnorwood@solitude.devel.redhat.com> | 2007-09-21 11:59:49 -0400 |
---|---|---|
committer | Robin Norwood <rnorwood@solitude.devel.redhat.com> | 2007-09-21 11:59:49 -0400 |
commit | 62bf26a5f7fed44ba703e3b854a4923ce1447f27 (patch) | |
tree | 57e16047774454e193660d7e905b1fa84f884e90 | |
parent | f945d9b43021fccde0544d4580778ae13ca50e22 (diff) | |
download | func-62bf26a5f7fed44ba703e3b854a4923ce1447f27.tar.gz func-62bf26a5f7fed44ba703e3b854a4923ce1447f27.tar.xz func-62bf26a5f7fed44ba703e3b854a4923ce1447f27.zip |
clean up dumb_client.py, and make it actually run for me
-rwxr-xr-x[-rw-r--r--] | client/dumb_client.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/client/dumb_client.py b/client/dumb_client.py index 173b3a3..c6a31ed 100644..100755 --- a/client/dumb_client.py +++ b/client/dumb_client.py @@ -6,33 +6,40 @@ import getopt import sys import xmlrpclib +myname, argv = sys.argv[0], sys.argv[1:] + +def usage(): + return "Usage: %s [ --help ] [ --verbose ] [ --server=http://hostname:port ] method arg1 [ ... ]" % myname verbose = 0 +server = "http://127.0.0.1:51234" try: - opts, args = getopt.getopt(sys.argv, "hvs:", + opts, args = getopt.getopt(argv, "hvs:", ["help", "verbose", "server="]) except getopt.error, e: print _("Error parsing list arguments: %s") % e - self.print_help() - # FIXME: error handling + print usage() + sys.exit() - -server = "http://127.0.0.1:51234" for (opt, val) in opts: + print "opt = %s, val = %s" % (opt, val) if opt in ["-h", "--help"]: - self.print_help() + print usage() sys.exit() if opt in ["-v", "--verbose"]: verbose = verbose + 1 if opt in ["-s", "--server"]: server = val +if len(args) < 1: + print usage() + sys.exit() + s = xmlrpclib.ServerProxy(server) -args = args[1:] method = args[0] print "calling %s with args: %s" % (method, args[1:]) @@ -40,3 +47,4 @@ print "calling %s with args: %s" % (method, args[1:]) # we can't call "call" on s, since thats a rpc, so # we call gettatr around it. print getattr(s, method)(*args[1:]) + |