- Timestamp:
- Apr 5, 2012, 3:34:14 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/ipptopspsdb.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/ipptopspsdb.py
r33710 r33726 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 response = raw_input(" * Name for new config, or existing config to edit? ") 862 if response == "": return 863 self.config.name = response 864 865 # attempt to insert new config, if it already exists then carry on with update 866 sql = "INSERT INTO config (name) VALUES ('" + self.config.name + "')" 867 try: 868 self.execute(sql) 869 except: pass 870 871 # for each column in the config table 872 sql = "SHOW COLUMNS FROM config" 873 rs = self.executeQuery(sql) 874 while (rs.next()): 875 876 field = rs.getString(1) 877 type = rs.getString(2) 878 null = rs.getString(3) 879 880 # things we don;t want the user to edit 881 if field == 'timestamp': continue 882 if field == 'name': continue 883 884 # get current value for this field, if any 885 try: 886 rs2 = self.executeQuery("SELECT " + field + " FROM config WHERE name = '" + self.config.name + "'") 887 rs2.first() 888 default = rs2.getString(1) 889 except: pass 890 891 question = " * " + field + " (" + type + ")" 892 893 # there may not be a default value 894 try: question = question + " hit return to accept default of: '" + default + "'" 895 except: pass 896 897 # prompt the user for new value or to accept existing value 898 question = question + "? " 899 response = raw_input(question) 900 if response != "": 901 if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'" 902 else: quotes = "" 903 self.execute("UPDATE config SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.config.name + "'") 904 888 905 889 906 '''
Note:
See TracChangeset
for help on using the changeset viewer.
