- Timestamp:
- Sep 6, 2011, 11:00:22 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/ippToPsps/jython
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
datastore.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/ippToPsps/jython
-
Property svn:ignore
set to
*.class
-
Property svn:ignore
set to
-
branches/eam_branches/ipp-20110710/ippToPsps/jython/datastore.py
r31839 r32337 5 5 import logging 6 6 import sys 7 import re 7 8 from xml.etree.ElementTree import ElementTree, Element, tostring 8 9 9 10 10 ''' … … 17 17 18 18 ''' 19 def __init__(self, logger ):19 def __init__(self, logger, doc): 20 20 21 21 # setup logger 22 22 self.logger = logger 23 self.doc = doc 23 24 self.logger.debug("Datastore constructor") 24 25 25 26 # open config 26 doc = ElementTree(file="config.xml")27 27 self.product = doc.find("datastore/product").text 28 28 self.type = doc.find("datastore/type").text … … 51 51 52 52 if p.returncode != 0: 53 self.logger.error ("Datastore publishfailed")53 self.logger.errorPair("Datastore publish", "failed") 54 54 ret = False 55 55 else: … … 57 57 ret = True 58 58 59 60 59 tempFile.close() 61 60 return ret 62 61 62 ''' 63 Removes an item from the datastore 63 64 64 ''' 65 Removes an item to the datastore 65 NB this will return a success if the batch is not found on the datastore 66 66 ''' 67 67 def remove(self, name): … … 72 72 --product " + self.product 73 73 74 p = Popen(command, shell=True, stdout=PIPE )74 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) 75 75 p.wait() 76 output, errors = p.communicate() 76 77 77 78 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 80 85 else: 86 self.logger.infoPair("Datastore removal successful", name) 81 87 ret = True 82 self.logger.infoPair("Datastore removal successful", name)83 88 84 89 return ret 85 90 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 103 from batch import Batch
Note:
See TracChangeset
for help on using the changeset viewer.
