Changeset 38973 for trunk/ippToPsps/jython/testCode.py
- Timestamp:
- Oct 27, 2015, 2:38:19 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/testCode.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
