-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUploader.py
263 lines (209 loc) · 10.2 KB
/
Uploader.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
from Readers.ReadEureka import *
import sqlite3
from Uploaders.UploadHanna import *
from Uploaders.UploadEureka import *
from Uploaders.UploadHobo import *
from Uploaders.UploadICP import *
from Uploaders.UploadICPNew import *
from Uploaders.UploadIC import *
from Uploaders.UploadScanFP import *
from Uploaders.UploadScanPAR import *
from Uploaders.UploadScanMaster import *
from Uploaders.UploadElementar import *
from Uploaders.UploadSampleId import *
from Uploaders.UploadAqualog import *
from Uploaders.UploadDOCIsotopes import *
from Uploaders.UploadLachat import *
from Uploaders.UploadNo3 import *
from Uploaders.UploadSrp import *
from Uploaders.UploadTss import *
from Uploaders.UploadWater import *
from Uploaders.UploadQ import *
from Uploaders.UploadSites import *
from Uploaders.UploadYSI import *
from Uploaders.UploadICNew import *
from Uploaders.UploadNewSrp import *
from Uploaders.upload_smartrock import *
from Readers.ReadICP import *
from Readers.ReadICPNew import *
from Readers.ReadIC import *
from Readers.ReadScanFP import *
from Readers.ReadScanPAR import *
from Readers.ReadScanMaster import *
from Readers.ReadElementar import *
from Readers.ReadSampleId import *
from Readers.ReadAqualog import *
from Readers.ReadDOCIsotopes import *
from Readers.ReadLachat import *
from Readers.ReadNo3 import *
from Readers.ReadSrp import *
from Readers.ReadTss import *
from Readers.ReadWater import *
from Readers.ReadQ import *
from Readers.ReadSites import *
from Readers.ReadYSI import *
from Readers.ReadICNew import *
from Readers.ReadNewSrp import *
from Readers.read_smartrock import *
class Uploader:
def __init__(self, database):
self.hannaReader = None
self.database = database
def getProjectId(self):
return self.database.getProjectId()
def uploadFile(self, cursor, filePath, fileOrigin, allowDuplicates):
self.allowDuplicates = allowDuplicates
# try:
if fileOrigin == "field_hanna":
self.hannaReader = ReadHanna(filePath)
hannaUploader = UploaderHanna(cursor, self, self.hannaReader)
# upload the data to the database
hannaUploader.uploadHanna()
hannaUploader.uploadBatch()
hannaUploader.uploadLogs()
if fileOrigin == "field_eureka": # *********************************************************
self.eurekaReader = ReadEureka(filePath)
self.eurekaUploader = UploaderEureka(cursor, self, self.eurekaReader)
self.eurekaUploader.uploadEureka()
self.eurekaUploader.uploadBatch()
self.eurekaUploader.uploadLogs()
if fileOrigin == "field_hobo.csv":
self.hoboReader = ReadHobo(filePath)
self.hoboUploader = UploadHobo(cursor, self, self.hoboReader, "absolute_pressure","hobo_pressure_logs_1", "hobo_pressure_batches_1")
self.hoboUploader.uploadHobo()
self.hoboUploader.uploadBatch()
self.hoboUploader.uploadLogs()
if fileOrigin == "light_hobo":
self.hoboReader = ReadHobo(filePath)
self.hoboUploader = UploadHobo(cursor, self, self.hoboReader, "intensity","hobo_light_logs_1", "hobo_light_batches_1")
self.hoboUploader.uploadHobo()
self.hoboUploader.uploadBatch()
self.hoboUploader.uploadLogs()
if fileOrigin == "dissolved_oxygen_hobo":
self.hoboReader = ReadHobo(filePath)
self.hoboUploader = UploadHobo(cursor, self, self.hoboReader, "dissolved_oxygen_mgl","hobo_oxygen_logs_1", "hobo_oxygen_batches_1")
self.hoboUploader.uploadHobo()
self.hoboUploader.uploadBatch()
self.hoboUploader.uploadLogs()
if fileOrigin == "conductivity_hobo":
self.hoboReader = ReadHobo(filePath)
self.hoboUploader = UploadHobo(cursor, self, self.hoboReader, "conductivity","hobo_conductivity_logs_1", "hobo_conductivity_batches_1")
self.hoboUploader.uploadHobo()
self.hoboUploader.uploadBatch()
self.hoboUploader.uploadLogs()
if fileOrigin == "field_hobo.hobo":
raise RawHoboFileIngested(filePath)
if fileOrigin == "icp":
self.icpReader = ReadICP(filePath)
self.icpUploader = UploadICP(cursor, self, self.icpReader)
self.icpUploader.uploadBatch()
self.icpUploader.uploadReads()
if fileOrigin == "icp_new":
self.icpReader = ReadICPNew(filePath)
self.icpUploader = UploadICPNew(cursor, self, self.icpReader)
self.icpUploader.uploadBatch()
self.icpUploader.uploadReads()
if fileOrigin == "ic":
self.icReader = ReadIC(filePath)
self.icUploader = UploadIC(cursor, self, self.icReader)
self.icUploader.uploadBatch()
self.icUploader.uploadReads()
if fileOrigin == "ic_new":
self.icReader = ReadICNew(filePath)
self.icUploader = UploadICNew(cursor, self, self.icReader)
self.icUploader.uploadBatch()
self.icUploader.uploadReads()
if fileOrigin == "scan.fp":
self.scanFPReader = ReadScanFP(filePath)
self.scanFPUploader = UploadScanFP(cursor, self, self.scanFPReader)
self.scanFPUploader.uploadBatch()
self.scanFPUploader.uploadReads()
if fileOrigin == "scan.par":
self.scanPARReader = ReadScanPAR(filePath)
self.scanPARUploader = UploadScanPAR(cursor, self, self.scanPARReader)
self.scanPARUploader.uploadBatch()
self.scanPARUploader.uploadReads()
if fileOrigin == "masterScan":
self.scanMasterReader = ReadScanMaster(filePath)
self.scanMasterUploader = UploadScanMaster(cursor, self, self.scanMasterReader)
self.scanMasterUploader.uploadBatch()
self.scanMasterUploader.uploadReads()
if fileOrigin == "elementar":
self.elementarReader = ReadElementar(filePath)
self.elementarUploader = UploadElementar(cursor, self, self.elementarReader)
self.elementarUploader.uploadBatch()
self.elementarUploader.uploadReads()
if fileOrigin == "sampleID":
# FIXME automate filling blank tests
# self.filePath = filePath
self.sampleIdReader = ReadSampleId(filePath)
self.sampleIdUploader = UploadSampleId(cursor, self, self.sampleIdReader)
self.sampleIdUploader.uploadBatch()
self.sampleIdUploader.uploadReads()
if fileOrigin == "aqualog":
self.aqualogReader = ReadAqualog(filePath)
self.aqualogUploader = UploadAqualog(cursor, self, self.aqualogReader)
self.aqualogUploader.uploadBatch()
self.aqualogUploader.uploadReads()
if fileOrigin == "docIsotopes":
self.docReader = ReadDOCIsotopes(filePath)
self.docUploader = UploadDOCIsotopes(cursor, self, self.docReader)
self.docUploader.uploadBatch()
self.docUploader.uploadReads()
if fileOrigin == "lachat":
self.lachatReader = ReadLachat(filePath)
self.lachatUploader = UploadLachat(cursor, self, self.lachatReader)
self.lachatUploader.uploadBatch()
self.lachatUploader.uploadReads()
if fileOrigin == "no3":
self.no3Reader = ReadNo3(filePath)
self.no3Uploader = UploadNo3(cursor, self, self.no3Reader)
self.no3Uploader.uploadBatch()
self.no3Uploader.uploadReads()
if fileOrigin == "srp":
self.srpReader = ReadSrp(filePath)
self.srpUploader = UploadSrp(cursor, self, self.srpReader)
self.srpUploader.uploadBatch()
self.srpUploader.uploadReads()
if fileOrigin == "tss":
self.tssReader = ReadTss(filePath)
self.tssUploader = UploadTss(cursor, self, self.tssReader)
self.tssUploader.uploadBatch()
self.tssUploader.uploadReads()
if fileOrigin == "water":
self.waterReader = ReadWater(filePath)
self.waterUploader = UploadWater(cursor, self, self.waterReader)
self.waterUploader.uploadBatch()
self.waterUploader.uploadReads()
if fileOrigin == "q":
self.qReader = ReadQ(filePath)
self.qUploader = UploadQ(cursor, self, self.qReader)
self.qUploader.uploadBatch()
self.qUploader.uploadReads()
if fileOrigin == "YSI":
self.ysiReader = ReadYSI(filePath)
self.ysiUploader = UploadYSI(cursor, self, self.ysiReader)
self.ysiUploader.uploadBatch()
self.ysiUploader.uploadReads()
if fileOrigin == "sites":
self.sitesReader = ReadSites(filePath)
self.sitesUploader = UploadSites(cursor, self, self.sitesReader)
self.sitesUploader.uploadBatch()
self.sitesUploader.uploadReads()
if fileOrigin == "srp_new":
self.newSrpReader = ReadNewSrp(filePath)
self.newSrpUploader = UploadNewSrp(cursor, self, self.newSrpReader)
self.newSrpUploader.uploadBatch()
self.newSrpUploader.uploadReads()
if fileOrigin == "smartrock":
self.smartrock_reader = read_smartrock(filePath)
self.smartrock_uploader = upload_smartrock(cursor, self, self.smartrock_reader)
self.smartrock_uploader.uploadBatch()
self.smartrock_uploader.uploadReads()
# except sqlite3.OperationalError: # FIXME: PUT THIS BACK
# raise DatabaseLocked()
#
# except Error as e:
# print("ERROR in UPLOADER")
# print(type(e))
# raise e