IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 29, 2012, 5:07:20 PM (14 years ago)
Author:
eugene
Message:

merging changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120405/ippToPsps/jython/ipptopspsdb.py

    r33710 r33948  
    854854        return configs
    855855
    856 
    857     '''
    858     Writes current Config object to Db
    859     '''
    860     def writeConfig(self):
    861 
    862         sql = "UPDATE config \
    863                SET \
    864                datastore_product = '" + self.config.datastoreProduct + "' \
    865                ,datastore_type = '" + self.config.datastoreType + "' \
    866                ,datastore_publish = " + self.config.datastorePublishing + " \
    867                ,dvo_label = '" + self.config.dvoLabel + "' \
    868                ,dvo_location = '" + self.config.dvoLocation + "' \
    869                ,min_ra = " + self.config.minRa + " \
    870                ,max_ra = " + self.config.maxRa + " \
    871                ,min_dec = " + self.config.minDec + " \
    872                ,max_dec = " + self.config.maxDec + " \
    873                ,box_size = " + self.config.boxSize + " \
    874                ,base_path = '" + self.config.basePath + "' \
    875                ,data_release = " + self.config.dataRelease + " \
    876                ,delete_local = " + self.config.deleteLocal + " \
    877                ,delete_datastore = " + self.config.deleteDatastore + " \
    878                ,delete_dxlayer = " + self.config.deleteDxLayer + " \
    879                ,epoch = '" + self.config.epoch + "' \
    880                ,survey = '" + self.config.survey + "' \
    881                ,psps_survey = '" + self.config.pspsSurvey + "' \
    882                ,queue_P2 = " + self.config.queuingThisBatchType("P2") + " \
    883                ,queue_ST = " + self.config.queuingThisBatchType("ST") + " \
    884                ,queue_OB = " + self.config.queuingThisBatchType("OB") + " \
    885                WHERE name = '" + self.config.name + "'"
    886 
    887         self.execute(sql)
     856    '''
     857    Prompts user for info about a new or existing config and lets them neter the various details
     858    '''
     859    def editConfig(self):
     860
     861       print " ********************************************************************"
     862       print " *              Config editor"
     863       print " *"
     864       response = raw_input(" * Name for new config, or existing config to edit? ")
     865       if response == "": return
     866       self.config.name = response
     867
     868       # attempt to insert new config, if it already exists then carry on with update
     869       sql = "INSERT INTO config (name) VALUES ('" + self.config.name + "')"
     870       try:       
     871           self.execute(sql)
     872       except: pass
     873
     874       # for each column in the config table
     875       sql = "SHOW COLUMNS FROM config"
     876       rs = self.executeQuery(sql)
     877       while (rs.next()):
     878
     879           field = rs.getString(1)
     880           type = rs.getString(2)
     881           null = rs.getString(3)
     882
     883           # things we don;t want the user to edit
     884           if field == 'timestamp': continue
     885           if field == 'name': continue
     886
     887           # get current value for this field, if any
     888           try:
     889               rs2 = self.executeQuery("SELECT " + field + " FROM config WHERE name = '" + self.config.name + "'")
     890               rs2.first()
     891               default = rs2.getString(1)
     892           except: pass
     893
     894           question = " * " + field + " (" + type + ")"
     895
     896           # there may not be a default value
     897           try: question = question +  " hit return to accept default of: '" + default + "'"
     898           except: pass
     899
     900           # prompt the user for new value or to accept existing value
     901           question = question +  "? "
     902           response = raw_input(question)
     903           if response != "":
     904               if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'"
     905               else: quotes = ""
     906               self.execute("UPDATE config SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.config.name + "'")
     907       
     908       print " *"
     909       print " ********************************************************************"
    888910
    889911    '''
     
    951973            else: self.config.datastorePublishing = False
    952974            self.config.dvoLabel = rs.getString(4)
     975
     976            # if dvoLabel is null is can break queries, so set to something
     977            if not self.config.dvoLabel: self.config.dvoLabel = "none"
    953978            self.config.dvoLocation = rs.getString(5)
    954979            self.config.minRa = rs.getDouble(6)
     
    12551280
    12561281        self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)")
    1257         count = 0
    12581282        for row in rows:
    12591283
     
    12621286                       VALUES (%d, %f, %f)" % (row[0], row[1], row[2])
    12631287                self.execute(sql)
    1264                 count += 1
    12651288            except: continue
    12661289
    1267         self.logger.infoPair("All items written to Db", "%d" % count)
     1290        count = self.getRowCount("all_pending")
     1291        self.logger.infoPair("Items written to Db", "%d" % count)
    12681292
    12691293    '''
Note: See TracChangeset for help on using the changeset viewer.