IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38838 for trunk


Ignore:
Timestamp:
Oct 10, 2015, 12:56:31 PM (11 years ago)
Author:
eugene
Message:

track the loaded tables so we can cleanly skip missing tables

File:
1 edited

Legend:

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

    r38837 r38838  
    443443    def importIppTables(self, columns="*", filter=""):
    444444
    445       self.logger.infoPair("Importing tables with filter", filter)
    446 
    447       # print "trying to read ", self.fits.getPath()
    448 
    449       try:
    450           tables = stilts.treads(self.fits.getPath())
    451       except:
    452           self.logger.errorPair("STILTS could not import from", self.fits.getPath())
    453           return False
    454 
    455       count = 0
    456       for table in tables:
    457 
    458           # print "import smf table ", table
    459           match = re.match(filter, table.name)
    460           if not match: continue
    461           self.logger.debugPair("Reading IPP table", table.name)
    462           table = stilts.tpipe(table, cmd='addcol table_index $0')
    463 
    464           table = stilts.tpipe(table, cmd='explodeall')
    465 
    466           # print "read smf table ", table
    467           self.logger.infoPair("read smf table", table)
    468 
    469           # drop any previous tables before import
    470           self.scratchDb.dropTable(table.name)
    471 
    472           # IPP FITS files are littered with infinities, so remove these
    473           self.logger.debug("Removing Infinity values from all columns")
    474           table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
    475           table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
    476           table = stilts.tpipe(table, cmd='replaceval Infinity null *')
    477           # print "cleaned up values ", table
    478 
    479           try:
    480               table.write(self.scratchDb.url + '#' + table.name)
    481               # XXX this one is not needed
    482               # self.scratchDb.killLastConnectionID()
    483               count = count + 1
    484           except:
    485               self.logger.exception("Problem writing table '" + table.name + "' to the database")
     445        self.logger.infoPair("Importing tables with filter", filter)
     446
     447        # print "trying to read ", self.fits.getPath()
     448
     449        try:
     450            tables = stilts.treads(self.fits.getPath())
     451        except:
     452            self.logger.errorPair("STILTS could not import from", self.fits.getPath())
     453            return False
     454
     455        self.tablesLoaded = []
     456
     457        count = 0
     458        for table in tables:
     459
     460            # print "import smf table ", table
     461            match = re.match(filter, table.name)
     462            if not match: continue
     463            self.logger.debugPair("Reading IPP table", table.name)
     464            table = stilts.tpipe(table, cmd='addcol table_index $0')
     465
     466            table = stilts.tpipe(table, cmd='explodeall')
     467
     468            # print "read smf table ", table
     469            self.logger.infoPair("read smf table", table)
     470
     471            # drop any previous tables before import
     472            self.scratchDb.dropTable(table.name)
     473
     474            # IPP FITS files are littered with infinities, so remove these
     475            self.logger.debug("Removing Infinity values from all columns")
     476            table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
     477            table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
     478            table = stilts.tpipe(table, cmd='replaceval Infinity null *')
     479            # print "cleaned up values ", table
     480
     481            try:
     482                table.write(self.scratchDb.url + '#' + table.name)
     483                # XXX this one is not needed
     484                # self.scratchDb.killLastConnectionID()
     485                count = count + 1
     486            except:
     487                self.logger.exception("Problem writing table '" + table.name + "' to the database")
     488
     489            self.tablesLoaded.append(table.name)
    486490
    487491      self.logger.infoPair("Done. Imported", "%d tables" % count)
Note: See TracChangeset for help on using the changeset viewer.