tashi-client: new encapsulated comms don't give direct feedback if RPC is unavailable: Give preference to extraViews. Improve error messages.
git-svn-id: https://svn.apache.org/repos/asf/incubator/tashi/branches/stroucki-accounting@1295358 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/tashi/client/tashi-client.py b/src/tashi/client/tashi-client.py
index f7411ba..b4d9323 100755
--- a/src/tashi/client/tashi-client.py
+++ b/src/tashi/client/tashi-client.py
@@ -526,6 +526,7 @@
"""Main function for the client program"""
global INDENT, exitCode, client
exitCode = 0
+ exception = None
INDENT = (os.getenv("INDENT", 4))
if (len(sys.argv) < 2):
usage()
@@ -583,25 +584,33 @@
vals[parg] = val
continue
+ # somewhat lame, but i don't want to rewrite the fn at this time
+ exception = ValueError("Unknown argument %s" % (arg))
- raise ValueError("Unknown argument %s" % (arg))
+ f = None
+ try:
+ f = extraViews[function][0]
+ except:
+ pass
-
- f = getattr(client, function, None)
+ if (f is None):
+ f = getattr(client, function, None)
try:
- if (f is None):
- f = extraViews[function][0]
+ if exception is not None:
+ raise exception
+
if (function in convertArgs):
fargs = eval(convertArgs[function], globals(), vals)
else:
fargs = []
- except NameError, e:
- print e
+
+ res = f(*fargs)
+ except Exception, e:
+ print "Failed in calling %s: %s" % (function, e)
print "Please run tashi-client --examples for syntax information"
sys.exit(-1)
- res = f(*fargs)
if (res != None):
keys = extraViews.get(function, (None, None))[1]
try: