incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r736717 - /incubator/tashi/trunk/src/tashi/client/client.py
Date Thu, 22 Jan 2009 17:12:47 GMT
Author: mryan3
Date: Thu Jan 22 09:12:47 2009
New Revision: 736717

URL: http://svn.apache.org/viewvc?rev=736717&view=rev
Log:
Modified the tashi client to sort output by id and make id the first column.  Makes the output
more human readable.


Modified:
    incubator/tashi/trunk/src/tashi/client/client.py

Modified: incubator/tashi/trunk/src/tashi/client/client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/client.py?rev=736717&r1=736716&r2=736717&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/client.py (original)
+++ incubator/tashi/trunk/src/tashi/client/client.py Thu Jan 22 09:12:47 2009
@@ -20,6 +20,7 @@
 import inspect
 import os
 import sys
+import types
 from tashi.services.ttypes import *
 from thrift.protocol.TBinaryProtocol import TBinaryProtocol
 from thrift.transport.TTransport import TBufferedTransport
@@ -37,15 +38,20 @@
 		for k2 in k.__dict__.keys():
 			if (not k2.endswith("Obj")):
 				keys[k2] = k2
+	if ('id' in keys):
+		del keys['id']
+		keylist = ['id'] + keys.keys()
+	else:
+		keylist = keys.keys()
 	output = "<html>"
 	output = output + "<table>"
 	output = output + "<tr>"
-	for k in keys.keys():
+	for k in keylist:
 		output = output + "<td>%s</td>" % (k)
 	output = output + "</tr>"
 	for k in list:
 		output = output + "<tr>"
-		for k2 in keys.keys():
+		for k2 in keylist:
 			if (k2 == "state"):
 				output = output + "<td>%s</td>" % (str(vmStates[k.__dict__.get(k2, None)]))
 			else:
@@ -163,6 +169,18 @@
 	args = map(lambda x: eval(x), sys.argv[1:])
 	try:
 		res = f(*args)
+		def cmp(x, y):
+			try:
+				if (x.id < y.id):
+					return -1
+				elif (y.id < x.id):
+					return 1
+				else:
+					return 0
+			except Exception, e:
+				return 0
+		if (type(res) == types.ListType):
+			res.sort(cmp)
 		if (os.getenv("USE_HTML_TABLES")):
 			try:
 				makeHTMLTable(res)



Mime
View raw message