IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.