[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22977 - gnunet-planetlab/gplmt
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22977 - gnunet-planetlab/gplmt |
Date: |
Mon, 30 Jul 2012 15:04:04 +0200 |
Author: wachs
Date: 2012-07-30 15:04:04 +0200 (Mon, 30 Jul 2012)
New Revision: 22977
Modified:
gnunet-planetlab/gplmt/Tasks.py
gnunet-planetlab/gplmt/gplmt.py
Log:
added start id functionality
Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py 2012-07-30 12:59:43 UTC (rev 22976)
+++ gnunet-planetlab/gplmt/Tasks.py 2012-07-30 13:04:04 UTC (rev 22977)
@@ -23,9 +23,11 @@
# Nodes
try:
import xml
+ from xml.parsers import expat
from minixsv import pyxsval as xsv
from elementtree import ElementTree
elementtree_loaded = True
+ from genxmlif import GenXmlIfError
except ImportError:
pass
@@ -87,15 +89,23 @@
self.set = list()
-def handle_task (elem):
+def handle_task (elem, tasks):
t = Task ()
if (None != elem.attrib.get("name")):
t.name = elem.attrib.get("name")
if (None != elem.attrib.get("id")):
- t.id = elem.attrib.get("id")
+ t.id = elem.attrib.get("id")
+ if (tasks.startid != -1):
+ if (tasks.startid == t.id):
+ tasks.startid_found = True
+ glogger.log ("Task " + str (t.id) + " '" + t.name + "' has start
ID")
+ if (tasks.startid_found == False):
+ glogger.log ("Task " + str (t.id) + " '" + t.name + "' skipped")
+ return None;
+
if (None != elem.attrib.get("enabled")):
if ("FALSE" == str(elem.attrib.get("enabled")).upper()):
glogger.log ("Task " + str (t.id) + " '" + t.name + "' is
disabled")
@@ -146,15 +156,15 @@
t.log ()
return t
-def handle_sequence (elem, l):
+def handle_sequence (elem, tasks):
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)
+ handle_child (child, tasks)
-def handle_parallel (elem, l):
+def handle_parallel (elem, tasks):
glogger.log ("Found parallel execution with " + str(len(elem)) + "
elements")
if (None != elem.attrib.get("enabled")):
if ("FALSE" == str(elem.attrib.get("enabled")).upper()):
@@ -175,18 +185,18 @@
# handle_sequence (elem, l)
else:
print "Invalid element in task file: " + elem.tag
- l.append (ptask)
+ tasks.l.append (ptask)
-def handle_child (elem, l):
+def handle_child (elem, tasks):
global support_operations
if (elem.tag in supported_operations):
- t = handle_task (elem)
+ t = handle_task (elem, tasks)
if (None != t):
- l.append(t)
+ tasks.l.append(t)
elif (elem.tag == "parallel"):
- handle_parallel (elem, l)
+ handle_parallel (elem, tasks)
elif (elem.tag == "sequence"):
- handle_sequence (elem, l)
+ handle_sequence (elem, tasks)
else:
print "Invalid element in task file: " + elem.tag
@@ -203,7 +213,7 @@
class Tasks:
- def __init__(self, filename, logger):
+ def __init__(self, filename, logger, startid):
assert (None != logger)
global glogger
glogger = logger
@@ -211,6 +221,8 @@
self.filename = filename
self.name = "<Undefined>"
self.l = list ()
+ self.startid = startid
+ self.startid_found = False
def load (self):
self.logger.log ("Loading tasks file '" + self.filename + "'")
enabled = True
@@ -219,6 +231,9 @@
except xsv.xsvalErrorHandler.XsvalError as e:
print "File '" + self.filename + "' does not validate against
schema: \n" + str(e)
return False
+ except GenXmlIfError as e:
+ print "File '" + self.filename + "' is not well-formed: \n" +
str(e)
+ return False
except IOError:
print "File '" + self.filename + "' not found \n"
return False
@@ -230,7 +245,7 @@
if (None != root.attrib.get("enabled")):
if (False == root.attrib.get("enabled")):
enabled = False
- except xml.parsers.expat.ExpatError as e:
+ except expat.ExpatError as e:
print "File '" + self.filename + "'is malformed: " + str(e)
return False
except IOError:
@@ -238,12 +253,16 @@
return False
if (enabled == True):
for child in root:
- handle_child (child, self.l)
+ handle_child (child, self)
else:
print "Tasklist " + self.filename + " was disabled"
#print_sequence (self.l)
+
+ return True
+
+
def copy (self):
- t = Tasks (self.filename, self.logger)
+ t = Tasks (self.filename, self.logger, -1)
# Create a copy of the task list as described in
# http://docs.python.org/library/copy.html
t.filename = self.filename
Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py 2012-07-30 12:59:43 UTC (rev 22976)
+++ gnunet-planetlab/gplmt/gplmt.py 2012-07-30 13:04:04 UTC (rev 22977)
@@ -70,7 +70,7 @@
# Parse command line arguments
try:
- opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:ap:", ["help",
"config=", "nodes=", "tasks=", "all", "password"])
+ opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:ap:s:", ["help",
"config=", "nodes=", "tasks=", "all", "password", "startid"])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
@@ -91,7 +91,9 @@
elif o in ("-a", "--all"):
main.pl_use_nodes = True
elif o in ("-p", "--password"):
- main.pl_password = a
+ main.pl_password = a
+ elif o in ("-s", "--startid"):
+ main.startid = a
else:
assert False, "unhandled option"
@@ -139,7 +141,7 @@
sys.exit(2)
# Load actions file
- tasks = Tasks.Tasks (main.tasks_file, main.logger);
+ tasks = Tasks.Tasks (main.tasks_file, main.logger, main.startid);
if (tasks.load() == False):
sys.exit(2)
@@ -152,6 +154,8 @@
# Start execution
worker = Worker.Worker (main.logger, configuration, nodes, tasks,
notifications)
worker.start()
+
+ print "HERE"
# Clean up
@@ -165,6 +169,7 @@
-t, --tasks=FILENAME use tasks file FILENAME\n\
-a, --all use all nodes assigned to PlanetLab slice instead
of nodes file\n\
-p, --password password to acces PlanetLab API\n\
+ -s, --startid start with this task id \n\
-h, --help print this help\n\
-V, --verbose be verbose \n\
Report bugs to address@hidden \n\
@@ -179,6 +184,7 @@
pl_password = "";
pl_use_nodes = False;
logger = None;
+ startid = -1;
def __init__(self):
self.verbose = False;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22977 - gnunet-planetlab/gplmt,
gnunet <=