itkdb-gtk 0.10.10.dev5__py3-none-any.whl → 0.10.10.dev7__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/UploadMultipleTests.py +11 -2
- itkdb_gtk/{ModuleVisualInspection.py → VisualInspection.py} +69 -17
- itkdb_gtk/WireBondGui.py +49 -6
- itkdb_gtk/__init__.py +4 -9
- itkdb_gtk/dashBoard.py +28 -4
- {itkdb_gtk-0.10.10.dev5.dist-info → itkdb_gtk-0.10.10.dev7.dist-info}/METADATA +1 -1
- {itkdb_gtk-0.10.10.dev5.dist-info → itkdb_gtk-0.10.10.dev7.dist-info}/RECORD +10 -12
- {itkdb_gtk-0.10.10.dev5.dist-info → itkdb_gtk-0.10.10.dev7.dist-info}/WHEEL +1 -1
- {itkdb_gtk-0.10.10.dev5.dist-info → itkdb_gtk-0.10.10.dev7.dist-info}/entry_points.txt +1 -2
- itkdb_gtk/UploadPetalInformation.py +0 -749
- itkdb_gtk/readAVSdata.py +0 -693
- {itkdb_gtk-0.10.10.dev5.dist-info → itkdb_gtk-0.10.10.dev7.dist-info}/top_level.txt +0 -0
|
@@ -1,749 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Uploads data from AVS pdf."""
|
|
3
|
-
import json
|
|
4
|
-
import sys
|
|
5
|
-
from argparse import ArgumentParser
|
|
6
|
-
from datetime import datetime, timezone
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
import dateutil.parser
|
|
9
|
-
import gi
|
|
10
|
-
|
|
11
|
-
gi.require_version("Gtk", "3.0")
|
|
12
|
-
from gi.repository import Gtk, Gio
|
|
13
|
-
|
|
14
|
-
try:
|
|
15
|
-
import itkdb_gtk
|
|
16
|
-
|
|
17
|
-
except ImportError:
|
|
18
|
-
cwd = Path(__file__).parent.parent
|
|
19
|
-
sys.path.append(cwd.as_posix())
|
|
20
|
-
|
|
21
|
-
from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils, dbGtkUtils
|
|
22
|
-
|
|
23
|
-
def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
|
|
24
|
-
"""Create a DictDialog within a scrolled window.
|
|
25
|
-
|
|
26
|
-
Return:
|
|
27
|
-
------
|
|
28
|
-
scrolled: the scrolled window
|
|
29
|
-
gM: the DictDialog
|
|
30
|
-
|
|
31
|
-
"""
|
|
32
|
-
gM = dbGtkUtils.DictDialog(the_dict, hidden)
|
|
33
|
-
scrolled = Gtk.ScrolledWindow()
|
|
34
|
-
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
|
35
|
-
scrolled.add(gM)
|
|
36
|
-
return scrolled, gM
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def get_type(child):
|
|
40
|
-
"""Return object type
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
child (): object
|
|
44
|
-
|
|
45
|
-
Returns:
|
|
46
|
-
str: object type
|
|
47
|
-
|
|
48
|
-
"""
|
|
49
|
-
if child["type"] is not None:
|
|
50
|
-
ctype = child["type"]["code"]
|
|
51
|
-
else:
|
|
52
|
-
ctype = child["componentType"]["code"]
|
|
53
|
-
|
|
54
|
-
return ctype
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class AVSPanel(dbGtkUtils.ITkDBWindow):
|
|
58
|
-
"""Dialog for interaction with DB."""
|
|
59
|
-
|
|
60
|
-
def __init__(self, session, options):
|
|
61
|
-
"""Initialization."""
|
|
62
|
-
super().__init__(session=session, title="Upload AVS Data", show_search="Click to search SN in DB")
|
|
63
|
-
self.test_uploaded = {}
|
|
64
|
-
self.test_list = []
|
|
65
|
-
self.test_index = {}
|
|
66
|
-
self.test_panel = {}
|
|
67
|
-
self.test_map = {}
|
|
68
|
-
self.petal_core = None
|
|
69
|
-
self.alias = None
|
|
70
|
-
self.petal_weight = -1
|
|
71
|
-
self.DESY_comp = {}
|
|
72
|
-
# self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
# Prepare HeaderBar
|
|
76
|
-
self.hb.props.title = "DB Upload Petal Data"
|
|
77
|
-
|
|
78
|
-
button = Gtk.Button()
|
|
79
|
-
icon = Gio.ThemedIcon(name="document-send-symbolic")
|
|
80
|
-
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
81
|
-
button.add(image)
|
|
82
|
-
button.set_tooltip_text("Click to upload test shown in notebook.")
|
|
83
|
-
button.connect("clicked", self.upload_current_test)
|
|
84
|
-
self.hb.pack_end(button)
|
|
85
|
-
|
|
86
|
-
button = Gtk.Button()
|
|
87
|
-
icon = Gio.ThemedIcon(name="emblem-documents-symbolic")
|
|
88
|
-
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
89
|
-
button.add(image)
|
|
90
|
-
button.set_tooltip_text("Click to upload AVS files.")
|
|
91
|
-
button.connect("clicked", self.upload_avs_files)
|
|
92
|
-
self.hb.pack_end(button)
|
|
93
|
-
|
|
94
|
-
# PS file entry and search button
|
|
95
|
-
self.btnPSF = Gtk.FileChooserButton()
|
|
96
|
-
self.btnPSF.connect("file-set", self.on_psf_set)
|
|
97
|
-
if options.PS:
|
|
98
|
-
ifile = Path(options.PS).expanduser().resolve().as_posix()
|
|
99
|
-
self.btnPSF.set_filename(ifile)
|
|
100
|
-
self.on_psf_set()
|
|
101
|
-
|
|
102
|
-
# FAT file entry and seach buttin
|
|
103
|
-
self.btnFAT = Gtk.FileChooserButton()
|
|
104
|
-
self.btnFAT.connect("file-set", self.on_fat_set)
|
|
105
|
-
if options.FAT:
|
|
106
|
-
ifile = Path(options.FAT).expanduser().resolve().as_posix()
|
|
107
|
-
self.btnFAT.set_filename(ifile)
|
|
108
|
-
|
|
109
|
-
# The Serial number
|
|
110
|
-
self.SN = Gtk.Entry()
|
|
111
|
-
# self.SN.connect("changed", self.SN_changed)
|
|
112
|
-
if options.SN:
|
|
113
|
-
self.SN.set_text(options.SN)
|
|
114
|
-
|
|
115
|
-
# Put the 3 objects in a Grid
|
|
116
|
-
grid = Gtk.Grid(column_spacing=5, row_spacing=1)
|
|
117
|
-
self.mainBox.pack_start(grid, False, True, 0)
|
|
118
|
-
|
|
119
|
-
self.btn_state = Gtk.Button(label="Undef")
|
|
120
|
-
self.btn_state.set_name("btnState")
|
|
121
|
-
self.btn_state.connect("clicked", self.show_state)
|
|
122
|
-
self.btn_state.set_tooltip_text("If green all good. Click to see commnets and defects.")
|
|
123
|
-
|
|
124
|
-
grid.attach(Gtk.Label(label="Serial No."), 0, 0, 1, 1)
|
|
125
|
-
grid.attach(self.SN, 1, 0, 1, 1)
|
|
126
|
-
grid.attach(self.btn_state, 2, 0, 1, 1)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
grid.attach(Gtk.Label(label="Prod. Sheet"), 0, 1, 1, 1)
|
|
130
|
-
grid.attach(self.btnPSF, 1, 1, 1, 1)
|
|
131
|
-
|
|
132
|
-
btn = Gtk.Button(label="Reset")
|
|
133
|
-
btn.connect("clicked", self.on_reset)
|
|
134
|
-
grid.attach(btn, 2, 1, 1, 1)
|
|
135
|
-
|
|
136
|
-
grid.attach(Gtk.Label(label="FAT file"), 0, 2, 1, 1)
|
|
137
|
-
grid.attach(self.btnFAT, 1, 2, 1, 1)
|
|
138
|
-
|
|
139
|
-
# Add a Separator
|
|
140
|
-
self.mainBox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, True, 0)
|
|
141
|
-
|
|
142
|
-
# The notebook
|
|
143
|
-
self.notebook = Gtk.Notebook()
|
|
144
|
-
self.notebook.set_tab_pos(Gtk.PositionType.LEFT)
|
|
145
|
-
self.mainBox.pack_start(self.notebook, True, True, 20)
|
|
146
|
-
|
|
147
|
-
# Create the Notebook pages
|
|
148
|
-
defaults = {
|
|
149
|
-
"institution": "AVS",
|
|
150
|
-
"runNumber": 1,
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
self.manufacture = self.create_test_window(
|
|
154
|
-
ITkDButils.get_test_skeleton(
|
|
155
|
-
self.session, "CORE_PETAL", "MANUFACTURING", defaults),
|
|
156
|
-
"manufacture", "Manufacture")
|
|
157
|
-
|
|
158
|
-
self.weights = self.create_test_window(
|
|
159
|
-
ITkDButils.get_test_skeleton(
|
|
160
|
-
self.session, "CORE_PETAL", "WEIGHING", defaults),
|
|
161
|
-
"weights", "Weights")
|
|
162
|
-
|
|
163
|
-
self.delamination = self.create_test_window(
|
|
164
|
-
ITkDButils.get_test_skeleton(
|
|
165
|
-
self.session, "CORE_PETAL", "DELAMINATION", defaults),
|
|
166
|
-
"delamination", "Delamination")
|
|
167
|
-
|
|
168
|
-
self.grounding = self.create_test_window(
|
|
169
|
-
ITkDButils.get_test_skeleton(
|
|
170
|
-
self.session, "CORE_PETAL", "GROUNDING_CHECK", defaults),
|
|
171
|
-
"grounding", "Grounding")
|
|
172
|
-
|
|
173
|
-
self.metrology = self.create_test_window(
|
|
174
|
-
ITkDButils.get_test_skeleton(
|
|
175
|
-
self.session, "CORE_PETAL", "METROLOGY_AVS", defaults),
|
|
176
|
-
"metrology", "Metrology")
|
|
177
|
-
|
|
178
|
-
self.visual_inspection = self.create_test_window(
|
|
179
|
-
ITkDButils.get_test_skeleton(
|
|
180
|
-
self.session, "CORE_PETAL", "VISUAL_INSPECTION", defaults),
|
|
181
|
-
"visual_inspection", "Visual Inspection")
|
|
182
|
-
|
|
183
|
-
# List componentes
|
|
184
|
-
self.components = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
|
185
|
-
self.components.set_border_width(5)
|
|
186
|
-
self.notebook.append_page(self.components, Gtk.Label(label="Components"))
|
|
187
|
-
|
|
188
|
-
# The button box
|
|
189
|
-
btnBox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
|
|
190
|
-
|
|
191
|
-
# btn = Gtk.Button(label="Reload AVS files")
|
|
192
|
-
# btn.connect("clicked", self.read_avs_files)
|
|
193
|
-
# btnBox.add(btn)
|
|
194
|
-
|
|
195
|
-
btn = Gtk.Button(label="Assemble")
|
|
196
|
-
btn.set_tooltip_text("Assemble components in DB")
|
|
197
|
-
btn.connect("clicked", self.on_assembly)
|
|
198
|
-
btnBox.add(btn)
|
|
199
|
-
|
|
200
|
-
btn = Gtk.Button(label="Check Components")
|
|
201
|
-
btn.set_tooltip_text("Check components in DB")
|
|
202
|
-
btn.connect("clicked", self.on_check_components)
|
|
203
|
-
btnBox.add(btn)
|
|
204
|
-
|
|
205
|
-
btn = Gtk.Button(label="Check Tests")
|
|
206
|
-
btn.set_tooltip_text("Check test results")
|
|
207
|
-
btn.connect("clicked", self.on_check_tests)
|
|
208
|
-
btnBox.add(btn)
|
|
209
|
-
|
|
210
|
-
btn = Gtk.Button(label="Upload Tests")
|
|
211
|
-
btn.set_tooltip_text("Upload all tests")
|
|
212
|
-
|
|
213
|
-
btn.connect("clicked", self.on_upload)
|
|
214
|
-
btnBox.add(btn)
|
|
215
|
-
|
|
216
|
-
self.mainBox.pack_start(btnBox, False, True, 0)
|
|
217
|
-
self.connect("destroy", Gtk.main_quit)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
# The text view
|
|
221
|
-
self.mainBox.pack_start(self.message_panel.frame, True, True, 5)
|
|
222
|
-
|
|
223
|
-
self.show_all()
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
def show_state(self, *arg):
|
|
227
|
-
"""Shows the status"""
|
|
228
|
-
msg = ""
|
|
229
|
-
for test in self.test_list:
|
|
230
|
-
values = test.values
|
|
231
|
-
ndef = len(values["defects"])
|
|
232
|
-
ncomm = len(values["comments"])
|
|
233
|
-
if ndef==0 and ncomm==0:
|
|
234
|
-
continue
|
|
235
|
-
|
|
236
|
-
msg += "{}\n".format(values["testType"])
|
|
237
|
-
if ndef:
|
|
238
|
-
msg += "Defects\n"
|
|
239
|
-
|
|
240
|
-
for D in values["defects"]:
|
|
241
|
-
msg += "{}: {}\n".format(D["name"], D["description"])
|
|
242
|
-
|
|
243
|
-
if ncomm:
|
|
244
|
-
msg += "Comments\n"
|
|
245
|
-
|
|
246
|
-
for C in values["comments"]:
|
|
247
|
-
msg += "{}\n".format(C)
|
|
248
|
-
|
|
249
|
-
msg += "\n"
|
|
250
|
-
|
|
251
|
-
dialog = Gtk.MessageDialog(
|
|
252
|
-
transient_for=self,
|
|
253
|
-
flags=0,
|
|
254
|
-
message_type=Gtk.MessageType.INFO,
|
|
255
|
-
buttons=Gtk.ButtonsType.OK,
|
|
256
|
-
text="Problems found",
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
dialog.format_secondary_text(msg)
|
|
260
|
-
dialog.run()
|
|
261
|
-
dialog.destroy()
|
|
262
|
-
|
|
263
|
-
def on_reset(self, *args):
|
|
264
|
-
"""Reset SN"""
|
|
265
|
-
self.petal_core = None
|
|
266
|
-
self.alias = None
|
|
267
|
-
self.SN.set_text("")
|
|
268
|
-
self.btnPSF.unselect_all()
|
|
269
|
-
self.btnFAT.unselect_all()
|
|
270
|
-
|
|
271
|
-
def create_test_window(self, test_json, test_name, label):
|
|
272
|
-
"""Create the dialog for a DB test and add it to the notebook.
|
|
273
|
-
|
|
274
|
-
Args:
|
|
275
|
-
test_json: The JSon-like dict with the values
|
|
276
|
-
test_name: The name of the test for internal indexing
|
|
277
|
-
label: The label for the Notebook
|
|
278
|
-
|
|
279
|
-
Returns:
|
|
280
|
-
The box containing the data.
|
|
281
|
-
|
|
282
|
-
"""
|
|
283
|
-
scrolled, gM = create_scrolled_dictdialog(test_json)
|
|
284
|
-
self.test_list.append(gM)
|
|
285
|
-
self.test_index[test_name] = len(self.test_list) - 1
|
|
286
|
-
self.test_map[test_json["testType"]] = test_name
|
|
287
|
-
|
|
288
|
-
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
|
289
|
-
box.set_border_width(5)
|
|
290
|
-
box.pack_end(scrolled, True, True, 0)
|
|
291
|
-
box.dict_dialog = gM
|
|
292
|
-
gM.box = box
|
|
293
|
-
self.test_panel[test_name] = box
|
|
294
|
-
self.notebook.append_page(box, Gtk.Label(label=label))
|
|
295
|
-
|
|
296
|
-
return box
|
|
297
|
-
|
|
298
|
-
def update_scroll_window(self, key, data):
|
|
299
|
-
"""Update panel for a given test."""
|
|
300
|
-
scrolled, gM = create_scrolled_dictdialog(data, ("component", "testType"))
|
|
301
|
-
self.test_list[self.test_index[key]] = gM
|
|
302
|
-
dbGtkUtils.replace_in_container(self.test_panel[key], scrolled)
|
|
303
|
-
|
|
304
|
-
def check_register_petal(self, SN):
|
|
305
|
-
"""Register petal core in DB.
|
|
306
|
-
|
|
307
|
-
Args:
|
|
308
|
-
SN: The petal Serial Number.
|
|
309
|
-
|
|
310
|
-
"""
|
|
311
|
-
if self.petal_core:
|
|
312
|
-
return
|
|
313
|
-
|
|
314
|
-
self.find_petal(SN, silent=True)
|
|
315
|
-
if self.petal_core:
|
|
316
|
-
return
|
|
317
|
-
|
|
318
|
-
dialog = Gtk.MessageDialog(
|
|
319
|
-
transient_for=self,
|
|
320
|
-
flags=0,
|
|
321
|
-
message_type=Gtk.MessageType.INFO,
|
|
322
|
-
text="Register Petal Core\n{}".format(SN)
|
|
323
|
-
)
|
|
324
|
-
dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
325
|
-
Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
|
326
|
-
dialog.set_border_width(10)
|
|
327
|
-
dialog.format_secondary_text("Enter Petal Core Alias")
|
|
328
|
-
alias = Gtk.Entry(text=self.alias)
|
|
329
|
-
box = dialog.get_content_area()
|
|
330
|
-
box.add(alias)
|
|
331
|
-
dialog.show_all()
|
|
332
|
-
out = dialog.run()
|
|
333
|
-
if out == Gtk.ResponseType.OK:
|
|
334
|
-
petal_alias = alias.get_text().strip()
|
|
335
|
-
if len(petal_alias) == 0:
|
|
336
|
-
petal_alias = self.alias
|
|
337
|
-
|
|
338
|
-
rc = ITkDButils.registerPetalCore(self.session, SN, petal_alias)
|
|
339
|
-
if rc is None:
|
|
340
|
-
dbGtkUtils.complain("Could not Register petal {} ({})".format(SN, petal_alias))
|
|
341
|
-
|
|
342
|
-
dialog.hide()
|
|
343
|
-
dialog.destroy()
|
|
344
|
-
|
|
345
|
-
def get_app_petal_serial_number(self):
|
|
346
|
-
"""Get the SN from the text box."""
|
|
347
|
-
txt_SN = self.SN.get_text().strip()
|
|
348
|
-
return txt_SN
|
|
349
|
-
|
|
350
|
-
def check_petal_serial_number(self, SN):
|
|
351
|
-
"""Check tha the given SN is consistent."""
|
|
352
|
-
txt_SN = self.get_app_petal_serial_number()
|
|
353
|
-
if txt_SN and len(txt_SN):
|
|
354
|
-
if txt_SN != SN.strip():
|
|
355
|
-
return False
|
|
356
|
-
|
|
357
|
-
else:
|
|
358
|
-
return True
|
|
359
|
-
|
|
360
|
-
else:
|
|
361
|
-
self.check_register_petal(SN)
|
|
362
|
-
self.SN.set_text(SN)
|
|
363
|
-
return True
|
|
364
|
-
|
|
365
|
-
def on_psf_set(self, *args):
|
|
366
|
-
"""Production Sheet file selected."""
|
|
367
|
-
PSF = self.btnPSF.get_filename()
|
|
368
|
-
if PSF is None or not Path(PSF).exists():
|
|
369
|
-
dbGtkUtils.complain("Could not find Production File", PSF, parent=self)
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
try:
|
|
373
|
-
manuf_json, weights_json, self.DESY_comp, self.alias = readAVSdata.readProductionSheet(self.session, PSF, "SNnnnn")
|
|
374
|
-
if self.petal_weight > 0:
|
|
375
|
-
weights_json["results"]["WEIGHT_CORE"] = self.petal_weight
|
|
376
|
-
|
|
377
|
-
except readAVSdata.AVSDataException as E:
|
|
378
|
-
dbGtkUtils.complain("Wrong Production Sheet file", str(E))
|
|
379
|
-
self.btnPSF.unselect_all()
|
|
380
|
-
return
|
|
381
|
-
|
|
382
|
-
SN = manuf_json["component"]
|
|
383
|
-
if not self.check_petal_serial_number(SN):
|
|
384
|
-
dbGtkUtils.complain("Inconsistent Serial number found.",
|
|
385
|
-
"Wrong Serial number extracted from the Production Sheet document.\n{}".format(PSF))
|
|
386
|
-
self.btnPSF.unselect_all()
|
|
387
|
-
return
|
|
388
|
-
|
|
389
|
-
scrolled, gM = create_scrolled_dictdialog(manuf_json, ("component", "testType"))
|
|
390
|
-
self.test_list[self.test_index["manufacture"]] = gM
|
|
391
|
-
dbGtkUtils.replace_in_container(self.manufacture, scrolled)
|
|
392
|
-
|
|
393
|
-
scrolled, gM = create_scrolled_dictdialog(weights_json, ("component", "testType"))
|
|
394
|
-
self.test_list[self.test_index["weights"]] = gM
|
|
395
|
-
dbGtkUtils.replace_in_container(self.weights, scrolled)
|
|
396
|
-
|
|
397
|
-
gD = dbGtkUtils.DictDialog(self.DESY_comp)
|
|
398
|
-
dbGtkUtils.replace_in_container(self.components, gD)
|
|
399
|
-
|
|
400
|
-
# Check if we need to assemble the module
|
|
401
|
-
self.check_assembly(self.DESY_comp)
|
|
402
|
-
|
|
403
|
-
self.check_components()
|
|
404
|
-
|
|
405
|
-
def on_fat_set(self, *args):
|
|
406
|
-
"""FAT file selected."""
|
|
407
|
-
FAT = self.btnFAT.get_filename()
|
|
408
|
-
if FAT is None or not Path(FAT).exists():
|
|
409
|
-
dbGtkUtils.complain("Could not find FAT File", FAT, parent=self)
|
|
410
|
-
|
|
411
|
-
try:
|
|
412
|
-
SN = self.get_app_petal_serial_number()
|
|
413
|
-
if SN and not SN.startswith("20USEBC"):
|
|
414
|
-
SN = None
|
|
415
|
-
|
|
416
|
-
j_vi, j_del, j_gnd, j_mtr, batch, self.petal_weight = readAVSdata.readFATfile(self.session, FAT, SN)
|
|
417
|
-
self.test_list[self.test_index["weights"]].set_value("results.WEIGHT_CORE", self.petal_weight)
|
|
418
|
-
|
|
419
|
-
except readAVSdata.AVSDataException as E:
|
|
420
|
-
dbGtkUtils.complain("Wrong FAT file", str(E))
|
|
421
|
-
self.btnFAT.unselect_all()
|
|
422
|
-
return
|
|
423
|
-
|
|
424
|
-
SN = j_vi["component"]
|
|
425
|
-
if not self.check_petal_serial_number(SN):
|
|
426
|
-
dbGtkUtils.complain("Inconsistent Serial number found.",
|
|
427
|
-
"Wrong Serial number extracted from the FAT document.\n{}".format(FAT))
|
|
428
|
-
self.btnFAT.unselect_all()
|
|
429
|
-
return
|
|
430
|
-
|
|
431
|
-
self.update_scroll_window("visual_inspection", j_vi)
|
|
432
|
-
self.update_scroll_window("delamination", j_del)
|
|
433
|
-
self.update_scroll_window("grounding", j_gnd)
|
|
434
|
-
self.update_scroll_window("metrology", j_mtr)
|
|
435
|
-
|
|
436
|
-
self.check_tests(True)
|
|
437
|
-
|
|
438
|
-
def read_avs_files(self, widgets):
|
|
439
|
-
"""Read AVS files."""
|
|
440
|
-
PSF = self.btnPSF.get_filename()
|
|
441
|
-
if PSF is not None:
|
|
442
|
-
self.on_psf_set(None)
|
|
443
|
-
|
|
444
|
-
FAT = self.btnFAT.get_filename()
|
|
445
|
-
if FAT is not None:
|
|
446
|
-
self.on_fat_set(None)
|
|
447
|
-
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
def find_petal(self, SN, silent=False):
|
|
451
|
-
"""Finds petal with given SN."""
|
|
452
|
-
try:
|
|
453
|
-
self.petal_core = ITkDButils.get_DB_component(self.session, SN)
|
|
454
|
-
|
|
455
|
-
except Exception as E:
|
|
456
|
-
if not silent:
|
|
457
|
-
dbGtkUtils.complain("Could not find Petal Core in DB", str(E))
|
|
458
|
-
|
|
459
|
-
self.petal_core = None
|
|
460
|
-
return
|
|
461
|
-
|
|
462
|
-
if self.petal_core is None:
|
|
463
|
-
return
|
|
464
|
-
|
|
465
|
-
try:
|
|
466
|
-
if self.petal_core["type"]["code"] != "CORE_AVS":
|
|
467
|
-
dbGtkUtils.complain("Wrong component type", "This is not an AVS petal core")
|
|
468
|
-
|
|
469
|
-
if self.petal_core["currentStage"]["code"] != "ASSEMBLY":
|
|
470
|
-
dbGtkUtils.complain("Wrong component stage", "Wrong stage: {}".format(self.petal_core["currentStage"]["code"]))
|
|
471
|
-
|
|
472
|
-
self.write_message("{}\n".format(json.dumps(self.petal_core, indent=3)))
|
|
473
|
-
|
|
474
|
-
except KeyError:
|
|
475
|
-
# Petal is not there
|
|
476
|
-
self.petal_core = None
|
|
477
|
-
|
|
478
|
-
def query_db(self, *args):
|
|
479
|
-
"""Called when QueryDB button clicked."""
|
|
480
|
-
SN = self.SN.get_text()
|
|
481
|
-
if len(SN) == 0:
|
|
482
|
-
dbGtkUtils.complain("Empty Serial number",
|
|
483
|
-
"You should enter a valid Serial number for the petal core.",
|
|
484
|
-
parent=self)
|
|
485
|
-
self.petal_core = None
|
|
486
|
-
return
|
|
487
|
-
|
|
488
|
-
# if not checkSerialNumber(SN):
|
|
489
|
-
# dbGtkUtils.complain("Wrong Serial number",
|
|
490
|
-
# "You should enter a valid Serial number for the petal core.",
|
|
491
|
-
# parent=self)
|
|
492
|
-
# return
|
|
493
|
-
self.find_petal(SN)
|
|
494
|
-
|
|
495
|
-
if self.btnFAT.get_filename() is None and self.btnPSF.get_filename() is None:
|
|
496
|
-
# update tests from DB
|
|
497
|
-
for test in self.petal_core["tests"]:
|
|
498
|
-
latest = None
|
|
499
|
-
latest_time = datetime(year=1, month=1, day=1, tzinfo=timezone.utc)
|
|
500
|
-
testType = test["code"]
|
|
501
|
-
for T in test["testRuns"]:
|
|
502
|
-
test_date = dateutil.parser.parse(T["cts"])
|
|
503
|
-
if test_date > latest_time:
|
|
504
|
-
latest_time = test_date
|
|
505
|
-
latest = T["id"]
|
|
506
|
-
|
|
507
|
-
dbT = ITkDButils.get_testrun(self.session, latest)
|
|
508
|
-
testDB = ITkDButils.from_full_test_to_test_data(dbT)
|
|
509
|
-
self.update_scroll_window(self.test_map[testType], testDB)
|
|
510
|
-
|
|
511
|
-
def on_check_components(self, *args):
|
|
512
|
-
"""Button clicked."""
|
|
513
|
-
self.check_components()
|
|
514
|
-
|
|
515
|
-
def check_components(self):
|
|
516
|
-
"""Check that components are in DB."""
|
|
517
|
-
for cmp, cmp_SN in self.DESY_comp.items():
|
|
518
|
-
if not (isinstance(cmp_SN, str) and cmp_SN.startswith("20U")):
|
|
519
|
-
continue
|
|
520
|
-
|
|
521
|
-
out = ITkDButils.get_DB_component(self.session, cmp_SN)
|
|
522
|
-
if out is None:
|
|
523
|
-
self.write_message("{}: not in DB\n".format(cmp))
|
|
524
|
-
else:
|
|
525
|
-
self.write_message("{}: in {}\n".format(cmp, out["currentLocation"]["code"]))
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
def check_assembly(self, components):
|
|
529
|
-
"""Check if we need to assemble components to core."""
|
|
530
|
-
if self.petal_core is None:
|
|
531
|
-
self.query_db()
|
|
532
|
-
if self.petal_core is None:
|
|
533
|
-
return
|
|
534
|
-
|
|
535
|
-
comp_map = {
|
|
536
|
-
"BT_PETAL_FRONT": "FacingFront",
|
|
537
|
-
"BT_PETAL_BACK": "FacingBack",
|
|
538
|
-
"COOLING_LOOP_PETAL": "CoolingLoop",
|
|
539
|
-
"THERMALFOAMSET_PETAL": "AllcompSet"
|
|
540
|
-
}
|
|
541
|
-
final_stage = {
|
|
542
|
-
"BT_PETAL_FRONT": "COMPLETED",
|
|
543
|
-
"BT_PETAL_BACK": "COMPLETED",
|
|
544
|
-
"COOLING_LOOP_PETAL": "CLINCORE",
|
|
545
|
-
"THERMALFOAMSET_PETAL": "IN_CORE"
|
|
546
|
-
}
|
|
547
|
-
missing = []
|
|
548
|
-
for child in self.petal_core["children"]:
|
|
549
|
-
if child["component"] is None:
|
|
550
|
-
if child["type"] is not None:
|
|
551
|
-
ctype = child["type"]["code"]
|
|
552
|
-
else:
|
|
553
|
-
ctype = child["componentType"]["code"]
|
|
554
|
-
|
|
555
|
-
missing.append(ctype)
|
|
556
|
-
|
|
557
|
-
if len(missing) == 0:
|
|
558
|
-
return
|
|
559
|
-
|
|
560
|
-
error_txt = []
|
|
561
|
-
txt = "Click OK to add\n\t{}".format("\n\t".join(missing))
|
|
562
|
-
if dbGtkUtils.ask_for_confirmation("Missing components", txt, parent=self):
|
|
563
|
-
this_petal = self.SN.get_text()
|
|
564
|
-
for cmp in missing:
|
|
565
|
-
SN = components[comp_map[cmp]]
|
|
566
|
-
if SN[0:5] == "20USE":
|
|
567
|
-
rc = ITkDButils.assemble_component(self.session, this_petal, SN)
|
|
568
|
-
if rc is None:
|
|
569
|
-
error_txt.append("Problem assembling {} into Petal\n".format(cmp))
|
|
570
|
-
|
|
571
|
-
# Check for HonneyComb set
|
|
572
|
-
for P in self.petal_core["properties"]:
|
|
573
|
-
if P["code"] == "HC_ID" and P["value"] is None:
|
|
574
|
-
if dbGtkUtils.is_iterable(components["HoneyCombSet"]):
|
|
575
|
-
val = ' '.join(components["HoneyCombSet"])
|
|
576
|
-
else:
|
|
577
|
-
val = str(components["HoneyCombSet"])
|
|
578
|
-
rc = ITkDButils.set_component_property(self.session,
|
|
579
|
-
this_petal,
|
|
580
|
-
"HC_ID",
|
|
581
|
-
val)
|
|
582
|
-
if rc is None:
|
|
583
|
-
error_txt.append("Problems setting HoneyCombSet ID.\n")
|
|
584
|
-
|
|
585
|
-
break
|
|
586
|
-
|
|
587
|
-
# Check the final stage of the assembled objects
|
|
588
|
-
for child in self.petal_core["children"]:
|
|
589
|
-
if child["component"]:
|
|
590
|
-
cSN = child["component"]["serialNumber"]
|
|
591
|
-
ctype = get_type(child)
|
|
592
|
-
cobj = ITkDButils.get_DB_component(self.session, cSN)
|
|
593
|
-
cstage = cobj["currentStage"]['code']
|
|
594
|
-
if cstage != final_stage[ctype]:
|
|
595
|
-
rc = ITkDButils.set_object_stage(self.session, cSN, final_stage[ctype])
|
|
596
|
-
if rc is None:
|
|
597
|
-
print("Could not set final stage of {}".format(cSN))
|
|
598
|
-
|
|
599
|
-
if len(error_txt)>0:
|
|
600
|
-
dbGtkUtils.complain("Assembly of {} could not be completeed:".format(this_petal),
|
|
601
|
-
"\n".join(error_txt))
|
|
602
|
-
|
|
603
|
-
def upload_current_test(self, *args):
|
|
604
|
-
"""Called with upload button clcked."""
|
|
605
|
-
SN = self.SN.get_text()
|
|
606
|
-
if len(SN) == 0:
|
|
607
|
-
dbGtkUtils.complain("Petal SN is empty")
|
|
608
|
-
return
|
|
609
|
-
|
|
610
|
-
def find_children(W):
|
|
611
|
-
try:
|
|
612
|
-
for c in W.get_children():
|
|
613
|
-
if "DictDialog" in c.get_name():
|
|
614
|
-
return c
|
|
615
|
-
|
|
616
|
-
else:
|
|
617
|
-
return find_children(c)
|
|
618
|
-
|
|
619
|
-
except Exception:
|
|
620
|
-
return None
|
|
621
|
-
|
|
622
|
-
return None
|
|
623
|
-
|
|
624
|
-
page = self.notebook.get_nth_page(self.notebook.get_current_page())
|
|
625
|
-
dctD = find_children(page)
|
|
626
|
-
if dctD is None:
|
|
627
|
-
return
|
|
628
|
-
|
|
629
|
-
values = dctD.values
|
|
630
|
-
values["component"] = SN
|
|
631
|
-
print(json.dumps(values, indent=2))
|
|
632
|
-
rc = ITkDButils.upload_test(self.session, values)
|
|
633
|
-
if rc is not None:
|
|
634
|
-
dbGtkUtils.complain("Could not upload test", rc)
|
|
635
|
-
|
|
636
|
-
else:
|
|
637
|
-
dbGtkUtils.ask_for_confirmation("Test uploaded.",
|
|
638
|
-
"{} - {}".format(values["component"], values["testType"]))
|
|
639
|
-
|
|
640
|
-
def upload_avs_files(self, *args):
|
|
641
|
-
"""Called when upload AVS files clicked."""
|
|
642
|
-
SN = self.SN.get_text()
|
|
643
|
-
if len(SN) == 0:
|
|
644
|
-
dbGtkUtils.complain("Petal SN is empty")
|
|
645
|
-
return
|
|
646
|
-
|
|
647
|
-
def upload_file(file_path, title, desc):
|
|
648
|
-
if file_path is not None:
|
|
649
|
-
if not Path(file_path).exists():
|
|
650
|
-
dbGtkUtils.complain("Could not find {}".format(title))
|
|
651
|
-
|
|
652
|
-
else:
|
|
653
|
-
try:
|
|
654
|
-
ITkDButils.create_component_attachment(self.session, SN, file_path, description=desc)
|
|
655
|
-
|
|
656
|
-
except Exception as e:
|
|
657
|
-
dbGtkUtils.complain("Could not Upload {}".format(desc), str(e))
|
|
658
|
-
|
|
659
|
-
PSF = self.btnPSF.get_filename()
|
|
660
|
-
upload_file(PSF, "Production File", "AVS Production file")
|
|
661
|
-
|
|
662
|
-
FAT = self.btnFAT.get_filename()
|
|
663
|
-
upload_file(FAT, "FAT file", "AVS FAT file")
|
|
664
|
-
|
|
665
|
-
def on_check_tests(self, *args):
|
|
666
|
-
"""Button clicked."""
|
|
667
|
-
self.check_tests(True)
|
|
668
|
-
|
|
669
|
-
def check_tests(self, do_write=False):
|
|
670
|
-
"""Check whether all tests are find"""
|
|
671
|
-
nbad = 0
|
|
672
|
-
bad = []
|
|
673
|
-
for test in self.test_list:
|
|
674
|
-
values = test.values
|
|
675
|
-
if not values["passed"]:
|
|
676
|
-
nbad +=1
|
|
677
|
-
bad.append(values["testType"])
|
|
678
|
-
|
|
679
|
-
if nbad:
|
|
680
|
-
dbGtkUtils.set_button_color(self.btn_state, "red", "white")
|
|
681
|
-
self.btn_state.set_label("FAILED")
|
|
682
|
-
else:
|
|
683
|
-
dbGtkUtils.set_button_color(self.btn_state, "green", "white")
|
|
684
|
-
self.btn_state.set_label("PASSED")
|
|
685
|
-
|
|
686
|
-
if do_write:
|
|
687
|
-
if nbad:
|
|
688
|
-
self.write_message("Petal Failed:\n")
|
|
689
|
-
for T in bad:
|
|
690
|
-
self.write_message("\t{}\n".format(T))
|
|
691
|
-
else:
|
|
692
|
-
if len(self.test_list)>0:
|
|
693
|
-
self.write_message("All tests are PASSED\n")
|
|
694
|
-
|
|
695
|
-
return nbad
|
|
696
|
-
|
|
697
|
-
def on_assembly(self, widget):
|
|
698
|
-
"""Assembly button clicked."""
|
|
699
|
-
self.check_assembly(self.DESY_comp)
|
|
700
|
-
|
|
701
|
-
def on_upload(self, widget):
|
|
702
|
-
"""Upload tests to DB."""
|
|
703
|
-
if self.petal_core is None:
|
|
704
|
-
self.query_db()
|
|
705
|
-
if self.petal_core is None:
|
|
706
|
-
return
|
|
707
|
-
|
|
708
|
-
for test in self.test_list:
|
|
709
|
-
values = test.values
|
|
710
|
-
self.write_message("{}\n".format(values["testType"]))
|
|
711
|
-
res = ITkDButils.upload_test(self.session, values, check_runNumber=True)
|
|
712
|
-
if res is not None:
|
|
713
|
-
dbGtkUtils.complain("Could not upload test {}".format(values["testType"]), res)
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
def main():
|
|
717
|
-
"""The main entry."""
|
|
718
|
-
# Parse command line options
|
|
719
|
-
parser = ArgumentParser()
|
|
720
|
-
parser.add_argument('files', nargs='*', help="Input files")
|
|
721
|
-
parser.add_argument("--SN", dest="SN", type=str, default=None,
|
|
722
|
-
help="Module serial number")
|
|
723
|
-
parser.add_argument("--PS", dest="PS", type=str, default=None,
|
|
724
|
-
help="Produc tion Sheet file")
|
|
725
|
-
parser.add_argument("--FAT", dest="FAT", type=str, default=None,
|
|
726
|
-
help="FAT file")
|
|
727
|
-
|
|
728
|
-
options = parser.parse_args()
|
|
729
|
-
|
|
730
|
-
# ITk_PB authentication
|
|
731
|
-
dlg = ITkDBlogin.ITkDBlogin()
|
|
732
|
-
session = dlg.get_client()
|
|
733
|
-
|
|
734
|
-
# Start the Application
|
|
735
|
-
win = AVSPanel(session, options)
|
|
736
|
-
win.show_all()
|
|
737
|
-
win.set_accept_focus(True)
|
|
738
|
-
win.present()
|
|
739
|
-
try:
|
|
740
|
-
Gtk.main()
|
|
741
|
-
except KeyboardInterrupt:
|
|
742
|
-
print("Arrggggg !!!")
|
|
743
|
-
|
|
744
|
-
print("Bye !!")
|
|
745
|
-
dlg.die()
|
|
746
|
-
sys.exit()
|
|
747
|
-
|
|
748
|
-
if __name__ == "__main__":
|
|
749
|
-
main()
|