- Timestamp:
- May 29, 2012, 5:07:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/ippToPsps/jython/ipptopspsdb.py
r33710 r33948 854 854 return configs 855 855 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 " ********************************************************************" 888 910 889 911 ''' … … 951 973 else: self.config.datastorePublishing = False 952 974 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" 953 978 self.config.dvoLocation = rs.getString(5) 954 979 self.config.minRa = rs.getDouble(6) … … 1255 1280 1256 1281 self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)") 1257 count = 01258 1282 for row in rows: 1259 1283 … … 1262 1286 VALUES (%d, %f, %f)" % (row[0], row[1], row[2]) 1263 1287 self.execute(sql) 1264 count += 11265 1288 except: continue 1266 1289 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) 1268 1292 1269 1293 '''
Note:
See TracChangeset
for help on using the changeset viewer.
