IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38973


Ignore:
Timestamp:
Oct 27, 2015, 2:38:19 PM (11 years ago)
Author:
eugene
Message:

add debug option to ippjython / ipptopsps.py; move some messages to debug; only do XY01 in test mode; test ingest of a FITS file to mysql

Location:
trunk/ippToPsps/jython
Files:
6 edited

Legend:

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

    r38958 r38973  
    6767                logger.errorPair("Could not read FITS PHU for id", "%d" % id)
    6868                raise
     69        else:
     70            logger.errorPair("missing fits item?", str(id))
    6971
    7072        # define the dvo table names
  • trunk/ippToPsps/jython/config.py

    r37355 r38973  
    2828        self.onebatch = False
    2929        self.loopBatch = False
     30        self.loggerLevel = logging.INFO
    3031
    3132        if sys.argv.count("-test"):
     
    6667            self.loopBatch = True
    6768            sys.argv.remove("-loop")
     69
     70        if sys.argv.count("-quiet"):
     71            self.loggerLevel = logging.WARNING
     72            sys.argv.remove("-quiet")
     73
     74        if sys.argv.count("-debug"):
     75            self.loggerLevel = logging.DEBUG
     76            sys.argv.remove("-debug")
    6877
    6978        ## name of the top-level jython script
     
    121130        self.logger = logging.getLogger(self.programName)
    122131        if (self.name is None):
    123             self.logger.setup(self.programName, self.logPath, "none", host, pid, stdout, sendToFile)
     132            self.logger.setup(self.programName, self.logPath, "none", host, pid, self.loggerLevel, stdout, sendToFile)
    124133        else:
    125             self.logger.setup(self.programName, self.logPath, self.name, host, pid, stdout, sendToFile)
     134            self.logger.setup(self.programName, self.logPath, self.name, host, pid, self.loggerLevel, stdout, sendToFile)
    126135
    127136        return self.logger
  • trunk/ippToPsps/jython/detectionbatch.py

    r38958 r38973  
    341341        self.scratchDb.execute(sql)
    342342
    343         print "---- inserted ImageMeta into mysql"
     343        self.logger.debugPair("inserted into mysql", "ImageMeta")
    344344
    345345        self.scratchDb.updateRecalStats(tableName, header['IMAGEID'], str(pltscale));
     
    347347        self.scratchDb.updateAllRows(tableName, "processingVersion", str(self.skychunk.processingVersion))
    348348
    349         print "---- updated things"
    350 
    351349        if 'NASTRO' in header: self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO'])
    352350        self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0")
    353351
    354         print "---- completed ImageMeta"
     352        self.logger.debugPair("completed", "ImageMeta")
    355353        return True
    356354
     
    691689                for y in range(self.startY, self.endY):
    692690                   
     691                    ## for a quick test, just do the first chip:
     692                    if self.config.test and self.config.camera == "gpc1":
     693                        if x != 0 or y != 1: continue
     694
    693695                    # dodge the corners
    694696                    if x==0 and y==0: continue
     
    717719        for x in range(self.startX, self.endX):
    718720            for y in range(self.startY, self.endY):
     721
     722                ## for a quick test, just do the first chip:
     723                if self.config.test and self.config.camera == "gpc1":
     724                    if x != 0 or y != 1: continue
    719725
    720726                # dodge the corners
     
    927933            for y in range(self.startY, self.endY):
    928934               
     935                ## for a quick test, just do the first chip:
     936                if self.config.test and self.config.camera == "gpc1":
     937                    if x != 0 or y != 1: continue
     938
    929939                # dodge the corners
    930940                if x==0 and y==0: continue
     
    10501060    def importIppTables(self, filter=""):
    10511061       
    1052         regex = ".*.psf"
     1062        ## XXX does the regex work?
     1063        regex = "XY*"
    10531064   
    1054         if False and self.config.test and self.config.camera == "gpc1":
    1055             regex = "XY01.psf"
     1065        ## for a quick test, just do the first chip:
     1066        if self.config.test and self.config.camera == "gpc1":
     1067            regex = "XY01*"
    10561068           
    10571069        print "my ID: " + str(self.id)
     
    10661078            #### crap crap crap
    10671079
    1068         regex = ".*"
     1080        ## this is apparently over-riding the choices above
     1081        ## regex = ".*"
     1082
     1083        ## the list of columns above works fine for *.psf, but breaks the *.deteff tables
     1084        ## just read all columns
    10691085        columns = "*"
    10701086
  • trunk/ippToPsps/jython/gpc1db.py

    r38960 r38973  
    170170                   GROUP BY stage_id"
    171171
    172         try:
    173             rs = self.executeQuery(sql)
    174 
    175         except:
    176             self.logger.exception("Can't query for ids in DVO")
    177             self.logger.infoPair("failed sql:", sql)
    178             sys.exit(1)
     172        self.logger.debug("SQL: " + sql)
     173        rs = self.executeQuery(sql)
    179174
    180175        while (rs.next()):
  • trunk/ippToPsps/jython/pslogger.py

    r35417 r38973  
    1111   This will default to stout and no file output
    1212   '''
    13    def setup(self, programName, basePath, skychunkName, host, pid, stdout=1, sendToFile=0):
     13   def setup(self, programName, basePath, skychunkName, host, pid, loggerLevel, stdout=1, sendToFile=0):
    1414
    1515       formatter = logging.Formatter('%(asctime)s.%(msecs)03d | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S')
    16        self.setLevel(logging.INFO)
     16       self.setLevel(loggerLevel)
    1717
    1818       if sendToFile:
     
    3434       if sendToFile: print "Writing log to: " + FULLPATH
    3535
     36   def debugPair(self, first, second):
     37       self.debug("%-40s%s" % (first, second))
     38
    3639   def infoPair(self, first, second):
    3740       self.info("%-40s%s" % (first, second))
    3841
     42   def warningPair(self, first, second):
     43       self.warning("%-40s%s" % (first, second))
     44
    3945   def errorPair(self, first, second):
    4046       self.error("%-40s%s" % (first, second))
    41 
    42    def debugPair(self, first, second):
    43        self.debug("%-40s%s" % (first, second))
    4447
    4548   def infoTitle(self, str):
  • trunk/ippToPsps/jython/testCode.py

    r38939 r38973  
    55# import time
    66import sys
    7 # import os
     7import os
    88import math
    9 # import logging.config
    109
    11 # from sqlUtility import sqlUtility
     10import stilts
    1211
    1312# testCode class
     
    1817        super(testCode, self).__init__(argv)
    1918
    20     def run(self):
     19    def connectMysql(self, argv):
    2120
    22         # tables = stilts.treads(fileName)
     21        if len(sys.argv) != 6:
     22            print "USAGE: ippjython testCode.py (dbHost) (dbUser) (dbPass) (dbName) (filename)"
     23            os._exit(2)
    2324
    24         for x in range(0, 8):
    25             for y in range(0, 8):
     25        # open config and grab database parameters
     26        self.dbHost = sys.argv[1]
     27        self.dbUser = sys.argv[2]
     28        self.dbPass = sys.argv[3]
     29        self.dbName = sys.argv[4]
    2630
    27                 if not ((x == 0) and (y == 1)):
    28                     print "case 1"
    29                     print "x : " + str(x)
    30                     print "y : " + str(y)
    31                 else:
    32                     print "case 2"
    33                     print "x : " + str(x)
    34                     print "y : " + str(y)
     31        self.filename = sys.argv[5]
     32
     33        # url for mysql / stilts
     34        self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?autoReconnect=true&user="+self.dbUser+"&password="+self.dbPass
     35
     36        ## no need to set up the connection for this test
     37        ## try:
     38        ##     self.con = DriverManager.getConnection(self.url)
     39        ## except:
     40        ##     raise
     41
     42    '''
     43    Accepts a regular expression filter so not all tables need to be imported
     44    '''
     45    def importIppTables(self):
     46
     47        try:
     48            tables = stilts.treads(self.filename)
     49        except:
     50            print "STILTS could not import from " + filename
     51            os._exit(3)
     52
     53        for table in tables:
     54
     55            print "import smf table " + table.name
     56
     57            # need to generate an index on the IPP_IDET column
     58            # table = stilts.tpipe(table, cmd='addcol table_index $0')
     59            table = stilts.tpipe(table, cmd='explodeall')
     60
     61            print "read smf table " + table.name
     62
     63            # drop any previous tables before import
     64            # self.scratchDb.dropTable(table.name)
     65
     66            # limit to specific columns
     67            # table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
     68
     69            # IPP FITS files are littered with infinities, so remove these
     70            print "Removing Infinity values from all columns"
     71            table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
     72            table = stilts.tpipe(table, cmd='replaceval Infinity null *')
     73
     74            try:
     75                table.write(self.url + '#' + table.name)
     76            except:
     77                print "Problem writing table '" + table.name + "' to the database"
     78                os._exit(4)
     79
     80        return True
     81
     82    def run(self, argv):
     83
     84        self.connectMysql(argv)
     85        self.importIppTables()
     86
     87        ## for x in range(0, 8):
     88        ##     for y in range(0, 8):
     89        ##
     90        ##         if not ((x == 0) and (y == 1)):
     91        ##             print "case 1"
     92        ##             print "x : " + str(x)
     93        ##             print "y : " + str(y)
     94        ##         else:
     95        ##             print "case 2"
     96        ##             print "x : " + str(x)
     97        ##             print "y : " + str(y)
    3598
    3699'''
     
    39102try:
    40103    testcode = testCode(sys.argv)
    41     testcode.run()
    42     testcode.exitProgram("completed")
     104    testcode.run(sys.argv)
    43105except: pass
Note: See TracChangeset for help on using the changeset viewer.