[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22631 - in gnunet-planetlab/gplmt: . contrib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22631 - in gnunet-planetlab/gplmt: . contrib |
Date: |
Fri, 13 Jul 2012 16:15:34 +0200 |
Author: wachs
Date: 2012-07-13 16:15:34 +0200 (Fri, 13 Jul 2012)
New Revision: 22631
Modified:
gnunet-planetlab/gplmt/Tasks.py
gnunet-planetlab/gplmt/contrib/tasks.xml
Log:
- task parsing
Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py 2012-07-13 12:46:38 UTC (rev 22630)
+++ gnunet-planetlab/gplmt/Tasks.py 2012-07-13 14:15:34 UTC (rev 22631)
@@ -21,21 +21,102 @@
# GNUnet Planetlab deployment and automation toolset
#
# Nodes
+from elementtree import ElementTree
-import xml.dom.minidom;
-import xml.parsers.expat;
-from xml.dom.minidom import parse, parseString
-import ConfigParser
+glogger = None
+class Operation:
+ none=0
+ run=1
+ get=2
+ put=3
+class Task:
+ def __init__(self):
+ self.id = -1
+ self.name = ""
+ self.type = Operation.none
+ self.command = ""
+ self.arguments = ""
+ self.expected_return_code = 0
+ self.expected_output = ""
+ self.stop_on_fail = False
+ def log (self):
+ glogger.log ("Task " + str(self.id) + ": " + self.name)
+ def check (self):
+ if ((self.id == -1) or (self.name == "") or (self.type ==
Operation.none)):
+ return False
+
+
+
+def handle_task (elem):
+ t = Task ()
+ for child in elem:
+ if (child.tag == "id"):
+ t.id = child.text
+ if (child.tag == "name"):
+ t.name = child.text
+ if (child.tag == "type"):
+ if (child.text == "run"):
+ t.type = Operation.run
+ elif (child.text == "get"):
+ t.type = Operation.get
+ elif (child.text == "put"):
+ t.type = Operation.put
+ else:
+ t.type = Operation.none
+ if (child.tag == "command"):
+ t.command = child.text
+ if (child.tag == "arguments"):
+ t.arguments = child.text
+ if (child.tag == "expected_return_code"):
+ t.expected_return_code = child.text
+ if (child.tag == "stop_on_fail"):
+ t.stop_on_fail = child.text
+
+ if (False == t.check()):
+ print "Parsing invalid task with id " + str (t.id) + " name " + t.name
+ else:
+ t.log ()
+
+
+ #for child in task:
+ # handle_child (child)
+
+def handle_sequence (elem):
+ print "sequence"
+ for child in elem:
+ handle_child (child)
+
+def handle_parallel (elem):
+ print "parallel " + str(len(elem))
+
+ for child in elem:
+ handle_child (child)
+
+def handle_child (elem):
+ if (elem.tag == "task"):
+ handle_task (elem)
+ else:
+ if (elem.tag == "parallel"):
+ handle_parallel (elem)
+ if (elem.tag == "sequence"):
+ handle_sequence (elem)
+
class Tasks:
def __init__(self, filename, logger):
assert (None != logger)
+ global glogger
+ glogger = logger
self.logger = logger
self.filename = filename
def load (self):
self.logger.log ("Loading nodes file '" + self.filename + "'")
try:
- dom = xml.dom.minidom.parse (self.filename)
- except ExpatError as e:
- print e
\ No newline at end of file
+ root = ElementTree.parse (self.filename).getroot()
+ except IOError:
+ print "File " + self.filename + " not found"
+ return False
+ print " root"
+ for child in root:
+ handle_child (child)
Modified: gnunet-planetlab/gplmt/contrib/tasks.xml
===================================================================
--- gnunet-planetlab/gplmt/contrib/tasks.xml 2012-07-13 12:46:38 UTC (rev
22630)
+++ gnunet-planetlab/gplmt/contrib/tasks.xml 2012-07-13 14:15:34 UTC (rev
22631)
@@ -13,7 +13,7 @@
<parallel>
<task>
<id>0</id>
- <name>run 1</name>
+ <name>run p2a</name>
<type>run</type>
<command>cat</command>
<arguments></arguments>
@@ -23,7 +23,7 @@
</task>
<task>
<id>0</id>
- <name>run 1</name>
+ <name>run p2b</name>
<type>run</type>
<command>cat</command>
<arguments></arguments>
@@ -34,7 +34,7 @@
</parallel>
<task>
<id>0</id>
- <name>run 1</name>
+ <name>run 3</name>
<type>run</type>
<command>cat</command>
<arguments></arguments>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22631 - in gnunet-planetlab/gplmt: . contrib,
gnunet <=