import sys, socket
import os
import re
+import readline
from Util import *
from XMLParser import *
from threading import Thread
'boot':[self.nodeC, 'Bootstrap server. Options: all | x .'],
'start': [self.clientC, 'Start clients. Options: all | x | x,y .'],
'stop': [self.clientC, 'Stop clients. Options: all | x | x,y .'],
- 'status': [self.clientC, 'Status clients. Options: all | x | x,y .'],
+ 'status': [self.clientC,'Status clients. Options: all | x | x,y .'],
'archive': [self.nodeC, 'Archive output information of clients.'+\
'Options: all | x .'],
'getclients': [self.nodeC,'Get running clients. Options: all | x .'],
'getoutput': [self.nodeC,'Get clients output. Options: all | x .'],
- 'help': [self.simpleC, "Show This Message."],
- 'exit': [self.simpleC, "Exit Commander."]
+ 'help': [self.simpleC, 'Show This Message.'],
+ 'exit': [self.simpleC, 'Exit Commander.']
}
def simpleC(self, comm, argv):
if comm == 'list':
for node in self.nodes.getNodes():
self.printNodeInfo(node)
+ si = self.swarm.getSIByNode(node)
+ self.printClientInfo(si)
if comm == 'help':
print "List of commands:"
keys = self.commands.keys()
int(node.listen_port),
si.pid)
+
+ #{'download_size': 183509218, 'num_peers': 2, 'eta': 0, 'timestamp': datetime.datetime(2010, 4, 30, 9, 6, 27), 'upload_speed': 0, 'download_speed': 0, 'dht': 0}
def statusSI(self, node, si):
ret = self.Commander.status(node.public_address,
int(node.listen_port),
si.pid)
- if ret: print ret
+ if ret:
+ self.printNodeInfo(node)
+ self.printClientInfo(si)
+ for k,v in ret.items():
+ if k=='timestamp':
+ print "\t" + k +": " + v.strftime("%H:%M:%S %d/%m/%y")
+ else:
+ print "\t" + k +": " + str(v)
def getNodeStatus(self, node):
ret = self.Commander.getClients(node.public_address,
int(node.listen_port))
if ret:
- print 'node ' + node.id + ' (' + node.public_address +\
- ":" +node.public_port + " -> " + node.private_address +\
- ":" +node.listen_port +' ):'
+ self.printNodeInfo(node)
for l in ret:
print " -" + l[0] + " client(pid:" + str(l[1]) +") on \"" + l[2] +"\""
ret = self.Commander.getOutput(node.public_address,
int(node.listen_port))
if ret:
- print 'node ' + node.id + ' (' + node.public_address +\
- ":" +node.public_port + " -> " + node.private_address +\
- ":" +node.listen_port +' ):'
+ self.printNodeInfo(node)
for l in ret:
print " -" + l[0] + " client on \"" + l[1] + "\" outputs at:"
for ll in l[2:]:
ret = self.Commander.archive(node.public_address,
int(node.listen_port))
if ret:
- print 'node ' + node.id + ' (' + node.public_address +\
- ":" +node.public_port + " -> " + node.private_address +\
- ":" +node.listen_port +' ):'
+ self.printNodeInfo(node)
for l in ret:
- print "archiving ... " +l
+ print " archiving ... " +l
def cleanNode(self, node):
pass
(self.commands[argv[0]][0])(argv[0], argv[1:])
except KeyError:
print "Unknown command"
+ except EOFError, KeyboardException:
+ sys.exit()
def printNodeInfo(self, node):
- si = self.swarm.getSIByNode(node)
print 'node ' + node.id + ' (' + node.public_address +\
":" +node.public_port + " -> " + node.private_address +\
- ":" +node.listen_port +' ):'
+ ":" +node.listen_port +')'
+
+ def printClientInfo(self, si):
print ' - client ' + si.id +' (' + si.btclient + ', Down:' + si.download_limit + \
" KB/s" + ", Up:" +si.upload_limit + " KB/s" + ' )'
def about(self):
- print "Commander version 1.1"
+ print "Commander version 1.1.1"
print "Enter \"help\" for instructions"
if __name__ == "__main__":