IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 1, 2011, 4:25:54 PM (15 years ago)
Author:
rhenders
Message:

Many things....

File:
1 edited

Legend:

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

    r31105 r31109  
    1616    Constructor
    1717    '''
    18     def __init__(self, batchType, inputFitsPath, outputFitsPath, dbHost, dbName, dbUser, dbPass):
     18    def __init__(self, batchType, inputFitsPath, outputFitsPath, dbHost, dbName, dbUser, dbPass, survey):
    1919
     20        # set up class variables
    2021        self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot"
    2122        self.inputFitsPath = inputFitsPath
     
    2526        self.dbUser = dbUser
    2627        self.dbPass = dbPass
     28        self.survey = survey
     29
     30        # set up JDBC connection
    2731        self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?user="+self.dbUser+"&password="+self.dbPass
    2832        self.con = DriverManager.getConnection(self.url)
     33        self.stmt = self.con.createStatement()
    2934
     35        # get survey ID from init table
     36        sql = "SELECT surveyID from Survey WHERE name = '" + survey + "'"
     37        rs = self.stmt.executeQuery(sql) 
     38        rs.first()
     39        self.surveyID = rs.getInt(1)
     40   
    3041        # store today's date
    3142        now = datetime.datetime.now();
    3243        self.dateStr = now.strftime("%Y-%m-%d")
    3344
    34         self.parseFitsHeader()
     45        if self.inputFitsPath != "":
     46            self.parseFitsHeader()
    3547
    3648    '''
     
    3850    '''
    3951    def __del__(self):
     52
    4053        print "Batch destructor"
     54        self.stmt.close()
    4155        self.con.close()
    4256
     57    '''
     58    Updates a table with surveyID
     59    '''
     60    def updateSurveyID(self, table):
     61
     62        sql = "UPDATE " + table + "  SET surveyID=%d" % self.surveyID
     63        self.stmt.execute(sql)
     64
     65    '''
     66    Updates a table with filterID grabbed from Filter init table
     67    '''
     68    def updateFilterID(self, table):
     69
     70        sql = "UPDATE "+table+" AS a, Filter AS b SET a.filterID=b.filterID WHERE b.filterType = '" + self.filter + "'"
     71        self.stmt.execute(sql)
    4372
    4473    '''
     
    87116             table.write(self.url + '#' + table.name)
    88117
     118         self.indexPspsTables()
     119
     120    '''
     121    Subclass should implement this to index IPP tables
     122    '''   
     123    def indexIppTables(self):
     124        print "indexIppTables not implemented"
     125
     126
     127    '''
     128    Adds an index to the supplied table and column
     129    '''
     130    def createIndex(self, table, column):
     131
     132        print "Creating index on column '"+column+"' for table '"+table+"'"
     133
     134        sql = "CREATE INDEX "+table+"_index ON "+table+" ("+column+")"
     135        try:
     136            self.stmt.execute(sql)
     137        except:
     138            print "Index already in place on '" + column + "' for table '" + table + "'"
     139
     140
     141    '''
     142    Subclass should implement this to index PSPS tables
     143    '''   
     144    def indexPspsTables(self):
     145        print "indexPspsTables not implemented"
     146
     147
    89148    '''
    90149    Imports IPP tables from FITS file
     
    101160          except:
    102161              print "ERROR table " + table.name + " is busted"
     162
     163          self.indexIppTables()
    103164
    104165    '''
Note: See TracChangeset for help on using the changeset viewer.