Changeset 38973
- Timestamp:
- Oct 27, 2015, 2:38:19 PM (11 years ago)
- Location:
- trunk/ippToPsps/jython
- Files:
-
- 6 edited
-
batch.py (modified) (1 diff)
-
config.py (modified) (3 diffs)
-
detectionbatch.py (modified) (7 diffs)
-
gpc1db.py (modified) (1 diff)
-
pslogger.py (modified) (2 diffs)
-
testCode.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/batch.py
r38958 r38973 67 67 logger.errorPair("Could not read FITS PHU for id", "%d" % id) 68 68 raise 69 else: 70 logger.errorPair("missing fits item?", str(id)) 69 71 70 72 # define the dvo table names -
trunk/ippToPsps/jython/config.py
r37355 r38973 28 28 self.onebatch = False 29 29 self.loopBatch = False 30 self.loggerLevel = logging.INFO 30 31 31 32 if sys.argv.count("-test"): … … 66 67 self.loopBatch = True 67 68 sys.argv.remove("-loop") 69 70 if sys.argv.count("-quiet"): 71 self.loggerLevel = logging.WARNING 72 sys.argv.remove("-quiet") 73 74 if sys.argv.count("-debug"): 75 self.loggerLevel = logging.DEBUG 76 sys.argv.remove("-debug") 68 77 69 78 ## name of the top-level jython script … … 121 130 self.logger = logging.getLogger(self.programName) 122 131 if (self.name is None): 123 self.logger.setup(self.programName, self.logPath, "none", host, pid, s tdout, sendToFile)132 self.logger.setup(self.programName, self.logPath, "none", host, pid, self.loggerLevel, stdout, sendToFile) 124 133 else: 125 self.logger.setup(self.programName, self.logPath, self.name, host, pid, s tdout, sendToFile)134 self.logger.setup(self.programName, self.logPath, self.name, host, pid, self.loggerLevel, stdout, sendToFile) 126 135 127 136 return self.logger -
trunk/ippToPsps/jython/detectionbatch.py
r38958 r38973 341 341 self.scratchDb.execute(sql) 342 342 343 print "---- inserted ImageMeta into mysql"343 self.logger.debugPair("inserted into mysql", "ImageMeta") 344 344 345 345 self.scratchDb.updateRecalStats(tableName, header['IMAGEID'], str(pltscale)); … … 347 347 self.scratchDb.updateAllRows(tableName, "processingVersion", str(self.skychunk.processingVersion)) 348 348 349 print "---- updated things"350 351 349 if 'NASTRO' in header: self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO']) 352 350 self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0") 353 351 354 print "---- completed ImageMeta"352 self.logger.debugPair("completed", "ImageMeta") 355 353 return True 356 354 … … 691 689 for y in range(self.startY, self.endY): 692 690 691 ## for a quick test, just do the first chip: 692 if self.config.test and self.config.camera == "gpc1": 693 if x != 0 or y != 1: continue 694 693 695 # dodge the corners 694 696 if x==0 and y==0: continue … … 717 719 for x in range(self.startX, self.endX): 718 720 for y in range(self.startY, self.endY): 721 722 ## for a quick test, just do the first chip: 723 if self.config.test and self.config.camera == "gpc1": 724 if x != 0 or y != 1: continue 719 725 720 726 # dodge the corners … … 927 933 for y in range(self.startY, self.endY): 928 934 935 ## for a quick test, just do the first chip: 936 if self.config.test and self.config.camera == "gpc1": 937 if x != 0 or y != 1: continue 938 929 939 # dodge the corners 930 940 if x==0 and y==0: continue … … 1050 1060 def importIppTables(self, filter=""): 1051 1061 1052 regex = ".*.psf" 1062 ## XXX does the regex work? 1063 regex = "XY*" 1053 1064 1054 if False and self.config.test and self.config.camera == "gpc1": 1055 regex = "XY01.psf" 1065 ## for a quick test, just do the first chip: 1066 if self.config.test and self.config.camera == "gpc1": 1067 regex = "XY01*" 1056 1068 1057 1069 print "my ID: " + str(self.id) … … 1066 1078 #### crap crap crap 1067 1079 1068 regex = ".*" 1080 ## this is apparently over-riding the choices above 1081 ## regex = ".*" 1082 1083 ## the list of columns above works fine for *.psf, but breaks the *.deteff tables 1084 ## just read all columns 1069 1085 columns = "*" 1070 1086 -
trunk/ippToPsps/jython/gpc1db.py
r38960 r38973 170 170 GROUP BY stage_id" 171 171 172 try: 173 rs = self.executeQuery(sql) 174 175 except: 176 self.logger.exception("Can't query for ids in DVO") 177 self.logger.infoPair("failed sql:", sql) 178 sys.exit(1) 172 self.logger.debug("SQL: " + sql) 173 rs = self.executeQuery(sql) 179 174 180 175 while (rs.next()): -
trunk/ippToPsps/jython/pslogger.py
r35417 r38973 11 11 This will default to stout and no file output 12 12 ''' 13 def setup(self, programName, basePath, skychunkName, host, pid, stdout=1, sendToFile=0):13 def setup(self, programName, basePath, skychunkName, host, pid, loggerLevel, stdout=1, sendToFile=0): 14 14 15 15 formatter = logging.Formatter('%(asctime)s.%(msecs)03d | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S') 16 self.setLevel(logg ing.INFO)16 self.setLevel(loggerLevel) 17 17 18 18 if sendToFile: … … 34 34 if sendToFile: print "Writing log to: " + FULLPATH 35 35 36 def debugPair(self, first, second): 37 self.debug("%-40s%s" % (first, second)) 38 36 39 def infoPair(self, first, second): 37 40 self.info("%-40s%s" % (first, second)) 38 41 42 def warningPair(self, first, second): 43 self.warning("%-40s%s" % (first, second)) 44 39 45 def errorPair(self, first, second): 40 46 self.error("%-40s%s" % (first, second)) 41 42 def debugPair(self, first, second):43 self.debug("%-40s%s" % (first, second))44 47 45 48 def infoTitle(self, str): -
trunk/ippToPsps/jython/testCode.py
r38939 r38973 5 5 # import time 6 6 import sys 7 #import os7 import os 8 8 import math 9 # import logging.config10 9 11 # from sqlUtility import sqlUtility 10 import stilts 12 11 13 12 # testCode class … … 18 17 super(testCode, self).__init__(argv) 19 18 20 def run(self):19 def connectMysql(self, argv): 21 20 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) 23 24 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] 26 30 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) 35 98 36 99 ''' … … 39 102 try: 40 103 testcode = testCode(sys.argv) 41 testcode.run() 42 testcode.exitProgram("completed") 104 testcode.run(sys.argv) 43 105 except: pass
Note:
See TracChangeset
for help on using the changeset viewer.
