IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32138 for trunk/ippToPsps


Ignore:
Timestamp:
Aug 19, 2011, 11:44:37 AM (15 years ago)
Author:
rhenders
Message:

added static methods for getting various paths and name; added method to delete a batch from local disk

File:
1 edited

Legend:

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

    r32118 r32138  
    6464        self.survey = self.doc.find("options/survey").text
    6565        self.pspsSurvey = self.doc.find("options/pspsSurvey").text
    66         dvoGpc1Label = self.doc.find("dvo/gpc1Label").text
     66        self.dvoGpc1Label = self.doc.find("dvo/gpc1Label").text
    6767        self.dvoLocation = self.doc.find("dvo/location").text
    6868        self.useFullTables = int(self.doc.find("dvo/useFullTables").text)
     
    7878        else:
    7979            self.surveyID = -1;
    80 
    8180       
    8281        # get some options from the config
     
    9291                self.id,
    9392                self.survey,
    94                 dvoGpc1Label,
     93                self.dvoGpc1Label,
    9594                self.datastore.product)
    9695
    9796        # get local storage location from config
    9897        self.batchName = Batch.getNameFromID(self.batchID)
    99         basePath = self.doc.find("localOutPath").text
     98        self.basePath = self.doc.find("localOutPath").text
    10099        self.subDir = Batch.getSubDir(
    101                 basePath,
     100                self.basePath,
    102101                self.batchType,
    103                 dvoGpc1Label)
     102                self.dvoGpc1Label)
    104103
    105104        self.localOutPath = Batch.getOutputPath(
    106                 basePath,
     105                self.basePath,
    107106                self.batchType,
    108                 dvoGpc1Label,
     107                self.dvoGpc1Label,
    109108                self.batchID)
    110109
     
    155154    def getOutputPath(basePath, batchType, dvoLabel, id):
    156155       return Batch.getSubDir(basePath, batchType, dvoLabel) + "/" + Batch.getNameFromID(id)
     156
     157    '''
     158    Static method to get name of tar file
     159    '''
     160    @staticmethod
     161    def getTarFile(id):
     162        return Batch.getNameFromID(id) + ".tar"
     163
     164    '''
     165    Static method to get path of tar file
     166    '''
     167    @staticmethod
     168    def getTarPath(basePath, batchType, dvoLabel, id):
     169        return Batch.getSubDir(basePath, batchType, dvoLabel) + "/" + Batch.getTarFile(id)
     170
     171    '''
     172    Static method to get name of tarball file
     173    '''
     174    @staticmethod
     175    def getTarballFile(id):
     176        return Batch.getTarFile(id) + ".gz"
     177
     178    '''
     179    Static method to get path of tarball file
     180    '''
     181    @staticmethod
     182    def getTarballPath(basePath, batchType, dvoLabel, id):
     183        return Batch.getSubDir(basePath, batchType, dvoLabel) + "/" + Batch.getTarballFile(id)
     184
     185    ''' 
     186    Static method to delete this batch from local disk
     187    '''
     188    @staticmethod
     189    def deleteFromDisk(basePath, batchType, dvoLabel, id):
     190       
     191        tarballPath = Batch.getTarballPath(basePath, batchType, dvoLabel, id)
     192        dirPath = Batch.getOutputPath(basePath, batchType, dvoLabel, id)
     193
     194        if not os.path.exists(tarballPath): return 1
     195
     196        try:
     197            os.remove(tarballPath)
     198        except:
     199            return 0
     200   
     201        return 1
    157202
    158203    '''
     
    243288     
    244289        # set up filenams and paths
    245         tarFile = self.batchName + ".tar"
    246         tarPath = self.subDir + "/" + tarFile
    247 
    248         tarballFile = tarFile + ".gz"
    249         tarballPath = self.subDir + "/" + tarballFile
     290        tarFile = Batch.getTarFile(self.batchID)
     291        tarPath = Batch.getTarPath(self.basePath, self.batchType, self.dvoGpc1Label, self.batchID)
     292        tarballFile = Batch.getTarballFile(self.batchID)
     293        tarballPath = Batch.getTarballPath(self.basePath, self.batchType, self.dvoGpc1Label, self.batchID)
    250294
    251295        # tar directory
     
    293337            rs.close()
    294338
    295         self.ippToPspsDb.updateMinMaxObjID(self.batchID, self.minObjID, self.maxObjID)
     339        self.ippToPspsDb.updateDetectionStats(self.batchID, self.minObjID, self.maxObjID, self.totalDetections)
    296340        self.logger.infoPair("Total detections", "%ld" % self.totalDetections)
    297341        self.logger.infoPair("Min objID", "%ld" % self.minObjID)
Note: See TracChangeset for help on using the changeset viewer.