- Timestamp:
- Jan 11, 2012, 11:19:21 PM (15 years ago)
- Location:
- branches/meh_branches/ppsub_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/datastore.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppsub_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppsub_test/ippToPsps/jython/datastore.py
r32120 r33098 5 5 import logging 6 6 import sys 7 import re 7 8 from xml.etree.ElementTree import ElementTree, Element, tostring 9 10 from ipptopspsdb import IppToPspsDb 8 11 9 12 ''' … … 16 19 17 20 ''' 18 def __init__(self, logger, doc ):21 def __init__(self, logger, doc, ippToPspsDb): 19 22 20 23 # setup logger 21 24 self.logger = logger 22 25 self.doc = doc 26 self.ippToPspsDb = ippToPspsDb 23 27 self.logger.debug("Datastore constructor") 24 28 … … 34 38 def publish(self, name, path, file, fileType): 35 39 40 # TODO should handle this better 41 batchID = int(name[1:]) 42 36 43 self.logger.infoPair("Attempting to publish", path + "/" + file) 37 44 tempFile = tempfile.NamedTemporaryFile(mode='w+b') … … 39 46 tempFile.seek(0) 40 47 41 # build dsreg command command48 # build dsreg command 42 49 command = "dsreg --add " + name + "\ 43 -- copy--datapath " + path + "\50 --link --datapath " + path + "\ 44 51 --type " + self.type + "\ 45 52 --product " + self.product + "\ … … 52 59 self.logger.errorPair("Datastore publish", "failed") 53 60 ret = False 61 self.ippToPspsDb.updateLoadedToDatastore(batchID, -1) 54 62 else: 55 63 self.logger.infoPair("Datastore publish", "successful") 56 64 ret = True 65 self.ippToPspsDb.updateLoadedToDatastore(batchID, 1) 57 66 67 tempFile.close() 58 68 59 tempFile.close()60 69 return ret 61 62 70 63 71 ''' 64 72 Removes an item from the datastore 73 74 NB this will return a success if the batch is not found on the datastore 65 75 ''' 66 76 def remove(self, name): 77 78 # TODO should handle this better 79 batchID = int(name[1:]) 67 80 68 81 command = "dsreg \ … … 71 84 --product " + self.product 72 85 73 p = Popen(command, shell=True, stdout=PIPE )86 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) 74 87 p.wait() 88 output, errors = p.communicate() 75 89 76 90 if p.returncode != 0: 77 self.logger.errorPair("Datastore removal failed", name) 78 ret = False 91 if re.search("not found in", errors): 92 self.logger.infoPair("Datastore batch not found", name) 93 ret = True 94 self.ippToPspsDb.updateDeletedDatastore(batchID, 1) 95 else: 96 self.logger.infoPair("Datastore removal FAILED", name) 97 ret = False 79 98 else: 99 self.logger.infoPair("Datastore removal successful", name) 80 100 ret = True 81 self. logger.infoPair("Datastore removal successful", name)101 self.ippToPspsDb.updateDeletedDatastore(batchID, 1) 82 102 83 103 return ret
Note:
See TracChangeset
for help on using the changeset viewer.
