gnunet-svn
[Top][All Lists]
Advanced

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

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


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

Author: wachs
Date: 2012-07-20 16:33:53 +0200 (Fri, 20 Jul 2012)
New Revision: 22796

Modified:
   gnunet-planetlab/gplmt/README
   gnunet-planetlab/gplmt/Tasks.py
   gnunet-planetlab/gplmt/gplmt.py
Log:
- automatic xml validation


Modified: gnunet-planetlab/gplmt/README
===================================================================
--- gnunet-planetlab/gplmt/README       2012-07-20 14:14:14 UTC (rev 22795)
+++ gnunet-planetlab/gplmt/README       2012-07-20 14:33:53 UTC (rev 22796)
@@ -19,6 +19,7 @@
 - PlanetLab API integration to retrieve node list
 - SFTP support to copy data from and to nodes
 - Extensible task list
+- Task list validation against XML Schema
 - Extensible logging functionality
 
 Dependencies:
@@ -29,6 +30,7 @@
 - Python               >= 2.7
 - ElementTree          >= 1.3
 - Paramiko             >= 1.7
+- minixsv              >= 0.9
 
 The version numbers represent the versions we used to develop gplmt.
 
@@ -53,6 +55,12 @@
 On GNU/Linux use: sudo pip install elementtree
 Or check http://effbot.org/zone/element-index.htm
 
+minixsv
+--------
+
+On GNU/Linux use: sudo pip install minixsv
+Or check http://pypi.python.org/pypi/minixsv/0.7/
+
 Paramiko
 --------
 

Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py     2012-07-20 14:14:14 UTC (rev 22795)
+++ gnunet-planetlab/gplmt/Tasks.py     2012-07-20 14:33:53 UTC (rev 22796)
@@ -23,6 +23,7 @@
 # Nodes
 try: 
     import xml
+    from minixsv import pyxsval as xsv 
     from elementtree import ElementTree
     elementtree_loaded = True 
 except ImportError: 
@@ -212,19 +213,25 @@
     def load (self):        
         self.logger.log ("Loading tasks file '" + self.filename + "'")
         enabled = True
+        
         try:
+            xsv.parseAndValidate (self.filename)
+        except xsv.xsvalErrorHandler.XsvalError as e:
+            print "File '" + self.filename + "' does not validate against 
schema: " + str(e)
+            return False
+        
+        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)
+            print "File '" + self.filename + "'is malformed: " + str(e)
             return False                
         except IOError:
-            print "File " + self.filename + " not found"
+            print "File '" + self.filename + "' not found"
             return False
         if (enabled == True):
             for child in root:

Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py     2012-07-20 14:14:14 UTC (rev 22795)
+++ gnunet-planetlab/gplmt/gplmt.py     2012-07-20 14:33:53 UTC (rev 22796)
@@ -34,7 +34,13 @@
     paramiko_loaded = True 
 except ImportError: 
     paramiko_loaded = False 
+try:
+    import minixsv
+    minixsv_loaded = True 
+except ImportError: 
+    minixsv_loaded = False 
 
+
 import getopt;
 import sys;
 import Util;
@@ -56,7 +62,10 @@
         sys.exit(2)
     if (False == paramiko_loaded):
         print "paramiko SSH module is required for execution, please check 
README"
-        sys.exit(2)        
+        sys.exit(2)
+    if (False == minixsv_loaded):
+        print "minixsv module is required for execution, please check README"
+        sys.exit(2)       
     
 # Parse command line arguments
     




reply via email to

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