-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdb_test.py
104 lines (58 loc) · 1.97 KB
/
db_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
import sys
#import importlib
import sys
sys.path.append( "../rshlib" )
#import gui
import os
#from time import sleep
#from time import time
import time
import data_point
import db
import logger
import parameters
import moving_average
class TestDB:
"""
test db, data point, average.........
generally using csv or other file for input
also tests data_point
"""
def __init__(self, CSVMode = None ):
"""
"""
self.myParameters = parameters.Parameters( self ) # open early may effect other
self.myLogger = logger.Logger( self )
self.myLogger.open() # later should get file from parameters??
self.name = "TestDB"
self.db = db.DBAccess( self, CSVMode = True )
self.data_point = data_point.DataPoint( )
def logit( self, msg ):
# self.logit( "msg" )
self.myLogger.log( msg )
def test_1( self, ):
"""
"""
timex = 100000.
filein = open( "filein.csv", "r" )
filein = open( "pressure_data_2.csv", "r" )
data = filein.readlines()
app.db.dbConnect()
for i_data in data:
splits = i_data.split( "," )
pdata = splits[0].strip()
tdata = splits[1].strip()
#self.logit( tdata )
self.data_point.parse_test( pdata, tdata ) # for testing time from file
#self.data_point.parse( pdata )
#self.logit( str( self.data_point.pressure ))
app.db.dbNewValues( self.data_point.time, self.data_point.pressure, 0 )
#app.db.dbAddRow( self.data_point.time, self.data_point.pressure, 0 )
app.db.dbClose()
if __name__ == '__main__':
app = TestDB( CSVMode = True )
app.test_1()
app.logit( app.name + ": all done" )
app.myLogger.close()
# ============================= eof ===================