[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25051 - in gnunet-planetlab/gplmt: . gplmt
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25051 - in gnunet-planetlab/gplmt: . gplmt |
Date: |
Mon, 19 Nov 2012 15:00:04 +0100 |
Author: otarabai
Date: 2012-11-19 15:00:04 +0100 (Mon, 19 Nov 2012)
New Revision: 25051
Modified:
gnunet-planetlab/gplmt/gplmt.py
gnunet-planetlab/gplmt/gplmt/Configuration.py
gnunet-planetlab/gplmt/gplmt/Notifications.py
gnunet-planetlab/gplmt/gplmt/Worker.py
Log:
Result output formatting
Modified: gnunet-planetlab/gplmt/gplmt/Configuration.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Configuration.py 2012-11-19 13:59:39 UTC
(rev 25050)
+++ gnunet-planetlab/gplmt/gplmt/Configuration.py 2012-11-19 14:00:04 UTC
(rev 25051)
@@ -100,6 +100,11 @@
except ConfigParser.NoOptionError as e:
pass
+ try:
+ self.notifications = config.get("gplmt", "notification")
+ except ConfigParser.NoOptionError as e:
+ pass
+
# ssh options
try:
self.ssh_add_unkown_hostkeys = config.getboolean ("ssh",
"add_unkown_hostkeys")
@@ -131,4 +136,4 @@
return True
-
\ No newline at end of file
+
Modified: gnunet-planetlab/gplmt/gplmt/Notifications.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Notifications.py 2012-11-19 13:59:39 UTC
(rev 25050)
+++ gnunet-planetlab/gplmt/gplmt/Notifications.py 2012-11-19 14:00:04 UTC
(rev 25051)
@@ -63,13 +63,33 @@
self.task = task
self.result = result
self.fail = fail
-
-class Node:
+
+class TaskList:
def __init__(self, name):
self.name = name
+ self.success = False
self.start = time.time()
self.end = 0
+
+class TaskListCollection:
+ def __init__(self):
+ self.tasklists = list ()
+ def add (self, tasklist):
+ self.tasklists.append (tasklist)
+ def get (self, name):
+ for tl in self.tasklists:
+ if (tl.name == name):
+ return tl
+ return None
+
+class Node:
+ def __init__(self, name):
+ self.name = name
+ self.start = 0
+ self.end = 0
self.tasks = list ()
+ self.tasklists = TaskListCollection()
+ self.connectSuccess = False
class FileLoggerNotification (Notification):
@@ -99,29 +119,76 @@
def __init__(self, logger):
assert (None != logger)
self.logger = logger
- #self.nodes = NodeCollection ()
+ self.nodes = NodeCollection ()
def summarize (self):
- for n in self.nodes:
- tsk_str = ""
- for t in n.tasks:
- tsk_f = "[e]"
- if (t.fail == True):
- tsk_f = "[f]"
- else:
- tsk_f = "[s]"
- tsk_str += t.task.name + " " + tsk_f + " ->"
- print n.name
+ maxNodeLen = 0
+ maxTasklistLen = 0
+ # Calculate max length of node names and tasklist names
+ for n in self.nodes.nodes:
+ nodeLen = len(n.name)
+ if (nodeLen > maxNodeLen):
+ maxNodeLen = nodeLen
+ for tl in n.tasklists.tasklists:
+ tlLen = len(tl.name)
+ if(tlLen > maxTasklistLen):
+ maxTasklistLen = tlLen
+ # Print organized output
+ for n in self.nodes.nodes:
+ sys.stdout.write(n.name)
+ diff = maxNodeLen - len(n.name)
+ sys.stdout.write(' ' * diff + ' | ')
+ for tl in n.tasklists.tasklists:
+ sys.stdout.write(tl.name)
+ diff = maxTasklistLen - len(tl.name)
+ sys.stdout.write(' ' * diff + ' | ')
+ print 'success' if tl.success else 'fail'
+ # tsk_str = ""
+ # for t in n.tasks:
+ # tsk_f = "[e]"
+ # if (t.fail == True):
+ # tsk_f = "[f]"
+ # else:
+ # tsk_f = "[s]"
+ # tsk_str += t.task.name + " " + tsk_f + " ->"
+ # print n.name
def node_connected (self, node, success):
+ # Get node object
+ nodeObj = self.nodes.get(node)
+ # Create it if it doesn't exist
+ if(None == self.nodes.get(node)):
+ nodeObj = Node(node)
+ self.nodes.add(nodeObj)
+ # Set node start time as of now
+ nodeObj.start = time.time()
+ nodeObj.connectSuccess = success
return
def node_disconnected (self, node, success):
+ # Mainly need to set node end connection time
+ nodeObj = self.nodes.get(node)
+ nodeObj.end = time.time()
return
def tasklist_started (self, node, tasks):
+ # Get node object
+ nodeObj = self.nodes.get(node)
+ # Create it if it doesn't exist (shouldn't node_connected be called
before this?)
+ if(None == self.nodes.get(node)):
+ nodeObj = Node(node)
+ self.nodes.add(nodeObj)
+ # Create tasklist object
+ tasklist = TaskList(tasks.name)
+ # Add it to the collection of node tasklists
+ nodeObj.tasklists.add(tasklist)
return
def tasklist_completed (self, node, tasks, success):
- if (success == True):
- print node + " : Tasklist '" + tasks.name + "' completed
successfully"
- else:
- print node + " : Tasklist '" + tasks.name + "' completed with
failure"
+ # Mainly want to set tasklist end time and success status
+ nodeObj = self.nodes.get(node)
+ tasklist = nodeObj.tasklists.get(tasks.name)
+ tasklist.end = time.time()
+ tasklist.success = success
+ #if (success == True):
+ # print node + " : Tasklist '" + tasks.name + "' completed
successfully"
+ #else:
+ # print node + " : Tasklist '" + tasks.name + "' completed with
failure"
def task_started (self, node, task):
return
def task_completed (self, node, task, result):
@@ -133,16 +200,17 @@
self.logger = logger
#self.nodes = NodeCollection ()
def summarize (self):
- for n in self.nodes:
- tsk_str = ""
- for t in n.tasks:
- tsk_f = "[e]"
- if (t.fail == True):
- tsk_f = "[f]"
- else:
- tsk_f = "[s]"
- tsk_str += t.task.name + " " + tsk_f + " ->"
- print n.name
+ #for n in self.nodes:
+ # tsk_str = ""
+ # for t in n.tasks:
+ # tsk_f = "[e]"
+ # if (t.fail == True):
+ # tsk_f = "[f]"
+ # else:
+ # tsk_f = "[s]"
+ # tsk_str += t.task.name + " " + tsk_f + " ->"
+ # print n.name
+ return
def node_connected (self, node, success):
if (success == True):
print node + " : connected successfully"
@@ -169,4 +237,4 @@
elif (result == Tasks.Taskresult.src_file_not_found):
print node + " : Task '" + task.name + "' failed : source file
not found"
else:
- print node + " : Task '" + task.name + "' completed with failure"
\ No newline at end of file
+ print node + " : Task '" + task.name + "' completed with failure"
Modified: gnunet-planetlab/gplmt/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Worker.py 2012-11-19 13:59:39 UTC (rev
25050)
+++ gnunet-planetlab/gplmt/gplmt/Worker.py 2012-11-19 14:00:04 UTC (rev
25051)
@@ -331,7 +331,13 @@
g_logger = logger;
def start (self):
g_logger.log ("Starting execution")
+ workersList = list()
for n in self.nodes.nodes:
nw = NodeWorker (n, self.tasks.copy())
+ workersList.append(nw)
nw.start()
+ # block main thread until all worker threads are finished to print
summary
+ for w in workersList:
+ w.thread.join()
+ g_notifications.summarize()
Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py 2012-11-19 13:59:39 UTC (rev 25050)
+++ gnunet-planetlab/gplmt/gplmt.py 2012-11-19 14:00:04 UTC (rev 25051)
@@ -173,7 +173,7 @@
if (configuration.notifications == "simple"):
notifications = Notifications.SimpleNotification (main.logger)
- if (configuration.notifications == "result"):
+ elif (configuration.notifications == "result"):
notifications = Notifications.TaskListResultNotification
(main.logger)
else:
notifications = Notifications.TaskListResultNotification
(main.logger)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25051 - in gnunet-planetlab/gplmt: . gplmt,
gnunet <=