Index: /trunk/ippToPsps/jython/pollOdm.py
===================================================================
--- /trunk/ippToPsps/jython/pollOdm.py	(revision 32654)
+++ /trunk/ippToPsps/jython/pollOdm.py	(revision 32655)
@@ -17,26 +17,14 @@
 Method to actually poll ODM
 '''
-def poll(batchType):
+def poll(batchType, stage):
   
+    if stage == "unloaded":
+        ids = ippToPspsDb.getUnloadedBatchIDs(EPOCH, DVOLABEL, batchType)
+    elif stage == "unmergeworthy":
+        ids = ippToPspsDb.getUnmergeWorthyBatchIDs(EPOCH, DVOLABEL, batchType)
+    elif stage == "unmerged":
+        ids = ippToPspsDb.getUnmergedBatchIDs(EPOCH, DVOLABEL, batchType)
 
-    lookingForUnloaded = 0
-    lookingForUnmergeworthy = 0
-    lookingForUnmerged = 0
-    lookingForAll = 0
-
-    if TYPE == "unloaded":
-        lookingForUnloaded = 1
-        ids = ippToPspsDb.getUnloadedBatchIDs(EPOCH, DVOLABEL, batchType)
-    elif TYPE == "unmergeworthy":
-        lookingForUnmergeworthy = 1
-        ids = ippToPspsDb.getUnmergeWorthyBatchIDs(EPOCH, DVOLABEL, batchType)
-    elif TYPE == "unmerged":
-        lookingForUnmerged = 1
-        ids = ippToPspsDb.getUnmergedBatchIDs(EPOCH, DVOLABEL, batchType)
-    elif TYPE == "unfinished":
-        lookingForAll = 1
-        ids = ippToPspsDb.getAllUnfinishedBatchIDs(EPOCH, DVOLABEL, batchType)
-
-    logger.infoTitle("Checking %d %s %s batches" % (len(ids), TYPE, batchType))
+    logger.infoTitle("Checking %d %s %s batches" % (len(ids), stage, batchType))
 
     results = {}
@@ -53,14 +41,14 @@
            ippToPspsDb.updateOdmStatus(id, results)
 
-           if lookingForUnloaded:
+           if stage == "unloaded":
                if results['LOADEDTOODM'] == 1: newLoaded = newLoaded + 1
                if results['MERGEWORTHY'] == 1: newMergeWorthy = newMergeWorthy + 1
                if results['MERGED'] == 1: newMerged = newMerged + 1
 
-           elif lookingForUnmergeworthy:
+           elif stage == "unmergeworthy":
                if results['MERGEWORTHY'] == 1: newMergeWorthy = newMergeWorthy + 1
                if results['MERGED'] == 1: newMerged = newMerged + 1
 
-           elif lookingForUnmerged:
+           elif stage == "unmerged":
                if results['MERGED'] == 1: newMerged = newMerged + 1
 
@@ -88,7 +76,7 @@
     CONFIG  = sys.argv[1]
     BATCHTYPE = sys.argv[2]
-    TYPE = sys.argv[3]
+    STAGE = sys.argv[3]
 else:
-    print "\n** Usage: " + sys.argv[0] + " <configPath> <P2|ST|all> <unloaded|unmergeworthy|unmerged|unfinished> [hours]\n"
+    print "\n** Usage: " + sys.argv[0] + " <configPath> <P2|ST|all> <unloaded|unmergeworthy|unmerged|all> [hours]\n"
     sys.exit(1)
 
@@ -113,11 +101,18 @@
 EPOCH = configDoc.find("options/epoch").text
 
+if STAGE == "all": stages = ['unloaded', 'unmergeworthy', 'unmerged']
+else: stages = [STAGE]
+
+if BATCHTYPE == "all": batchTypes = ['P2', 'ST']
+else: batchTypes = [BATCHTYPE]
+
+for stage in stages: logger.infoPair("Checking stage", stage)
+for batchType in batchTypes: logger.infoPair("Checking batch type", batchType)
+
 while True:
 
-    if BATCHTYPE == "all":
-        poll("P2")
-        poll("ST")
-    else:    
-        poll(BATCHTYPE)
+    for stage in stages: 
+        for batchType in batchTypes:
+            poll(batchType, stage)
 
     if SECONDS: 
