gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22795 - gnunet-planetlab/gplmt


From: gnunet
Subject: [GNUnet-SVN] r22795 - gnunet-planetlab/gplmt
Date: Fri, 20 Jul 2012 16:14:14 +0200

Author: wachs
Date: 2012-07-20 16:14:14 +0200 (Fri, 20 Jul 2012)
New Revision: 22795

Modified:
   gnunet-planetlab/gplmt/Tasks.py
   gnunet-planetlab/gplmt/Worker.py
   gnunet-planetlab/gplmt/tasklist_schema.xsd
Log:
- dis/enabling tasklist elements


Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py     2012-07-20 13:43:34 UTC (rev 22794)
+++ gnunet-planetlab/gplmt/Tasks.py     2012-07-20 14:14:14 UTC (rev 22795)
@@ -22,6 +22,7 @@
 #
 # Nodes
 try: 
+    import xml
     from elementtree import ElementTree
     elementtree_loaded = True 
 except ImportError: 
@@ -93,6 +94,11 @@
     if (None != elem.attrib.get("id")):
         t.id = elem.attrib.get("id")        
     
+    if (None != elem.attrib.get("enabled")):
+        if ("FALSE" == str(elem.attrib.get("enabled")).upper()):
+            glogger.log ("Task " + str (t.id) + " '" + t.name + "' is 
disabled")
+            return
+    
     if (elem.tag == "run"):     
         t.type = Operation.run
     elif (elem.tag == "monitor"):            
@@ -139,11 +145,19 @@
         return t
 
 def handle_sequence (elem, l):
+    if (None != elem.attrib.get("enabled")):
+        if ("FALSE" == str(elem.attrib.get("enabled")).upper()):
+            glogger.log ("Element was disabled")
+            return
     for child in elem:
             handle_child (child, l)
             
 def handle_parallel (elem, l):
     glogger.log ("Found parallel execution with " + str(len(elem)) + " 
elements")
+    if (None != elem.attrib.get("enabled")):
+        if ("FALSE" == str(elem.attrib.get("enabled")).upper()):
+            glogger.log ("Element was disabled")
+            return
     ptask = Taskset ()
     for child in elem:
         if (elem.tag in supported_operations):
@@ -197,15 +211,26 @@
         self.l = list ()
     def load (self):        
         self.logger.log ("Loading tasks file '" + self.filename + "'")
+        enabled = True
         try:
             root = ElementTree.parse (self.filename).getroot()
             if (None != root.attrib.get("name")):
                 self.name = root.attrib.get("name")
+            if (None != root.attrib.get("enabled")):
+                if (False == root.attrib.get("enabled")):
+                    enabled = False
+                                    
+        except xml.parsers.expat.ExpatError as e:
+            print "File " + self.filename + "is malformed: " + str(e)
+            return False                
         except IOError:
             print "File " + self.filename + " not found"
             return False
-        for child in root:
-            handle_child (child, self.l)
+        if (enabled == True):
+            for child in root:
+                handle_child (child, self.l)
+        else:
+            print "Tasklist " + self.filename + " was disabled"
         #print_sequence (self.l)
     def copy (self):
         t = Tasks (self.filename, self.logger)

Modified: gnunet-planetlab/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/Worker.py    2012-07-20 13:43:34 UTC (rev 22794)
+++ gnunet-planetlab/gplmt/Worker.py    2012-07-20 14:14:14 UTC (rev 22795)
@@ -57,12 +57,14 @@
             timeout = 90
         exec_time = 0
         result = Tasks.Taskresult.success
+        
+        stdout = channel.makefile("rb")
+        stderr = channel.makefile_stderr("rb")
         while ((not channel.exit_status_ready()) and (exec_time < timeout)):
             time.sleep(1)
             exec_time += 1
         if (exec_time < timeout):
-            stdout = channel.makefile("rb")
-            stderr = channel.makefile_stderr("rb")
+
         
             stdout_data = stdout.readlines()
             stderr_data = stderr.readlines()

Modified: gnunet-planetlab/gplmt/tasklist_schema.xsd
===================================================================
--- gnunet-planetlab/gplmt/tasklist_schema.xsd  2012-07-20 13:43:34 UTC (rev 
22794)
+++ gnunet-planetlab/gplmt/tasklist_schema.xsd  2012-07-20 14:14:14 UTC (rev 
22795)
@@ -13,7 +13,8 @@
       <xs:element name="get" type="get" />
     </xs:choice>
   </xs:sequence>
-  <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="sequence">
@@ -26,7 +27,8 @@
       <xs:element name="put" type="put" />
       <xs:element name="get" type="get" />
     </xs:choice>
-  </xs:sequence>
+  </xs:sequence>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="parallel">
@@ -39,7 +41,8 @@
       <xs:element name="put" type="put" />
       <xs:element name="get" type="get" />
     </xs:choice>
-  </xs:sequence>
+  </xs:sequence>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="run">
@@ -52,7 +55,8 @@
     <xs:element name="stop_on_fail" type="xs:boolean"/>
   </xs:sequence>
   <xs:attribute name="id" type="xs:integer"/>  
-  <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="monitor">
@@ -66,6 +70,7 @@
   </xs:sequence>
   <xs:attribute name="id" type="xs:integer"/>
   <xs:attribute name="name" type="xs:string"/>  
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="put">
@@ -76,6 +81,7 @@
   </xs:sequence>
   <xs:attribute name="id" type="xs:integer"/>
   <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 <xs:complexType name="get">
@@ -86,6 +92,7 @@
   </xs:sequence>
   <xs:attribute name="id" type="xs:integer"/>
   <xs:attribute name="name" type="xs:string"/>
+  <xs:attribute name="enabled" type="xs:boolean"/>
 </xs:complexType>
 
 </xs:schema>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]