itkdb-gtk 0.10.9.dev3__py3-none-any.whl → 0.10.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of itkdb-gtk might be problematic. Click here for more details.
- itkdb_gtk/CreateShipments.py +30 -24
- itkdb_gtk/GetShipments.py +83 -81
- itkdb_gtk/GlueWeight.py +35 -51
- itkdb_gtk/ITkDBlogin.py +6 -2
- itkdb_gtk/ITkDButils.py +138 -19
- itkdb_gtk/PanelVisualInspection.py +258 -73
- itkdb_gtk/PetalReceptionTests.py +20 -11
- itkdb_gtk/SensorUtils.py +16 -14
- itkdb_gtk/ShowAttachments.py +3 -1
- itkdb_gtk/UploadModuleIV.py +8 -8
- itkdb_gtk/UploadMultipleTests.py +174 -109
- itkdb_gtk/UploadTest.py +17 -14
- itkdb_gtk/VisualInspection.py +299 -0
- itkdb_gtk/WireBondGui.py +556 -163
- itkdb_gtk/__init__.py +7 -7
- itkdb_gtk/dashBoard.py +86 -19
- itkdb_gtk/dbGtkUtils.py +79 -25
- {itkdb_gtk-0.10.9.dev3.dist-info → itkdb_gtk-0.10.10.dist-info}/METADATA +1 -1
- itkdb_gtk-0.10.10.dist-info/RECORD +28 -0
- {itkdb_gtk-0.10.9.dev3.dist-info → itkdb_gtk-0.10.10.dist-info}/WHEEL +1 -1
- {itkdb_gtk-0.10.9.dev3.dist-info → itkdb_gtk-0.10.10.dist-info}/entry_points.txt +1 -1
- itkdb_gtk/UploadPetalInformation.py +0 -711
- itkdb_gtk/readAVSdata.py +0 -693
- itkdb_gtk-0.10.9.dev3.dist-info/RECORD +0 -29
- {itkdb_gtk-0.10.9.dev3.dist-info → itkdb_gtk-0.10.10.dist-info}/top_level.txt +0 -0
itkdb_gtk/SensorUtils.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""A collection of utilities for sensor data."""
|
|
3
|
-
import io
|
|
4
3
|
from pathlib import Path
|
|
5
|
-
import numpy as np
|
|
6
4
|
import warnings
|
|
7
|
-
import
|
|
5
|
+
import numpy as np
|
|
8
6
|
from itkdb_gtk import ITkDButils
|
|
9
7
|
|
|
10
8
|
#
|
|
@@ -210,7 +208,7 @@ def LocateMicroDischarge(
|
|
|
210
208
|
V_BDV_ind = V_BDV_ind[ind]
|
|
211
209
|
if V_avg_BD.shape == (0,):
|
|
212
210
|
return NO_BD_CONST
|
|
213
|
-
|
|
211
|
+
|
|
214
212
|
return NO_BD_CONST
|
|
215
213
|
|
|
216
214
|
|
|
@@ -260,8 +258,12 @@ def sensor_data_to_json(session, mdata, mod_type, logger=None):
|
|
|
260
258
|
passed = True
|
|
261
259
|
|
|
262
260
|
# Find Current @ 500V
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
try:
|
|
262
|
+
indx = np.where(V == 500)[0]
|
|
263
|
+
i_500 = I[indx][0] / area
|
|
264
|
+
except IndexError:
|
|
265
|
+
i_500 = 999
|
|
266
|
+
|
|
265
267
|
if logger:
|
|
266
268
|
logger.write_message("I @ 500V = {:.2f} nA/cm2\n".format(i_500))
|
|
267
269
|
|
|
@@ -296,7 +298,7 @@ def sensor_data_to_json(session, mdata, mod_type, logger=None):
|
|
|
296
298
|
)
|
|
297
299
|
if logger:
|
|
298
300
|
logger.write_message("...{}. FAILED\n".format(txt))
|
|
299
|
-
|
|
301
|
+
|
|
300
302
|
passed = False
|
|
301
303
|
else:
|
|
302
304
|
if MicroDischargeV == NO_BD_CONST:
|
|
@@ -388,7 +390,7 @@ def save_sensor_data(fnam, mdata, name=None):
|
|
|
388
390
|
Args:
|
|
389
391
|
fnam: file name or file object.
|
|
390
392
|
mdata (dict): data as returned by :function:`read_sensor_file`
|
|
391
|
-
|
|
393
|
+
|
|
392
394
|
"""
|
|
393
395
|
if hasattr(fnam, "write") and callable(fnam.write):
|
|
394
396
|
data_out = fnam
|
|
@@ -396,17 +398,17 @@ def save_sensor_data(fnam, mdata, name=None):
|
|
|
396
398
|
fnam = name
|
|
397
399
|
else:
|
|
398
400
|
fnam = build_file_name(mdata)
|
|
399
|
-
|
|
401
|
+
|
|
400
402
|
else:
|
|
401
403
|
data_out = open(fnam, 'w', encoding="utf-8")
|
|
402
404
|
fnam = Path(fnam).name
|
|
403
|
-
|
|
405
|
+
|
|
404
406
|
is_module = "Module_SN" in mdata
|
|
405
407
|
if is_module:
|
|
406
408
|
SN = mdata["Module_SN"]
|
|
407
409
|
else:
|
|
408
410
|
SN = mdata["Component"]
|
|
409
|
-
|
|
411
|
+
|
|
410
412
|
if is_module:
|
|
411
413
|
items = [
|
|
412
414
|
"Type",
|
|
@@ -446,7 +448,7 @@ def save_sensor_data(fnam, mdata, name=None):
|
|
|
446
448
|
"Humidity",
|
|
447
449
|
"Comments",
|
|
448
450
|
]
|
|
449
|
-
|
|
451
|
+
|
|
450
452
|
data_out.write("{}\n".format(fnam))
|
|
451
453
|
for key in items:
|
|
452
454
|
if key == "Module_SN" or key == "Component":
|
|
@@ -469,7 +471,7 @@ def save_sensor_data(fnam, mdata, name=None):
|
|
|
469
471
|
V = np.abs(mdata["curve"]["V"])
|
|
470
472
|
I = np.abs(mdata["curve"]["I"])
|
|
471
473
|
S = np.abs(mdata["curve"]["S"])
|
|
472
|
-
|
|
474
|
+
|
|
473
475
|
ndata = len(V)
|
|
474
476
|
for i in range(ndata):
|
|
475
477
|
data_out.write("{:10.2f}\t{:10.2f}\t{:10.2f}\n".format(V[i], I[i], S[i]))
|
|
@@ -487,4 +489,4 @@ def build_file_name(mdata):
|
|
|
487
489
|
SN = mdata["Component"]
|
|
488
490
|
fnam = "{}-W{}_IV_{}".format(mdata["Batch"], mdata["Wafer"], mdata["RunNumber"])
|
|
489
491
|
|
|
490
|
-
return fnam
|
|
492
|
+
return fnam
|
itkdb_gtk/ShowAttachments.py
CHANGED
|
@@ -232,7 +232,9 @@ class ShowAttachments(Gtk.Dialog):
|
|
|
232
232
|
rc = dlg.run()
|
|
233
233
|
if rc == Gtk.ResponseType.OK:
|
|
234
234
|
path = Path(dlg.fC.get_filename())
|
|
235
|
-
A = ITkDButils.Attachment(path,
|
|
235
|
+
A = ITkDButils.Attachment(path=path,
|
|
236
|
+
title=dlg.att_title.get_text().strip(),
|
|
237
|
+
desc=dlg.att_desc.get_text().strip())
|
|
236
238
|
self.append_attachment_to_view(A)
|
|
237
239
|
self.attachments.append(A)
|
|
238
240
|
|
itkdb_gtk/UploadModuleIV.py
CHANGED
|
@@ -16,7 +16,6 @@ import json
|
|
|
16
16
|
import tempfile
|
|
17
17
|
import copy
|
|
18
18
|
from pathlib import Path
|
|
19
|
-
import shutil
|
|
20
19
|
|
|
21
20
|
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
|
|
22
21
|
from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar
|
|
@@ -56,11 +55,12 @@ def remove_files(W, flist):
|
|
|
56
55
|
class IVwindow(dbGtkUtils.ITkDBWindow):
|
|
57
56
|
"""GUI for IV file handling."""
|
|
58
57
|
|
|
59
|
-
def __init__(self, session, title="IV window", options=None,
|
|
58
|
+
def __init__(self, session, title="IV window", options=None, help_link=None):
|
|
60
59
|
"""Initialization."""
|
|
61
|
-
super().__init__(
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
super().__init__(session=session, title=title,
|
|
61
|
+
show_search=None, gtk_runs=gtk_runs,
|
|
62
|
+
help_link=help_link
|
|
63
|
+
)
|
|
64
64
|
self.mdata = {}
|
|
65
65
|
self.mod_type = {}
|
|
66
66
|
self.mod_SN = {}
|
|
@@ -179,7 +179,7 @@ class IVwindow(dbGtkUtils.ITkDBWindow):
|
|
|
179
179
|
js_out.write(json.dumps(test, indent=3, cls=dbGtkUtils.MyEncoder))
|
|
180
180
|
js_out.close()
|
|
181
181
|
|
|
182
|
-
attachment = ITkDButils.Attachment(data_out.name, "resultsFile", fnam)
|
|
182
|
+
attachment = ITkDButils.Attachment(path=data_out.name, title="resultsFile", desc=fnam)
|
|
183
183
|
uploadW = UploadTest.UploadTest(self.session, js_out.name, attachment)
|
|
184
184
|
uploadW.connect("destroy", remove_files, [data_out.name, js_out.name])
|
|
185
185
|
|
|
@@ -247,7 +247,7 @@ class IVwindow(dbGtkUtils.ITkDBWindow):
|
|
|
247
247
|
rc = fc.run()
|
|
248
248
|
if rc == Gtk.ResponseType.OK:
|
|
249
249
|
SensorUtils.save_sensor_data(fc.get_filename(), mdata)
|
|
250
|
-
|
|
250
|
+
|
|
251
251
|
fc.hide()
|
|
252
252
|
fc.destroy()
|
|
253
253
|
|
|
@@ -256,7 +256,7 @@ class IVwindow(dbGtkUtils.ITkDBWindow):
|
|
|
256
256
|
|
|
257
257
|
if do_both.get_active():
|
|
258
258
|
self.upload_test(self.mdata["single"], self.mod_type["single"])
|
|
259
|
-
|
|
259
|
+
|
|
260
260
|
dlg.destroy()
|
|
261
261
|
|
|
262
262
|
def on_refresh(self, *args):
|
itkdb_gtk/UploadMultipleTests.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""GUI to upload tests."""
|
|
3
|
-
import argparse
|
|
4
3
|
import fnmatch
|
|
5
4
|
import json
|
|
6
5
|
import os
|
|
@@ -11,7 +10,6 @@ try:
|
|
|
11
10
|
import itkdb_gtk
|
|
12
11
|
|
|
13
12
|
except ImportError:
|
|
14
|
-
from pathlib import Path
|
|
15
13
|
cwd = Path(__file__).parent.parent
|
|
16
14
|
sys.path.append(cwd.as_posix())
|
|
17
15
|
|
|
@@ -65,7 +63,26 @@ def all_files(root, patterns='*', single_level=False, yield_folders=False):
|
|
|
65
63
|
|
|
66
64
|
|
|
67
65
|
class TestList(object):
|
|
68
|
-
|
|
66
|
+
"""Enumeration with TreeView model columns."""
|
|
67
|
+
(
|
|
68
|
+
SN,
|
|
69
|
+
TestType,
|
|
70
|
+
RunNumber,
|
|
71
|
+
Date,
|
|
72
|
+
Institute,
|
|
73
|
+
Stage,
|
|
74
|
+
currentStage,
|
|
75
|
+
Path,
|
|
76
|
+
Json,
|
|
77
|
+
Nattch,
|
|
78
|
+
Attachments,
|
|
79
|
+
Ncomm,
|
|
80
|
+
Comments,
|
|
81
|
+
Ndef,
|
|
82
|
+
Defects,
|
|
83
|
+
Color,
|
|
84
|
+
ALL,
|
|
85
|
+
) = range(17)
|
|
69
86
|
|
|
70
87
|
|
|
71
88
|
def check_data(data):
|
|
@@ -103,15 +120,18 @@ def check_data(data):
|
|
|
103
120
|
class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
104
121
|
"""Collects information to upload a test and its attachments."""
|
|
105
122
|
|
|
106
|
-
def __init__(self, session,
|
|
123
|
+
def __init__(self, session, help_link=None):
|
|
107
124
|
"""Initialization.
|
|
108
125
|
|
|
109
126
|
Args:
|
|
110
127
|
session: ITkDB session
|
|
111
128
|
|
|
112
129
|
"""
|
|
113
|
-
super().__init__(session=session, title="Upload Tests", gtk_runs=gtk_runs,
|
|
130
|
+
super().__init__(session=session, title="Upload Tests", gtk_runs=gtk_runs, help_link=help_link)
|
|
114
131
|
self.tests = []
|
|
132
|
+
self.data = None
|
|
133
|
+
self.tree = None
|
|
134
|
+
self.def_color = None
|
|
115
135
|
|
|
116
136
|
self.init_window()
|
|
117
137
|
|
|
@@ -173,7 +193,23 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
173
193
|
|
|
174
194
|
def create_tree_view(self, size=150):
|
|
175
195
|
"""Creates the tree vew with the attachments."""
|
|
176
|
-
model = Gtk.ListStore(str,
|
|
196
|
+
model = Gtk.ListStore(str, # SN
|
|
197
|
+
str, # test type
|
|
198
|
+
str, # runNumber
|
|
199
|
+
str, # date
|
|
200
|
+
str, # institute
|
|
201
|
+
str, # stage
|
|
202
|
+
str, # stage
|
|
203
|
+
str, # ifile
|
|
204
|
+
object, # data
|
|
205
|
+
int, # num. attch.
|
|
206
|
+
object, # attachments
|
|
207
|
+
int, # num. comments
|
|
208
|
+
object, # comments
|
|
209
|
+
int, # num defects
|
|
210
|
+
object, # defects
|
|
211
|
+
str # color
|
|
212
|
+
)
|
|
177
213
|
self.tree = Gtk.TreeView(model=model)
|
|
178
214
|
self.tree.connect("button-press-event", self.button_pressed)
|
|
179
215
|
scrolled = Gtk.ScrolledWindow()
|
|
@@ -186,7 +222,8 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
186
222
|
self.tree.append_column(column)
|
|
187
223
|
|
|
188
224
|
renderer = Gtk.CellRendererText()
|
|
189
|
-
|
|
225
|
+
self.def_color = renderer.get_property("foreground-rgba").to_string()
|
|
226
|
+
column = Gtk.TreeViewColumn("Test Type", renderer, text=TestList.TestType, foreground=TestList.Color)
|
|
190
227
|
self.tree.append_column(column)
|
|
191
228
|
|
|
192
229
|
renderer = Gtk.CellRendererText()
|
|
@@ -224,12 +261,12 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
224
261
|
# double click shows attachments
|
|
225
262
|
if event.button == 1 and event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
|
|
226
263
|
select = self.tree.get_selection()
|
|
227
|
-
model,
|
|
228
|
-
if not
|
|
264
|
+
model, lv_iter = select.get_selected()
|
|
265
|
+
if not lv_iter:
|
|
229
266
|
return
|
|
230
267
|
|
|
231
|
-
self.on_show_json(None, (model,
|
|
232
|
-
# self.on_show_attachments(None, (model,
|
|
268
|
+
self.on_show_json(None, (model, lv_iter, model[lv_iter]))
|
|
269
|
+
# self.on_show_attachments(None, (model, lv_iter, model[lv_iter]))
|
|
233
270
|
return
|
|
234
271
|
|
|
235
272
|
if event.button != 3:
|
|
@@ -237,44 +274,44 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
237
274
|
|
|
238
275
|
# Create popup menu
|
|
239
276
|
select = self.tree.get_selection()
|
|
240
|
-
model,
|
|
277
|
+
model, lv_iter = select.get_selected()
|
|
241
278
|
values = None
|
|
242
|
-
if
|
|
243
|
-
values = model[
|
|
279
|
+
if lv_iter:
|
|
280
|
+
values = model[lv_iter]
|
|
244
281
|
|
|
245
|
-
if not
|
|
282
|
+
if not lv_iter:
|
|
246
283
|
P = tree.get_path_at_pos(event.x, event.y)
|
|
247
284
|
if P:
|
|
248
285
|
print(P[0].to_string())
|
|
249
|
-
|
|
250
|
-
values = model[
|
|
286
|
+
lv_iter = model.get_iter(P[0])
|
|
287
|
+
values = model[lv_iter]
|
|
251
288
|
|
|
252
289
|
if not values:
|
|
253
290
|
return
|
|
254
291
|
|
|
255
292
|
menu = Gtk.Menu()
|
|
256
293
|
item_show = Gtk.MenuItem(label="Show JSOn")
|
|
257
|
-
item_show.connect("activate", self.on_show_json, (model,
|
|
294
|
+
item_show.connect("activate", self.on_show_json, (model, lv_iter, values))
|
|
258
295
|
menu.append(item_show)
|
|
259
296
|
|
|
260
297
|
item_set_stage = Gtk.MenuItem(label="Set Stage")
|
|
261
|
-
item_set_stage.connect("activate", self.on_set_stage, (model,
|
|
298
|
+
item_set_stage.connect("activate", self.on_set_stage, (model, lv_iter, values))
|
|
262
299
|
menu.append(item_set_stage)
|
|
263
300
|
|
|
264
301
|
item_show_att = Gtk.MenuItem(label="Edit Attachments")
|
|
265
|
-
item_show_att.connect("activate", self.on_show_attachments, (model,
|
|
302
|
+
item_show_att.connect("activate", self.on_show_attachments, (model, lv_iter, values))
|
|
266
303
|
menu.append(item_show_att)
|
|
267
304
|
|
|
268
305
|
item_show_com = Gtk.MenuItem(label="Edit Comments")
|
|
269
|
-
item_show_com.connect("activate", self.on_show_comments, (model,
|
|
306
|
+
item_show_com.connect("activate", self.on_show_comments, (model, lv_iter, values))
|
|
270
307
|
menu.append(item_show_com)
|
|
271
308
|
|
|
272
309
|
item_show_def = Gtk.MenuItem(label="Edit Defects")
|
|
273
|
-
item_show_def.connect("activate", self.on_show_defects, (model,
|
|
310
|
+
item_show_def.connect("activate", self.on_show_defects, (model, lv_iter, values))
|
|
274
311
|
menu.append(item_show_def)
|
|
275
312
|
|
|
276
313
|
item_del = Gtk.MenuItem(label="Delete")
|
|
277
|
-
item_del.connect("activate", self.on_delete_tests, (model,
|
|
314
|
+
item_del.connect("activate", self.on_delete_tests, (model, lv_iter, values))
|
|
278
315
|
menu.append(item_del)
|
|
279
316
|
menu.show_all()
|
|
280
317
|
|
|
@@ -282,17 +319,17 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
282
319
|
|
|
283
320
|
def on_show_json(self, item, data):
|
|
284
321
|
"""Test JSon."""
|
|
285
|
-
model,
|
|
322
|
+
model, lv_iter, val = data
|
|
286
323
|
payload = val[TestList.Json]
|
|
287
324
|
value, dlg = create_json_data_editor(payload)
|
|
288
325
|
rc = dlg.run()
|
|
289
326
|
if rc == Gtk.ResponseType.OK:
|
|
290
327
|
payload = value.values
|
|
291
|
-
model.set_value(
|
|
292
|
-
model.set_value(
|
|
293
|
-
model.set_value(
|
|
294
|
-
model.set_value(
|
|
295
|
-
model.set_value(
|
|
328
|
+
model.set_value(lv_iter, TestList.Json, payload)
|
|
329
|
+
model.set_value(lv_iter, TestList.SN, payload["component"])
|
|
330
|
+
model.set_value(lv_iter, TestList.RunNumber, payload["runNumber"])
|
|
331
|
+
model.set_value(lv_iter, TestList.Date, handle_test_date(payload["date"]))
|
|
332
|
+
model.set_value(lv_iter, TestList.Institute, handle_test_date(payload["institution"]))
|
|
296
333
|
|
|
297
334
|
|
|
298
335
|
dlg.hide()
|
|
@@ -300,48 +337,48 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
300
337
|
|
|
301
338
|
def on_show_attachments(self, item, data):
|
|
302
339
|
"""Show the attachmetns."""
|
|
303
|
-
model,
|
|
340
|
+
model, lv_iter, val = data
|
|
304
341
|
|
|
305
342
|
SA = ShowAttachments("Test Attachments", self.session, val[TestList.Attachments], parent=self)
|
|
306
343
|
response = SA.run()
|
|
307
344
|
if response == Gtk.ResponseType.OK:
|
|
308
|
-
model.set_value(
|
|
309
|
-
model.set_value(
|
|
345
|
+
model.set_value(lv_iter, TestList.Attachments, SA.attachments)
|
|
346
|
+
model.set_value(lv_iter, TestList.Nattch, len(SA.attachments))
|
|
310
347
|
|
|
311
348
|
SA.hide()
|
|
312
349
|
SA.destroy()
|
|
313
350
|
|
|
314
351
|
def on_show_comments(self, item, data):
|
|
315
352
|
"""Show comments"""
|
|
316
|
-
model,
|
|
353
|
+
model, lv_iter, val = data
|
|
317
354
|
SC = ShowComments("Test Comments", val[TestList.Comments], self)
|
|
318
355
|
rc = SC.run()
|
|
319
356
|
if rc == Gtk.ResponseType.OK:
|
|
320
|
-
model.set_value(
|
|
321
|
-
model.set_value(
|
|
357
|
+
model.set_value(lv_iter, TestList.Comments, SC.comments)
|
|
358
|
+
model.set_value(lv_iter, TestList.Ncomm, len(SC.comments))
|
|
322
359
|
|
|
323
360
|
SC.hide()
|
|
324
361
|
SC.destroy()
|
|
325
362
|
|
|
326
363
|
def on_show_defects(self, item, data):
|
|
327
364
|
"""Show comments"""
|
|
328
|
-
model,
|
|
365
|
+
model, lv_iter, val = data
|
|
329
366
|
SD = ShowDefects("Test Defects", val[TestList.Defects], self)
|
|
330
367
|
rc = SD.run()
|
|
331
368
|
if rc == Gtk.ResponseType.OK:
|
|
332
|
-
model.set_value(
|
|
333
|
-
model.set_value(
|
|
369
|
+
model.set_value(lv_iter, TestList.Defects, SD.defects)
|
|
370
|
+
model.set_value(lv_iter, TestList.Ndef, len(SD.defects))
|
|
334
371
|
|
|
335
372
|
SD.hide()
|
|
336
373
|
SD.destroy()
|
|
337
374
|
|
|
338
375
|
def on_delete_tests(self, item, data):
|
|
339
376
|
"""Test edit."""
|
|
340
|
-
model,
|
|
377
|
+
model, lv_iter, val = data
|
|
341
378
|
rc = dbGtkUtils.ask_for_confirmation("Remove this test?",
|
|
342
379
|
"{} - {}".format(val[TestList.SN], val[TestList.TestType]))
|
|
343
380
|
if rc:
|
|
344
|
-
model.remove(
|
|
381
|
+
model.remove(lv_iter)
|
|
345
382
|
|
|
346
383
|
def get_test_institute(self):
|
|
347
384
|
"""Select an institue."""
|
|
@@ -373,9 +410,9 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
373
410
|
|
|
374
411
|
def on_set_stage(self, item, data):
|
|
375
412
|
"""Set the test stage."""
|
|
376
|
-
model,
|
|
413
|
+
model, lv_iter, val = data
|
|
377
414
|
SN = val[TestList.SN]
|
|
378
|
-
combo,
|
|
415
|
+
combo, _ = self.get_component_stages(SN)
|
|
379
416
|
|
|
380
417
|
dlg = Gtk.Dialog(title="Add Attachment")
|
|
381
418
|
|
|
@@ -392,9 +429,9 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
392
429
|
rc = dlg.run()
|
|
393
430
|
if rc == Gtk.ResponseType.OK:
|
|
394
431
|
new_stage = combo.get_active_text()
|
|
395
|
-
model[
|
|
396
|
-
data = model[
|
|
397
|
-
changed = (new_stage != model[
|
|
432
|
+
model[lv_iter][TestList.Stage] = new_stage
|
|
433
|
+
data = model[lv_iter][TestList.Json]
|
|
434
|
+
changed = (new_stage != model[lv_iter][TestList.currentStage])
|
|
398
435
|
data["isRetroactive"] = changed
|
|
399
436
|
if changed:
|
|
400
437
|
data["stage"] = new_stage
|
|
@@ -402,7 +439,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
402
439
|
if "stage" in data:
|
|
403
440
|
del data["stage"]
|
|
404
441
|
|
|
405
|
-
model[
|
|
442
|
+
model[lv_iter][TestList.Json] = data
|
|
406
443
|
|
|
407
444
|
|
|
408
445
|
dlg.hide()
|
|
@@ -428,66 +465,84 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
428
465
|
return combo, currentStage
|
|
429
466
|
|
|
430
467
|
except Exception:
|
|
431
|
-
self.write_message("Something went
|
|
468
|
+
self.write_message("Something went wrong with the stages\n")
|
|
432
469
|
return [None, None]
|
|
433
470
|
|
|
471
|
+
def add_test_data_to_view(self, data, ifile=None, folder=None):
|
|
472
|
+
"""Add a test data to the tree view."""
|
|
473
|
+
has_errors = False
|
|
474
|
+
default_site = None
|
|
475
|
+
|
|
476
|
+
errors, missing = check_data(data)
|
|
477
|
+
if len(missing) > 0:
|
|
478
|
+
self.write_message("Some keys are missing in the JSon file.\n")
|
|
479
|
+
self.write_message("{}\n".format("\n".join(['\t'+line for line in missing])))
|
|
480
|
+
|
|
481
|
+
if "institution" in missing and len(missing) == 1:
|
|
482
|
+
if default_site is None:
|
|
483
|
+
site, use_default = self.get_test_institute()
|
|
484
|
+
if use_default:
|
|
485
|
+
default_site = site
|
|
486
|
+
else:
|
|
487
|
+
site = default_site
|
|
488
|
+
|
|
489
|
+
if site:
|
|
490
|
+
data["institution"] = site
|
|
491
|
+
self.write_message("Setting Institution to {}\n".format(data["institution"]))
|
|
492
|
+
|
|
493
|
+
else:
|
|
494
|
+
has_errors = True
|
|
495
|
+
dbGtkUtils.complain("Invalid JSON file\n{}".format('\n'.join(errors)),"--")
|
|
496
|
+
|
|
497
|
+
if not has_errors:
|
|
498
|
+
attachments = []
|
|
499
|
+
if "attachments" in data:
|
|
500
|
+
for att in data["attachments"]:
|
|
501
|
+
path = Path(att["path"])
|
|
502
|
+
if path.exists():
|
|
503
|
+
path = path.expanduser().resolve()
|
|
504
|
+
else:
|
|
505
|
+
if folder is not None:
|
|
506
|
+
path = folder / path.name
|
|
507
|
+
|
|
508
|
+
if path.exists():
|
|
509
|
+
attachments.append(ITkDButils.Attachment(path=path,
|
|
510
|
+
title=att["title"],
|
|
511
|
+
desc=att["description"]))
|
|
512
|
+
else:
|
|
513
|
+
self.write_message("Ignoring atachment {}".format(data["path"]))
|
|
514
|
+
|
|
515
|
+
# We need to delete this, which is "unofficial"
|
|
516
|
+
del data["attachments"]
|
|
517
|
+
|
|
518
|
+
model = self.tree.get_model()
|
|
519
|
+
comments = data.get("comments", [])
|
|
520
|
+
defects = data.get("defects", [])
|
|
521
|
+
the_date = handle_test_date(data["date"])
|
|
522
|
+
combo, currentStage = self.get_component_stages(data["component"])
|
|
523
|
+
if data["passed"]:
|
|
524
|
+
if data["problems"]:
|
|
525
|
+
color = "orange"
|
|
526
|
+
else:
|
|
527
|
+
color = self.def_color
|
|
528
|
+
else:
|
|
529
|
+
color = "firebrick"
|
|
530
|
+
|
|
531
|
+
model.append([data["component"], data["testType"], data["runNumber"], the_date,
|
|
532
|
+
data["institution"], currentStage, currentStage,
|
|
533
|
+
ifile, data, len(attachments), attachments,
|
|
534
|
+
len(comments), comments, len(defects), defects, color])
|
|
535
|
+
|
|
434
536
|
def add_tests_to_view(self, files):
|
|
435
537
|
"""Add the input fiels to the treeview."""
|
|
436
|
-
default_site = None
|
|
437
538
|
for ifile in files:
|
|
438
539
|
try:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
self.write_message("Some keys are missing in the JSon file.\n")
|
|
445
|
-
self.write_message("{}\n".format("\n".join(['\t'+line for line in missing])))
|
|
446
|
-
|
|
447
|
-
if "institution" in missing and len(missing) == 1:
|
|
448
|
-
if default_site is None:
|
|
449
|
-
site, use_default = self.get_test_institute()
|
|
450
|
-
if use_default:
|
|
451
|
-
default_site = site
|
|
452
|
-
else:
|
|
453
|
-
site = default_site
|
|
454
|
-
|
|
455
|
-
if site:
|
|
456
|
-
data["institution"] = site
|
|
457
|
-
self.write_message("Setting Institution to {}\n".format(data["institution"]))
|
|
540
|
+
self.write_message("{}\n".format(Path(ifile).name))
|
|
541
|
+
folder = Path(ifile).parent
|
|
542
|
+
|
|
543
|
+
data = json.loads(open(ifile, 'r', encoding="UTF-8").read())
|
|
544
|
+
self.add_test_data_to_view(data, ifile=ifile, folder=folder)
|
|
458
545
|
|
|
459
|
-
else:
|
|
460
|
-
has_errors = True
|
|
461
|
-
dbGtkUtils.complain("Invalid JSON file\n{}".format('\n'.join(errors)), ifile)
|
|
462
|
-
|
|
463
|
-
if not has_errors:
|
|
464
|
-
attachments = []
|
|
465
|
-
if "attachments" in data:
|
|
466
|
-
folder = Path(ifile).parent
|
|
467
|
-
for att in data["attachments"]:
|
|
468
|
-
path = Path(att["path"])
|
|
469
|
-
if path.exists():
|
|
470
|
-
path = path.expanduser().resolve()
|
|
471
|
-
else:
|
|
472
|
-
path = folder / path.name
|
|
473
|
-
|
|
474
|
-
if path.exists():
|
|
475
|
-
attachments.append(ITkDButils.Attachment(path, att["title"], att["description"]))
|
|
476
|
-
else:
|
|
477
|
-
self.write_message("Ignoring atachment {}".format(data["path"]))
|
|
478
|
-
|
|
479
|
-
# We need to delete tis, which is "unofficial"
|
|
480
|
-
del data["attachments"]
|
|
481
|
-
|
|
482
|
-
model = self.tree.get_model()
|
|
483
|
-
comments = data.get("comments", [])
|
|
484
|
-
defects = data.get("defects", [])
|
|
485
|
-
the_date = handle_test_date(data["date"])
|
|
486
|
-
combo, currentStage = self.get_component_stages(data["component"])
|
|
487
|
-
model.append([data["component"], data["testType"], data["runNumber"], the_date,
|
|
488
|
-
data["institution"], currentStage, currentStage,
|
|
489
|
-
ifile, data, len(attachments), attachments,
|
|
490
|
-
len(comments), comments, len(defects), defects])
|
|
491
546
|
|
|
492
547
|
except Exception as E:
|
|
493
548
|
self.write_message("Cannot load file {}\n".format(ifile))
|
|
@@ -596,32 +651,42 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
596
651
|
def upload_test(self):
|
|
597
652
|
"""Uploads tests and attachments."""
|
|
598
653
|
model = self.tree.get_model()
|
|
599
|
-
|
|
600
|
-
|
|
654
|
+
lv_iter = model.get_iter_first()
|
|
655
|
+
ngood = 0
|
|
656
|
+
nbad = 0
|
|
657
|
+
while lv_iter:
|
|
601
658
|
past_iter = None
|
|
602
|
-
values = model[
|
|
659
|
+
values = model[lv_iter]
|
|
603
660
|
payload = values[TestList.Json]
|
|
604
661
|
payload["comments"] = values[TestList.Comments]
|
|
605
662
|
payload["defects"] = values[TestList.Defects]
|
|
606
663
|
|
|
607
|
-
rc = ITkDButils.upload_test(self.session, payload, values[TestList.Attachments])
|
|
664
|
+
rc = ITkDButils.upload_test(self.session, payload, values[TestList.Attachments], check_runNumber=True)
|
|
608
665
|
if rc:
|
|
609
666
|
ipos = rc.find("The following details may help:")
|
|
610
667
|
msg = rc[ipos:]
|
|
611
|
-
dbGtkUtils.complain("Failed uploading test {}-{}".format(payload["component"], payload["testType"])
|
|
612
|
-
self.write_message(msg)
|
|
668
|
+
dbGtkUtils.complain("Failed uploading test {}-{}".format(payload["component"], payload["testType"]))
|
|
669
|
+
self.write_message("Failed uploading test {}-{}\n{}\n".format(payload["component"], payload["testType"], msg))
|
|
670
|
+
nbad += 1
|
|
613
671
|
|
|
614
672
|
else:
|
|
615
673
|
self.write_message("Upload {}-{} successfull\n".format(payload["component"], payload["testType"]))
|
|
616
|
-
past_iter =
|
|
674
|
+
past_iter = lv_iter
|
|
675
|
+
ngood += 1
|
|
617
676
|
|
|
618
|
-
|
|
677
|
+
lv_iter = model.iter_next(lv_iter)
|
|
619
678
|
if past_iter:
|
|
620
679
|
model.remove(past_iter)
|
|
621
680
|
|
|
681
|
+
if nbad>0:
|
|
682
|
+
dbGtkUtils.complain("Failed to upload all tests", "{} test had errors.\nThey are left in the ListView.")
|
|
683
|
+
else:
|
|
684
|
+
dbGtkUtils.complain("All {} tests uploaded succesfully".format(ngood))
|
|
685
|
+
|
|
622
686
|
|
|
623
687
|
def main():
|
|
624
|
-
"""Main entry."""
|
|
688
|
+
"""Main entry."""
|
|
689
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch/uploadMultipleTests.html"
|
|
625
690
|
# DB login
|
|
626
691
|
dlg = ITkDBlogin.ITkDBlogin()
|
|
627
692
|
client = dlg.get_client()
|
|
@@ -633,7 +698,7 @@ def main():
|
|
|
633
698
|
client.user_gui = dlg
|
|
634
699
|
|
|
635
700
|
# Start GUI
|
|
636
|
-
UpT = UploadMultipleTests(client)
|
|
701
|
+
UpT = UploadMultipleTests(client, help_link=HELP_LINK)
|
|
637
702
|
|
|
638
703
|
if gtk_runs:
|
|
639
704
|
UpT.present()
|