IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32087


Ignore:
Timestamp:
Aug 12, 2011, 4:03:13 PM (15 years ago)
Author:
rhenders
Message:

changes to loggingl removed old java code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/pollOdm.py

    r32070 r32087  
    33from subprocess import call, PIPE, Popen
    44import tempfile
     5from xml.etree.ElementTree import ElementTree, Element, tostring
     6import re
     7import sys
     8
    59import logging.config
    610from pslogger import PSLogger
     11from ipptopspsdb import IppToPspsDb
     12from gpc1db import Gpc1Db
     13from odm import Odm
    714
    815
     16if len(sys.argv) > 1: CONFIG  = sys.argv[1]
     17else:
     18    print "** Usage: " + sys.argv[0] + " <configPath>"
     19    sys.exit(1)
     20
     21# open config file
     22configDoc = ElementTree(file=CONFIG)
     23
    924# set up logging
    10 logging.config.fileConfig("logging.conf")
    1125logging.setLoggerClass(PSLogger)
    1226logger = logging.getLogger("pollODM")
    13 logger.setLevel(logging.INFO)
     27logger.setup(configDoc, "pollODM")
     28
     29ippToPspsDb = IppToPspsDb(logger, configDoc)
     30gpc1Db = Gpc1Db(logger, configDoc)
     31odm = Odm(logger, configDoc)
     32
     33DVOLABEL = configDoc.find("dvo/gpc1Label").text
     34EPOCH = configDoc.find("options/epoch").text
     35
     36ids = ippToPspsDb.getProcessedButUnmergedBatchIDs(EPOCH, DVOLABEL)
     37
     38logger.infoPair("Processed but un-merged batches", "%d" % len(ids))
    1439
    1540
     41results = {}
    1642
    17 tempFile = tempfile.NamedTemporaryFile(mode='w+b')
     43for id in ids:
    1844
    19 p = Popen("../perl/checkOdmStatus.pl -b B00117239 -f " + tempFile.name, shell=True, stdout=PIPE)
    20 p.wait()
    21 
    22 if p.returncode != 0:
    23    logger.errorPair("ODM polling", "failed")
    24 else:
    25    logger.infoPair("ODM polling", "successful")
     45   if odm.checkBatch(id, results):
     46       ippToPspsDb.updateOdmStatus(id, results)
    2647
    2748
    28 tempFile.close()
    29 
    30 
    31 
    32 '''
    33 from javax.xml.soap import *
    34 from javax.xml.namespace import QName
    35 from java.util import Iterator
    36 from java.net import URL
    37 
    38 
    39 
    40 mf = MessageFactory.newInstance()
    41 soapMessage = mf.createMessage()
    42 soapPart = soapMessage.getSOAPPart()
    43 soapEnvelope = soapPart.getEnvelope()
    44 soapBody = soapEnvelope.getBody()
    45 soapFactory  = SOAPFactory.newInstance()
    46 bodyName = soapFactory.createName("GetBatchStatus","","")
    47 body = soapEnvelope.getBody()
    48 bodyElement = body.addBodyElement(bodyName)
    49                                                                          
    50 
    51 
    52 
    53 
    54 
    55 
    56 
    57 
    58 
    59 
    60 
    61 #soapMessage.getMimeHeaders().addHeader("GetBatchStatus", "")
    62 
    63 bodyElement.addChildElement("batchNameFilter").addTextNode("%B00117239")
    64 bodyElement.addChildElement("statusFilter").addTextNode("*")
    65 bodyElement.addChildElement("fromFilter").addTextNode("2010-01-01")
    66 bodyElement.addChildElement("toFilter").addTextNode("2099-01-01")
    67 
    68 soapMessage.saveChanges()
    69 
    70 
    71 
    72 connectionFactory = SOAPConnectionFactory.newInstance()
    73 
    74 soapConnection = connectionFactory.createConnection()
    75 
    76 url = "http://web01.psps.ifa.hawaii.edu/a01/OdmWebService/OdmWebService.asmx"
    77 
    78 try:
    79     resp = soapConnection.call(soapMessage, url)
    80     print "RESPNSE" +  resp
    81 except:
    82     print "dsdsds"
    83 
    84 soapConnection.close();
    85 '''
Note: See TracChangeset for help on using the changeset viewer.