IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:00:22 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110710/ippToPsps/jython
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/ippToPsps/jython

    • Property svn:ignore set to
      *.class
  • branches/eam_branches/ipp-20110710/ippToPsps/jython/datastore.py

    r31839 r32337  
    55import logging
    66import sys
     7import re
    78from xml.etree.ElementTree import ElementTree, Element, tostring
    8 
    99
    1010'''
     
    1717
    1818    '''
    19     def __init__(self, logger):
     19    def __init__(self, logger, doc):
    2020   
    2121        # setup logger
    2222        self.logger = logger
     23        self.doc = doc
    2324        self.logger.debug("Datastore constructor")
    2425
    2526        # open config
    26         doc = ElementTree(file="config.xml")
    2727        self.product = doc.find("datastore/product").text
    2828        self.type = doc.find("datastore/type").text
     
    5151
    5252        if p.returncode != 0:
    53             self.logger.error("Datastore publish failed")
     53            self.logger.errorPair("Datastore publish",  "failed")
    5454            ret = False
    5555        else:
     
    5757            ret = True
    5858           
    59 
    6059        tempFile.close()
    6160        return ret
    6261
     62    '''
     63    Removes an item from the datastore
    6364
    64     '''
    65     Removes an item to the datastore
     65    NB this will return a success if the batch is not found on the datastore
    6666    '''
    6767    def remove(self, name):
     
    7272                   --product " + self.product
    7373
    74         p = Popen(command, shell=True, stdout=PIPE)
     74        p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
    7575        p.wait()
     76        output, errors = p.communicate()
    7677
    7778        if p.returncode != 0:
    78             self.logger.error("Datastore removal of " + name + " failed")
    79             ret = False
     79            if re.search("not found in", errors):
     80                self.logger.infoPair("Datastore batch not found", name)
     81                ret = True
     82            else:
     83                self.logger.infoPair("Datastore removal FAILED", name)
     84                ret = False
    8085        else:
     86            self.logger.infoPair("Datastore removal successful", name)
    8187            ret = True
    82             self.logger.infoPair("Datastore removal successful", name)
    8388           
    8489        return ret
    8590
     91    '''
     92    Removes a range of items from the datastore
     93    '''
     94    def removeRange(self, first, last):
     95
     96        firstInt = int(first[1:])
     97        lastInt = int(last[1:])
     98
     99        for i in range(firstInt, lastInt):
     100           
     101            self.remove(Batch.getNameFromID(i))
     102
     103from batch import Batch
Note: See TracChangeset for help on using the changeset viewer.