Index: /trunk/ippToPsps/jython/pollOdm.py
===================================================================
--- /trunk/ippToPsps/jython/pollOdm.py	(revision 32086)
+++ /trunk/ippToPsps/jython/pollOdm.py	(revision 32087)
@@ -3,83 +3,46 @@
 from subprocess import call, PIPE, Popen
 import tempfile
+from xml.etree.ElementTree import ElementTree, Element, tostring
+import re
+import sys
+
 import logging.config
 from pslogger import PSLogger
+from ipptopspsdb import IppToPspsDb
+from gpc1db import Gpc1Db
+from odm import Odm
 
 
+if len(sys.argv) > 1: CONFIG  = sys.argv[1]
+else:
+    print "** Usage: " + sys.argv[0] + " <configPath>"
+    sys.exit(1)
+
+# open config file
+configDoc = ElementTree(file=CONFIG)
+
 # set up logging
-logging.config.fileConfig("logging.conf")
 logging.setLoggerClass(PSLogger)
 logger = logging.getLogger("pollODM")
-logger.setLevel(logging.INFO)
+logger.setup(configDoc, "pollODM")
+
+ippToPspsDb = IppToPspsDb(logger, configDoc)
+gpc1Db = Gpc1Db(logger, configDoc)
+odm = Odm(logger, configDoc)
+
+DVOLABEL = configDoc.find("dvo/gpc1Label").text
+EPOCH = configDoc.find("options/epoch").text
+
+ids = ippToPspsDb.getProcessedButUnmergedBatchIDs(EPOCH, DVOLABEL)
+
+logger.infoPair("Processed but un-merged batches", "%d" % len(ids))
 
 
+results = {}
 
-tempFile = tempfile.NamedTemporaryFile(mode='w+b')
+for id in ids:
 
-p = Popen("../perl/checkOdmStatus.pl -b B00117239 -f " + tempFile.name, shell=True, stdout=PIPE)
-p.wait()
-
-if p.returncode != 0:
-   logger.errorPair("ODM polling", "failed")
-else:
-   logger.infoPair("ODM polling", "successful")
+   if odm.checkBatch(id, results):
+       ippToPspsDb.updateOdmStatus(id, results)
 
 
-tempFile.close()
-
-
-
-'''
-from javax.xml.soap import *
-from javax.xml.namespace import QName
-from java.util import Iterator
-from java.net import URL
-
-
-
-mf = MessageFactory.newInstance()
-soapMessage = mf.createMessage()
-soapPart = soapMessage.getSOAPPart()
-soapEnvelope = soapPart.getEnvelope()
-soapBody = soapEnvelope.getBody()
-soapFactory  = SOAPFactory.newInstance()
-bodyName = soapFactory.createName("GetBatchStatus","","")
-body = soapEnvelope.getBody()
-bodyElement = body.addBodyElement(bodyName)
-                                                                         
-
-
-
-
-
-
-
-
-
-
-
-#soapMessage.getMimeHeaders().addHeader("GetBatchStatus", "")
-
-bodyElement.addChildElement("batchNameFilter").addTextNode("%B00117239")
-bodyElement.addChildElement("statusFilter").addTextNode("*")
-bodyElement.addChildElement("fromFilter").addTextNode("2010-01-01")
-bodyElement.addChildElement("toFilter").addTextNode("2099-01-01")
-
-soapMessage.saveChanges()
-
-
-
-connectionFactory = SOAPConnectionFactory.newInstance()
-
-soapConnection = connectionFactory.createConnection()
-
-url = "http://web01.psps.ifa.hawaii.edu/a01/OdmWebService/OdmWebService.asmx"
-
-try:
-    resp = soapConnection.call(soapMessage, url)
-    print "RESPNSE" +  resp
-except:
-    print "dsdsds"
-
-soapConnection.close();
-'''
