[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28120 - gnunet-planetlab/gplmt/gplmt
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28120 - gnunet-planetlab/gplmt/gplmt |
Date: |
Wed, 17 Jul 2013 15:38:44 +0200 |
Author: wachs
Date: 2013-07-17 15:38:43 +0200 (Wed, 17 Jul 2013)
New Revision: 28120
Modified:
gnunet-planetlab/gplmt/gplmt/Notifications.py
gnunet-planetlab/gplmt/gplmt/Worker.py
Log:
returning output
Modified: gnunet-planetlab/gplmt/gplmt/Notifications.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Notifications.py 2013-07-17 13:37:30 UTC
(rev 28119)
+++ gnunet-planetlab/gplmt/gplmt/Notifications.py 2013-07-17 13:38:43 UTC
(rev 28120)
@@ -59,11 +59,16 @@
return None
class Task:
- def __init__(self, task, result, fail):
+ def __init__ (self, task):
self.task = task
+ self.msg = ""
+ self.output = ""
+ def finished (self, result, fail, msg, output):
self.result = result
self.fail = fail
-
+ self.msg = msg
+ self.output = output
+
class TaskList:
def __init__(self, name):
self.name = name
@@ -90,9 +95,7 @@
self.tasks = list ()
self.tasklists = TaskListCollection()
self.connectSuccess = False
- self.error_msg = ""
-
class FileLoggerNotification (Notification):
def __init__(self, logger):
assert (None != logger)
@@ -112,7 +115,7 @@
print node + " : Tasklist '" + tasks.name + "' completed with
failure"
def task_started (self, node, task, message):
return
- def task_completed (self, node, task, result, message):
+ def task_completed (self, node, task, result, message, output):
return
@@ -144,7 +147,14 @@
sys.stdout.write(tl.name)
diff = maxTasklistLen - len(tl.name)
sys.stdout.write(' ' * diff + ' | ')
- print 'success' if tl.success else n.error_msg
+ print 'success' if tl.success else 'failed in: '
+ for t in n.tasks:
+ if (t.result != Tasks.Taskresult.success):
+ print "\tFAIL: " + t.task.name + " with '" +t.msg+ "' and
'" +t.output+ "'"
+ else:
+ print "\tSUC " + t.task.name + " with '" +t.msg+ "' and '"
+t.output+ "'"
+
+
# tsk_str = ""
# for t in n.tasks:
# tsk_f = "[e]"
@@ -195,10 +205,20 @@
#else:
# print node + " : Tasklist '" + tasks.name + "' completed with
failure"
def task_started (self, node, task, message):
+ nodeObj = self.nodes.get(node)
+ if (None == nodeObj):
+ print "Node not found!"
+ return
+ nodeObj.tasks.append (Task (task))
return
- def task_completed (self, node, task, result, message):
+ def task_completed (self, node, task, result, message, output):
nodeObj = self.nodes.get(node)
- nodeObj.error_msg = task.name
+ for t in nodeObj.tasks:
+ if t.task is task:
+ if (result != Tasks.Taskresult.success):
+ t.finished (result, True, message, output)
+ else:
+ t.finished (result, False, message, output)
return
class SimpleNotification (Notification):
@@ -238,7 +258,7 @@
print node + " : Tasklist '" + tasks.name + "' completed with
failure"
def task_started (self, node, task, message):
print node + " : Task '" + task.name + "' started"
- def task_completed (self, node, task, result, message):
+ def task_completed (self, node, task, result, message, output):
if (result == Tasks.Taskresult.success):
print node + " : Task '" + task.name + "' completed successfully"
elif (result == Tasks.Taskresult.src_file_not_found):
Modified: gnunet-planetlab/gplmt/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Worker.py 2013-07-17 13:37:30 UTC (rev
28119)
+++ gnunet-planetlab/gplmt/gplmt/Worker.py 2013-07-17 13:38:43 UTC (rev
28120)
@@ -44,8 +44,12 @@
sys.exit(1)
+class TaskExecutionResult:
+ def __init__ (self, result, message, output):
+ self.result = result
+ self.message = message
+ self.output = output
-
interrupt = False
def signal_handler(signal, frame):
global interrupt
@@ -127,13 +131,16 @@
def exec_run (self, task, transport):
global interrupt
+ message = "undefined"
+ output = "missing"
if(interrupt):
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
interrupted by user")
- return Tasks.Taskresult.user_interrupt
+ message = "'"+ task.name + "' interrupted by user"
+ g_logger.log (self.node.hostname + " : Task '"+ message)
+ return TaskExecutionResult(Tasks.Taskresult.user_interrupt,
"interrupted by user", "")
if ((task.command == None) and (task.arguments == None)):
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
failed: no command to execute")
- return Tasks.Taskresult.fail
-
+ message = "'"+ task.name + "' no command to execute"
+ g_logger.log (self.node.hostname + " : Task " + message)
+ return TaskExecutionResult(Tasks.Taskresult.fail, "no command to
execute", "")
try:
channel = transport.open_session()
channel.settimeout(1.0)
@@ -208,14 +215,18 @@
result = Tasks.Taskresult.output_did_not_match
if (result == Tasks.Taskresult.success):
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
successful")
+ message = "'"+ task.name + "' successful"
+ g_logger.log (self.node.hostname + " : Task " + message)
elif (result == Tasks.Taskresult.timeout):
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
with timeout")
+ message = "'"+ task.name + "' with timeout"
+ g_logger.log (self.node.hostname + " : Task "+ message)
elif (result == Tasks.Taskresult.user_interrupt):
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
interrupted by user")
+ message = "'"+ task.name + "' interrupted by user"
+ g_logger.log (self.node.hostname + " : Task "+ message)
else:
- g_logger.log (self.node.hostname + " : Task '"+ task.name + "'
failed")
- return result
+ message = "'"+ task.name + "' failed"
+ g_logger.log (self.node.hostname + " : Task "+ message)
+ return TaskExecutionResult(result, message, output)
def exec_put (self, task, transport):
if (False == os.path.exists (task.src)):
return Tasks.Taskresult.src_file_not_found
@@ -340,34 +351,35 @@
g_notifications.node_connected (self.node.hostname, True, "")
transport = ssh.get_transport()
success = True
- result = Tasks.Taskresult.success
+ task_result = Tasks.Taskresult.success
while (None != task and not interrupt):
g_logger.log (self.node.hostname + " : Running task id "
+str(task.id)+" '" + task.name + "'")
g_notifications.task_started (self.node.hostname, task, "")
if (task.__class__.__name__ == "Task"):
if (task.type == Tasks.Operation.run):
- result = self.exec_run (task, transport)
- g_notifications.task_completed (self.node.hostname, task,
result, "")
+ task_result = self.exec_run (task, transport)
+ g_notifications.task_completed (self.node.hostname, task,
task_result.result, task_result.message, task_result.output)
elif (task.type == Tasks.Operation.put):
- result = self.exec_put (task, transport)
- g_notifications.task_completed (self.node.hostname, task,
result, "")
+ task_result = self.exec_put (task, transport)
+ g_notifications.task_completed (self.node.hostname, task,
task_result, "")
elif (task.type == Tasks.Operation.get):
- result = self.exec_get (task, transport)
- g_notifications.task_completed (self.node.hostname, task,
result, "")
+ task_result = self.exec_get (task, transport)
+ g_notifications.task_completed (self.node.hostname, task,
task_result, "")
elif (task.type == Tasks.Operation.run_per_host):
- result = self.exec_run_per_host (task, transport)
- g_notifications.task_completed (self.node.hostname, task,
result, "")
+ task_result = self.exec_run_per_host (task, transport)
+ g_notifications.task_completed (self.node.hostname, task,
task_result, "")
else:
print "UNSUPPORTED OPERATION!"
elif (task.__class__.__name__ == "Taskset"):
g_logger.log (self.node.hostname + " : Running task set")
- if ((task.stop_on_fail == True) and (result !=
Tasks.Taskresult.success)):
+ if ((task.stop_on_fail == True) and (task_result.result !=
Tasks.Taskresult.success)):
g_logger.log (self.node.hostname + " : Task failed and
therefore execution is stopped")
+ g_notifications.task_completed (self.node.hostname, task,
task_result.result, task_result.message, task_result.output)
transport.close()
success = False
break
# If received user interrupt, close channel and break execution
- elif (result == Tasks.Taskresult.user_interrupt):
+ elif (task_result == Tasks.Taskresult.user_interrupt):
transport.close()
success = False
break
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28120 - gnunet-planetlab/gplmt/gplmt,
gnunet <=