itkdb-gtk 0.9.0__py3-none-any.whl → 0.10.0.dev2__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 +41 -55
- itkdb_gtk/GetShipments.py +4 -21
- itkdb_gtk/GlueWeight.py +2 -2
- itkdb_gtk/ITkDButils.py +25 -13
- itkdb_gtk/PanelVisualInspection.py +230 -0
- itkdb_gtk/{GroundVITests.py → PetalReceptionTests.py} +7 -6
- itkdb_gtk/SensorUtils.py +490 -0
- itkdb_gtk/UploadModuleIV.py +206 -497
- itkdb_gtk/UploadMultipleTests.py +2 -2
- itkdb_gtk/UploadPetalInformation.py +164 -94
- itkdb_gtk/UploadTest.py +6 -4
- itkdb_gtk/__init__.py +5 -3
- itkdb_gtk/dashBoard.py +13 -12
- itkdb_gtk/dbGtkUtils.py +93 -5
- itkdb_gtk/readAVSdata.py +204 -72
- {itkdb_gtk-0.9.0.dist-info → itkdb_gtk-0.10.0.dev2.dist-info}/METADATA +1 -1
- itkdb_gtk-0.10.0.dev2.dist-info/RECORD +29 -0
- {itkdb_gtk-0.9.0.dist-info → itkdb_gtk-0.10.0.dev2.dist-info}/entry_points.txt +2 -2
- itkdb_gtk-0.9.0.dist-info/RECORD +0 -27
- {itkdb_gtk-0.9.0.dist-info → itkdb_gtk-0.10.0.dev2.dist-info}/WHEEL +0 -0
- {itkdb_gtk-0.9.0.dist-info → itkdb_gtk-0.10.0.dev2.dist-info}/top_level.txt +0 -0
itkdb_gtk/UploadMultipleTests.py
CHANGED
|
@@ -103,14 +103,14 @@ def check_data(data):
|
|
|
103
103
|
class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
104
104
|
"""Collects information to upload a test and its attachments."""
|
|
105
105
|
|
|
106
|
-
def __init__(self, session):
|
|
106
|
+
def __init__(self, session, help=help):
|
|
107
107
|
"""Initialization.
|
|
108
108
|
|
|
109
109
|
Args:
|
|
110
110
|
session: ITkDB session
|
|
111
111
|
|
|
112
112
|
"""
|
|
113
|
-
super().__init__(session=session, title="Upload Tests", gtk_runs=gtk_runs)
|
|
113
|
+
super().__init__(session=session, title="Upload Tests", gtk_runs=gtk_runs, help=help)
|
|
114
114
|
self.tests = []
|
|
115
115
|
|
|
116
116
|
self.init_window()
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import sys
|
|
5
5
|
from argparse import ArgumentParser
|
|
6
|
-
from datetime import datetime
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
9
|
import dateutil.parser
|
|
@@ -20,9 +20,7 @@ except ImportError:
|
|
|
20
20
|
cwd = Path(sys.argv[0]).parent.parent
|
|
21
21
|
sys.path.append(cwd.as_posix())
|
|
22
22
|
|
|
23
|
-
from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils
|
|
24
|
-
from itkdb_gtk.dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
|
|
25
|
-
|
|
23
|
+
from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils, dbGtkUtils
|
|
26
24
|
|
|
27
25
|
def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
|
|
28
26
|
"""Create a DictDialog within a scrolled window.
|
|
@@ -33,7 +31,7 @@ def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
|
|
|
33
31
|
gM: the DictDialog
|
|
34
32
|
|
|
35
33
|
"""
|
|
36
|
-
gM = DictDialog(the_dict, hidden)
|
|
34
|
+
gM = dbGtkUtils.DictDialog(the_dict, hidden)
|
|
37
35
|
scrolled = Gtk.ScrolledWindow()
|
|
38
36
|
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
|
39
37
|
scrolled.add(gM)
|
|
@@ -58,28 +56,26 @@ def get_type(child):
|
|
|
58
56
|
return ctype
|
|
59
57
|
|
|
60
58
|
|
|
61
|
-
class AVSPanel(
|
|
59
|
+
class AVSPanel(dbGtkUtils.ITkDBWindow):
|
|
62
60
|
"""Dialog for interaction with DB."""
|
|
63
61
|
|
|
64
62
|
def __init__(self, session, options):
|
|
65
63
|
"""Initialization."""
|
|
66
|
-
super().__init__(title="Upload AVS Data")
|
|
67
|
-
self.db_session = session
|
|
64
|
+
super().__init__(session=session, title="Upload AVS Data", show_search="Click to search SN in DB")
|
|
68
65
|
self.test_uploaded = {}
|
|
69
66
|
self.test_list = []
|
|
70
67
|
self.test_index = {}
|
|
71
68
|
self.test_panel = {}
|
|
72
69
|
self.test_map = {}
|
|
73
70
|
self.petal_core = None
|
|
71
|
+
self.alias = None
|
|
74
72
|
self.petal_weight = -1
|
|
73
|
+
self.DESY_comp = {}
|
|
75
74
|
# self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
|
76
75
|
|
|
77
76
|
#
|
|
78
77
|
# Prepare HeaderBar
|
|
79
|
-
hb =
|
|
80
|
-
hb.set_show_close_button(True)
|
|
81
|
-
hb.props.title = "DB Upload Petal Data"
|
|
82
|
-
self.set_titlebar(hb)
|
|
78
|
+
self.hb.props.title = "DB Upload Petal Data"
|
|
83
79
|
|
|
84
80
|
button = Gtk.Button()
|
|
85
81
|
icon = Gio.ThemedIcon(name="document-send-symbolic")
|
|
@@ -87,7 +83,7 @@ class AVSPanel(Gtk.Window):
|
|
|
87
83
|
button.add(image)
|
|
88
84
|
button.set_tooltip_text("Click to upload test shown in notebook.")
|
|
89
85
|
button.connect("clicked", self.upload_current_test)
|
|
90
|
-
hb.pack_end(button)
|
|
86
|
+
self.hb.pack_end(button)
|
|
91
87
|
|
|
92
88
|
button = Gtk.Button()
|
|
93
89
|
icon = Gio.ThemedIcon(name="emblem-documents-symbolic")
|
|
@@ -95,24 +91,7 @@ class AVSPanel(Gtk.Window):
|
|
|
95
91
|
button.add(image)
|
|
96
92
|
button.set_tooltip_text("Click to upload AVS files.")
|
|
97
93
|
button.connect("clicked", self.upload_avs_files)
|
|
98
|
-
hb.pack_end(button)
|
|
99
|
-
|
|
100
|
-
button = Gtk.Button()
|
|
101
|
-
icon = Gio.ThemedIcon(name="system-search-symbolic")
|
|
102
|
-
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
103
|
-
button.add(image)
|
|
104
|
-
button.set_tooltip_text("Click to search SN in data base.")
|
|
105
|
-
button.connect("clicked", self.query_db)
|
|
106
|
-
hb.pack_end(button)
|
|
107
|
-
|
|
108
|
-
self.userLabel = Gtk.Label()
|
|
109
|
-
self.userLabel.set_text(session.user.name)
|
|
110
|
-
hb.pack_start(self.userLabel)
|
|
111
|
-
|
|
112
|
-
#
|
|
113
|
-
# Crete man contentt box
|
|
114
|
-
self.mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
|
115
|
-
self.add(self.mainBox)
|
|
94
|
+
self.hb.pack_end(button)
|
|
116
95
|
|
|
117
96
|
# PS file entry and search button
|
|
118
97
|
self.btnPSF = Gtk.FileChooserButton()
|
|
@@ -139,11 +118,20 @@ class AVSPanel(Gtk.Window):
|
|
|
139
118
|
grid = Gtk.Grid(column_spacing=5, row_spacing=1)
|
|
140
119
|
self.mainBox.pack_start(grid, False, True, 0)
|
|
141
120
|
|
|
121
|
+
self.btn_state = Gtk.Button(label="Undef")
|
|
122
|
+
self.btn_state.set_name("btnState")
|
|
123
|
+
|
|
142
124
|
grid.attach(Gtk.Label(label="Serial No."), 0, 0, 1, 1)
|
|
143
125
|
grid.attach(self.SN, 1, 0, 1, 1)
|
|
126
|
+
grid.attach(self.btn_state, 2, 0, 1, 1)
|
|
127
|
+
|
|
144
128
|
|
|
145
129
|
grid.attach(Gtk.Label(label="Prod. Sheet"), 0, 1, 1, 1)
|
|
146
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)
|
|
147
135
|
|
|
148
136
|
grid.attach(Gtk.Label(label="FAT file"), 0, 2, 1, 1)
|
|
149
137
|
grid.attach(self.btnFAT, 1, 2, 1, 1)
|
|
@@ -164,32 +152,32 @@ class AVSPanel(Gtk.Window):
|
|
|
164
152
|
|
|
165
153
|
self.manufacture = self.create_test_window(
|
|
166
154
|
ITkDButils.get_test_skeleton(
|
|
167
|
-
self.
|
|
155
|
+
self.session, "CORE_PETAL", "MANUFACTURING", defaults),
|
|
168
156
|
"manufacture", "Manufacture")
|
|
169
157
|
|
|
170
158
|
self.weights = self.create_test_window(
|
|
171
159
|
ITkDButils.get_test_skeleton(
|
|
172
|
-
self.
|
|
160
|
+
self.session, "CORE_PETAL", "WEIGHING", defaults),
|
|
173
161
|
"weights", "Weights")
|
|
174
162
|
|
|
175
163
|
self.delamination = self.create_test_window(
|
|
176
164
|
ITkDButils.get_test_skeleton(
|
|
177
|
-
self.
|
|
165
|
+
self.session, "CORE_PETAL", "DELAMINATION", defaults),
|
|
178
166
|
"delamination", "Delamination")
|
|
179
167
|
|
|
180
168
|
self.grounding = self.create_test_window(
|
|
181
169
|
ITkDButils.get_test_skeleton(
|
|
182
|
-
self.
|
|
170
|
+
self.session, "CORE_PETAL", "GROUNDING_CHECK", defaults),
|
|
183
171
|
"grounding", "Grounding")
|
|
184
172
|
|
|
185
173
|
self.metrology = self.create_test_window(
|
|
186
174
|
ITkDButils.get_test_skeleton(
|
|
187
|
-
self.
|
|
175
|
+
self.session, "CORE_PETAL", "METROLOGY_AVS", defaults),
|
|
188
176
|
"metrology", "Metrology")
|
|
189
177
|
|
|
190
178
|
self.visual_inspection = self.create_test_window(
|
|
191
179
|
ITkDButils.get_test_skeleton(
|
|
192
|
-
self.
|
|
180
|
+
self.session, "CORE_PETAL", "VISUAL_INSPECTION", defaults),
|
|
193
181
|
"visual_inspection", "Visual Inspection")
|
|
194
182
|
|
|
195
183
|
# List componentes
|
|
@@ -200,29 +188,48 @@ class AVSPanel(Gtk.Window):
|
|
|
200
188
|
# The button box
|
|
201
189
|
btnBox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
|
|
202
190
|
|
|
203
|
-
btn = Gtk.Button(label="Reload AVS files")
|
|
204
|
-
btn.connect("clicked", self.read_avs_files)
|
|
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)
|
|
205
198
|
btnBox.add(btn)
|
|
206
199
|
|
|
207
|
-
btn = Gtk.Button(label="
|
|
208
|
-
btn.
|
|
200
|
+
btn = Gtk.Button(label="Check Components")
|
|
201
|
+
btn.set_tooltip_text("Check components in DB")
|
|
202
|
+
btn.connect("clicked", self.on_check_components)
|
|
209
203
|
btnBox.add(btn)
|
|
210
204
|
|
|
211
|
-
btn = Gtk.Button(label="
|
|
212
|
-
btn.
|
|
205
|
+
btn = Gtk.Button(label="Check Tests")
|
|
206
|
+
btn.set_tooltip_text("Check test results")
|
|
207
|
+
btn.connect("clicked", self.on_check_tests)
|
|
213
208
|
btnBox.add(btn)
|
|
214
209
|
|
|
215
210
|
btn = Gtk.Button(label="Upload Tests")
|
|
211
|
+
btn.set_tooltip_text("Upload all tests")
|
|
212
|
+
|
|
216
213
|
btn.connect("clicked", self.on_upload)
|
|
217
214
|
btnBox.add(btn)
|
|
218
215
|
|
|
219
|
-
btn = Gtk.Button(label="Quit")
|
|
220
|
-
btn.connect("clicked", Gtk.main_quit)
|
|
221
|
-
btnBox.add(btn)
|
|
222
|
-
|
|
223
216
|
self.mainBox.pack_start(btnBox, False, True, 0)
|
|
224
217
|
self.connect("destroy", Gtk.main_quit)
|
|
225
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
|
+
def on_reset(self, *args):
|
|
226
|
+
"""Reset SN"""
|
|
227
|
+
self.petal_core = None
|
|
228
|
+
self.alias = None
|
|
229
|
+
self.SN.set_text("")
|
|
230
|
+
self.btnPSF.unselect_all()
|
|
231
|
+
self.btnFAT.unselect_all()
|
|
232
|
+
|
|
226
233
|
def create_test_window(self, test_json, test_name, label):
|
|
227
234
|
"""Create the dialog for a DB test and add it to the notebook.
|
|
228
235
|
|
|
@@ -254,7 +261,7 @@ class AVSPanel(Gtk.Window):
|
|
|
254
261
|
"""Update panel for a given test."""
|
|
255
262
|
scrolled, gM = create_scrolled_dictdialog(data, ("component", "testType"))
|
|
256
263
|
self.test_list[self.test_index[key]] = gM
|
|
257
|
-
replace_in_container(self.test_panel[key], scrolled)
|
|
264
|
+
dbGtkUtils.replace_in_container(self.test_panel[key], scrolled)
|
|
258
265
|
|
|
259
266
|
def check_register_petal(self, SN):
|
|
260
267
|
"""Register petal core in DB.
|
|
@@ -280,16 +287,19 @@ class AVSPanel(Gtk.Window):
|
|
|
280
287
|
Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
|
281
288
|
dialog.set_border_width(10)
|
|
282
289
|
dialog.format_secondary_text("Enter Petal Core Alias")
|
|
283
|
-
alias = Gtk.Entry()
|
|
290
|
+
alias = Gtk.Entry(text=self.alias)
|
|
284
291
|
box = dialog.get_content_area()
|
|
285
292
|
box.add(alias)
|
|
286
293
|
dialog.show_all()
|
|
287
294
|
out = dialog.run()
|
|
288
295
|
if out == Gtk.ResponseType.OK:
|
|
289
|
-
petal_alias = alias.get_text()
|
|
290
|
-
|
|
296
|
+
petal_alias = alias.get_text().strip()
|
|
297
|
+
if len(petal_alias) == 0:
|
|
298
|
+
petal_alias = self.alias
|
|
299
|
+
|
|
300
|
+
rc = ITkDButils.registerPetalCore(self.session, SN, petal_alias)
|
|
291
301
|
if rc is None:
|
|
292
|
-
complain("Could not Register petal {} ({})".format(SN, petal_alias))
|
|
302
|
+
dbGtkUtils.complain("Could not Register petal {} ({})".format(SN, petal_alias))
|
|
293
303
|
|
|
294
304
|
dialog.hide()
|
|
295
305
|
dialog.destroy()
|
|
@@ -318,62 +328,64 @@ class AVSPanel(Gtk.Window):
|
|
|
318
328
|
"""Production Sheet file selected."""
|
|
319
329
|
PSF = self.btnPSF.get_filename()
|
|
320
330
|
if PSF is None or not Path(PSF).exists():
|
|
321
|
-
complain("Could not find Production File", PSF, parent=self)
|
|
331
|
+
dbGtkUtils.complain("Could not find Production File", PSF, parent=self)
|
|
322
332
|
return
|
|
323
333
|
|
|
324
334
|
try:
|
|
325
|
-
manuf_json, weights_json, self.DESY_comp = readAVSdata.readProductionSheet(self.
|
|
335
|
+
manuf_json, weights_json, self.DESY_comp, self.alias = readAVSdata.readProductionSheet(self.session, PSF, "SNnnnn")
|
|
326
336
|
if self.petal_weight > 0:
|
|
327
337
|
weights_json["results"]["WEIGHT_CORE"] = self.petal_weight
|
|
328
338
|
|
|
329
339
|
except readAVSdata.AVSDataException as E:
|
|
330
|
-
complain("Wrong Production Sheet file", str(E))
|
|
340
|
+
dbGtkUtils.complain("Wrong Production Sheet file", str(E))
|
|
331
341
|
self.btnPSF.unselect_all()
|
|
332
342
|
return
|
|
333
343
|
|
|
334
344
|
SN = manuf_json["component"]
|
|
335
345
|
if not self.check_petal_serial_number(SN):
|
|
336
|
-
complain("Inconsistent Serial number found.",
|
|
346
|
+
dbGtkUtils.complain("Inconsistent Serial number found.",
|
|
337
347
|
"Wrong Serial number extracted from the Production Sheet document.\n{}".format(PSF))
|
|
338
348
|
self.btnPSF.unselect_all()
|
|
339
349
|
return
|
|
340
350
|
|
|
341
351
|
scrolled, gM = create_scrolled_dictdialog(manuf_json, ("component", "testType"))
|
|
342
352
|
self.test_list[self.test_index["manufacture"]] = gM
|
|
343
|
-
replace_in_container(self.manufacture, scrolled)
|
|
353
|
+
dbGtkUtils.replace_in_container(self.manufacture, scrolled)
|
|
344
354
|
|
|
345
355
|
scrolled, gM = create_scrolled_dictdialog(weights_json, ("component", "testType"))
|
|
346
356
|
self.test_list[self.test_index["weights"]] = gM
|
|
347
|
-
replace_in_container(self.weights, scrolled)
|
|
357
|
+
dbGtkUtils.replace_in_container(self.weights, scrolled)
|
|
348
358
|
|
|
349
|
-
gD = DictDialog(self.DESY_comp)
|
|
350
|
-
replace_in_container(self.components, gD)
|
|
359
|
+
gD = dbGtkUtils.DictDialog(self.DESY_comp)
|
|
360
|
+
dbGtkUtils.replace_in_container(self.components, gD)
|
|
351
361
|
|
|
352
362
|
# Check if we need to assemble the module
|
|
353
363
|
self.check_assembly(self.DESY_comp)
|
|
364
|
+
|
|
365
|
+
self.check_components()
|
|
354
366
|
|
|
355
367
|
def on_fat_set(self, *args):
|
|
356
368
|
"""FAT file selected."""
|
|
357
369
|
FAT = self.btnFAT.get_filename()
|
|
358
370
|
if FAT is None or not Path(FAT).exists():
|
|
359
|
-
complain("Could not find FAT File", FAT, parent=self)
|
|
371
|
+
dbGtkUtils.complain("Could not find FAT File", FAT, parent=self)
|
|
360
372
|
|
|
361
373
|
try:
|
|
362
374
|
SN = self.get_app_petal_serial_number()
|
|
363
375
|
if SN and not SN.startswith("20USEBC"):
|
|
364
376
|
SN = None
|
|
365
377
|
|
|
366
|
-
j_vi, j_del, j_gnd, j_mtr, batch, self.petal_weight = readAVSdata.readFATfile(self.
|
|
378
|
+
j_vi, j_del, j_gnd, j_mtr, batch, self.petal_weight = readAVSdata.readFATfile(self.session, FAT, SN)
|
|
367
379
|
self.test_list[self.test_index["weights"]].set_value("results.WEIGHT_CORE", self.petal_weight)
|
|
368
380
|
|
|
369
381
|
except readAVSdata.AVSDataException as E:
|
|
370
|
-
complain("Wrong FAT file", str(E))
|
|
382
|
+
dbGtkUtils.complain("Wrong FAT file", str(E))
|
|
371
383
|
self.btnFAT.unselect_all()
|
|
372
384
|
return
|
|
373
385
|
|
|
374
386
|
SN = j_vi["component"]
|
|
375
387
|
if not self.check_petal_serial_number(SN):
|
|
376
|
-
complain("Inconsistent Serial number found.",
|
|
388
|
+
dbGtkUtils.complain("Inconsistent Serial number found.",
|
|
377
389
|
"Wrong Serial number extracted from the FAT document.\n{}".format(FAT))
|
|
378
390
|
self.btnFAT.unselect_all()
|
|
379
391
|
return
|
|
@@ -382,6 +394,8 @@ class AVSPanel(Gtk.Window):
|
|
|
382
394
|
self.update_scroll_window("delamination", j_del)
|
|
383
395
|
self.update_scroll_window("grounding", j_gnd)
|
|
384
396
|
self.update_scroll_window("metrology", j_mtr)
|
|
397
|
+
|
|
398
|
+
self.check_tests(True)
|
|
385
399
|
|
|
386
400
|
def read_avs_files(self, widgets):
|
|
387
401
|
"""Read AVS files."""
|
|
@@ -398,50 +412,53 @@ class AVSPanel(Gtk.Window):
|
|
|
398
412
|
def find_petal(self, SN, silent=False):
|
|
399
413
|
"""Finds petal with given SN."""
|
|
400
414
|
try:
|
|
401
|
-
self.petal_core = ITkDButils.get_DB_component(self.
|
|
415
|
+
self.petal_core = ITkDButils.get_DB_component(self.session, SN)
|
|
402
416
|
|
|
403
417
|
except Exception as E:
|
|
404
418
|
if not silent:
|
|
405
|
-
complain("Could not find Petal Core in DB", str(E))
|
|
419
|
+
dbGtkUtils.complain("Could not find Petal Core in DB", str(E))
|
|
406
420
|
|
|
407
421
|
self.petal_core = None
|
|
408
422
|
return
|
|
409
423
|
|
|
424
|
+
if self.petal_core is None:
|
|
425
|
+
return
|
|
426
|
+
|
|
410
427
|
try:
|
|
411
428
|
if self.petal_core["type"]["code"] != "CORE_AVS":
|
|
412
|
-
complain("Wrong component type", "This is not an AVS petal core")
|
|
429
|
+
dbGtkUtils.complain("Wrong component type", "This is not an AVS petal core")
|
|
413
430
|
|
|
414
431
|
if self.petal_core["currentStage"]["code"] != "ASSEMBLY":
|
|
415
|
-
complain("Wrong component stage", "Wrong stage: {}".format(self.petal_core["currentStage"]["code"]))
|
|
432
|
+
dbGtkUtils.complain("Wrong component stage", "Wrong stage: {}".format(self.petal_core["currentStage"]["code"]))
|
|
416
433
|
|
|
417
|
-
|
|
434
|
+
self.write_message("{}\n".format(json.dumps(self.petal_core, indent=3)))
|
|
418
435
|
|
|
419
436
|
except KeyError:
|
|
420
437
|
# Petal is not there
|
|
421
438
|
self.petal_core = None
|
|
422
439
|
|
|
423
|
-
def query_db(self,
|
|
440
|
+
def query_db(self, *args):
|
|
424
441
|
"""Called when QueryDB button clicked."""
|
|
425
442
|
SN = self.SN.get_text()
|
|
426
443
|
if len(SN) == 0:
|
|
427
|
-
complain("Empty Serial number",
|
|
444
|
+
dbGtkUtils.complain("Empty Serial number",
|
|
428
445
|
"You should enter a valid Serial number for the petal core.",
|
|
429
446
|
parent=self)
|
|
430
447
|
self.petal_core = None
|
|
431
448
|
return
|
|
432
449
|
|
|
433
450
|
# if not checkSerialNumber(SN):
|
|
434
|
-
# complain("Wrong Serial number",
|
|
451
|
+
# dbGtkUtils.complain("Wrong Serial number",
|
|
435
452
|
# "You should enter a valid Serial number for the petal core.",
|
|
436
453
|
# parent=self)
|
|
437
454
|
# return
|
|
438
|
-
self.find_petal(SN
|
|
455
|
+
self.find_petal(SN)
|
|
439
456
|
|
|
440
457
|
if self.btnFAT.get_filename() is None and self.btnPSF.get_filename() is None:
|
|
441
458
|
# update tests from DB
|
|
442
459
|
for test in self.petal_core["tests"]:
|
|
443
460
|
latest = None
|
|
444
|
-
latest_time = datetime
|
|
461
|
+
latest_time = datetime(year=1, month=1, day=1, tzinfo=timezone.utc)
|
|
445
462
|
testType = test["code"]
|
|
446
463
|
for T in test["testRuns"]:
|
|
447
464
|
test_date = dateutil.parser.parse(T["cts"])
|
|
@@ -449,10 +466,27 @@ class AVSPanel(Gtk.Window):
|
|
|
449
466
|
latest_time = test_date
|
|
450
467
|
latest = T["id"]
|
|
451
468
|
|
|
452
|
-
dbT = ITkDButils.get_testrun(self.
|
|
469
|
+
dbT = ITkDButils.get_testrun(self.session, latest)
|
|
453
470
|
testDB = ITkDButils.from_full_test_to_test_data(dbT)
|
|
454
471
|
self.update_scroll_window(self.test_map[testType], testDB)
|
|
455
472
|
|
|
473
|
+
def on_check_components(self, *args):
|
|
474
|
+
"""Button clicked."""
|
|
475
|
+
self.check_components()
|
|
476
|
+
|
|
477
|
+
def check_components(self):
|
|
478
|
+
"""Check that components are in DB."""
|
|
479
|
+
for cmp, cmp_SN in self.DESY_comp.items():
|
|
480
|
+
if not (isinstance(cmp_SN, str) and cmp_SN.startswith("20U")):
|
|
481
|
+
continue
|
|
482
|
+
|
|
483
|
+
out = ITkDButils.get_DB_component(self.session, cmp_SN)
|
|
484
|
+
if out is None:
|
|
485
|
+
self.write_message("{}: not in DB\n".format(cmp))
|
|
486
|
+
else:
|
|
487
|
+
self.write_message("{}: in {}\n".format(cmp, out["currentLocation"]["code"]))
|
|
488
|
+
|
|
489
|
+
|
|
456
490
|
def check_assembly(self, components):
|
|
457
491
|
"""Check if we need to assemble components to core."""
|
|
458
492
|
if self.petal_core is None:
|
|
@@ -487,24 +521,28 @@ class AVSPanel(Gtk.Window):
|
|
|
487
521
|
|
|
488
522
|
error_txt = []
|
|
489
523
|
txt = "Click OK to add\n\t{}".format("\n\t".join(missing))
|
|
490
|
-
if ask_for_confirmation("Missing components", txt, parent=self):
|
|
524
|
+
if dbGtkUtils.ask_for_confirmation("Missing components", txt, parent=self):
|
|
491
525
|
this_petal = self.SN.get_text()
|
|
492
526
|
for cmp in missing:
|
|
493
527
|
SN = components[comp_map[cmp]]
|
|
494
528
|
if SN[0:5] == "20USE":
|
|
495
|
-
rc = ITkDButils.assemble_component(self.
|
|
529
|
+
rc = ITkDButils.assemble_component(self.session, this_petal, SN)
|
|
496
530
|
if rc is None:
|
|
497
531
|
error_txt.append("Problem assembling {} into Petal\n".format(cmp))
|
|
498
532
|
|
|
499
533
|
# Check for HonneyComb set
|
|
500
534
|
for P in self.petal_core["properties"]:
|
|
501
535
|
if P["code"] == "HC_ID" and P["value"] is None:
|
|
502
|
-
|
|
536
|
+
if dbGtkUtils.is_iterable(components["HoneyCombSet"]):
|
|
537
|
+
val = ' '.join(components["HoneyCombSet"])
|
|
538
|
+
else:
|
|
539
|
+
val = str(components["HoneyCombSet"])
|
|
540
|
+
rc = ITkDButils.set_component_property(self.session,
|
|
503
541
|
this_petal,
|
|
504
542
|
"HC_ID",
|
|
505
|
-
|
|
543
|
+
val)
|
|
506
544
|
if rc is None:
|
|
507
|
-
error_txt.append("Problems setting
|
|
545
|
+
error_txt.append("Problems setting HoneyCombSet ID.\n")
|
|
508
546
|
|
|
509
547
|
break
|
|
510
548
|
|
|
@@ -513,22 +551,22 @@ class AVSPanel(Gtk.Window):
|
|
|
513
551
|
if child["component"]:
|
|
514
552
|
cSN = child["component"]["serialNumber"]
|
|
515
553
|
ctype = get_type(child)
|
|
516
|
-
cobj = ITkDButils.get_DB_component(session, cSN)
|
|
554
|
+
cobj = ITkDButils.get_DB_component(self.session, cSN)
|
|
517
555
|
cstage = cobj["currentStage"]['code']
|
|
518
556
|
if cstage != final_stage[ctype]:
|
|
519
|
-
rc = ITkDButils.set_object_stage(session, cSN, final_stage[ctype])
|
|
557
|
+
rc = ITkDButils.set_object_stage(self.session, cSN, final_stage[ctype])
|
|
520
558
|
if rc is None:
|
|
521
559
|
print("Could not set final stage of {}".format(cSN))
|
|
522
560
|
|
|
523
561
|
if len(error_txt):
|
|
524
|
-
complain("Assembly of {} could not be completeed:".format(this_petal),
|
|
562
|
+
dbGtkUtils.complain("Assembly of {} could not be completeed:".format(this_petal),
|
|
525
563
|
"\n".join(error_txt))
|
|
526
564
|
|
|
527
565
|
def upload_current_test(self, *args):
|
|
528
566
|
"""Called with upload button clcked."""
|
|
529
567
|
SN = self.SN.get_text()
|
|
530
568
|
if len(SN) == 0:
|
|
531
|
-
complain("Petal SN is empty")
|
|
569
|
+
dbGtkUtils.complain("Petal SN is empty")
|
|
532
570
|
return
|
|
533
571
|
|
|
534
572
|
def find_children(W):
|
|
@@ -553,32 +591,32 @@ class AVSPanel(Gtk.Window):
|
|
|
553
591
|
values = dctD.values
|
|
554
592
|
values["component"] = SN
|
|
555
593
|
print(json.dumps(values, indent=2))
|
|
556
|
-
rc = ITkDButils.upload_test(self.
|
|
594
|
+
rc = ITkDButils.upload_test(self.session, values)
|
|
557
595
|
if rc is not None:
|
|
558
|
-
complain("Could not upload test", rc)
|
|
596
|
+
dbGtkUtils.complain("Could not upload test", rc)
|
|
559
597
|
|
|
560
598
|
else:
|
|
561
|
-
ask_for_confirmation("Test uploaded.",
|
|
599
|
+
dbGtkUtils.ask_for_confirmation("Test uploaded.",
|
|
562
600
|
"{} - {}".format(values["component"], values["testType"]))
|
|
563
601
|
|
|
564
602
|
def upload_avs_files(self, *args):
|
|
565
603
|
"""Called when upload AVS files clicked."""
|
|
566
604
|
SN = self.SN.get_text()
|
|
567
605
|
if len(SN) == 0:
|
|
568
|
-
complain("Petal SN is empty")
|
|
606
|
+
dbGtkUtils.complain("Petal SN is empty")
|
|
569
607
|
return
|
|
570
608
|
|
|
571
609
|
def upload_file(file_path, title, desc):
|
|
572
610
|
if file_path is not None:
|
|
573
611
|
if not Path(file_path).exists():
|
|
574
|
-
complain("Could not find {}".format(title))
|
|
612
|
+
dbGtkUtils.complain("Could not find {}".format(title))
|
|
575
613
|
|
|
576
614
|
else:
|
|
577
615
|
try:
|
|
578
|
-
ITkDButils.create_component_attachment(self.
|
|
616
|
+
ITkDButils.create_component_attachment(self.session, SN, file_path, description=desc)
|
|
579
617
|
|
|
580
618
|
except Exception as e:
|
|
581
|
-
complain("Could not Upload {}".format(desc), str(e))
|
|
619
|
+
dbGtkUtils.complain("Could not Upload {}".format(desc), str(e))
|
|
582
620
|
|
|
583
621
|
PSF = self.btnPSF.get_filename()
|
|
584
622
|
upload_file(PSF, "Production File", "AVS Production file")
|
|
@@ -586,6 +624,38 @@ class AVSPanel(Gtk.Window):
|
|
|
586
624
|
FAT = self.btnFAT.get_filename()
|
|
587
625
|
upload_file(FAT, "FAT file", "AVS FAT file")
|
|
588
626
|
|
|
627
|
+
def on_check_tests(self, *args):
|
|
628
|
+
"""Button clicked."""
|
|
629
|
+
self.check_tests(True)
|
|
630
|
+
|
|
631
|
+
def check_tests(self, do_write=False):
|
|
632
|
+
"""Check whether all tests are find"""
|
|
633
|
+
nbad = 0
|
|
634
|
+
bad = []
|
|
635
|
+
for test in self.test_list:
|
|
636
|
+
values = test.values
|
|
637
|
+
if not values["passed"]:
|
|
638
|
+
nbad +=1
|
|
639
|
+
bad.append(values["testType"])
|
|
640
|
+
|
|
641
|
+
if nbad:
|
|
642
|
+
dbGtkUtils.set_button_color(self.btn_state, "red", "white")
|
|
643
|
+
self.btn_state.set_label("FAILED")
|
|
644
|
+
else:
|
|
645
|
+
dbGtkUtils.set_button_color(self.btn_state, "green", "white")
|
|
646
|
+
self.btn_state.set_label("PASSED")
|
|
647
|
+
|
|
648
|
+
if do_write:
|
|
649
|
+
if nbad:
|
|
650
|
+
self.write_message("Petal Failed:\n")
|
|
651
|
+
for T in bad:
|
|
652
|
+
self.write_message("\t{}\n".format(T))
|
|
653
|
+
else:
|
|
654
|
+
if len(self.test_list)>0:
|
|
655
|
+
self.write_message("All tests are PASSED\n")
|
|
656
|
+
|
|
657
|
+
return nbad
|
|
658
|
+
|
|
589
659
|
def on_assembly(self, widget):
|
|
590
660
|
"""Assembly button clicked."""
|
|
591
661
|
self.check_assembly(self.DESY_comp)
|
|
@@ -599,10 +669,10 @@ class AVSPanel(Gtk.Window):
|
|
|
599
669
|
|
|
600
670
|
for test in self.test_list:
|
|
601
671
|
values = test.values
|
|
602
|
-
|
|
603
|
-
res = ITkDButils.upload_test(self.
|
|
672
|
+
self.write_message("{}\n".format(values["testType"]))
|
|
673
|
+
res = ITkDButils.upload_test(self.session, values)
|
|
604
674
|
if res is not None:
|
|
605
|
-
complain("Could not upload test {}".format(values["testType"]), res)
|
|
675
|
+
dbGtkUtils.complain("Could not upload test {}".format(values["testType"]), res)
|
|
606
676
|
|
|
607
677
|
|
|
608
678
|
def main():
|
itkdb_gtk/UploadTest.py
CHANGED
|
@@ -78,7 +78,7 @@ def check_data(data):
|
|
|
78
78
|
class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
79
79
|
"""Collects information to upload a test and its attachments."""
|
|
80
80
|
|
|
81
|
-
def __init__(self, session, payload=None, attachment=None):
|
|
81
|
+
def __init__(self, session, payload=None, attachment=None, help=None):
|
|
82
82
|
"""Initialization.
|
|
83
83
|
|
|
84
84
|
Args:
|
|
@@ -107,7 +107,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
107
107
|
|
|
108
108
|
global gtk_runs
|
|
109
109
|
if gtk_runs:
|
|
110
|
-
super().__init__(session=session, title="Upload Test", gtk_runs=gtk_runs)
|
|
110
|
+
super().__init__(session=session, title="Upload Test", gtk_runs=gtk_runs, help=help)
|
|
111
111
|
self.init_window()
|
|
112
112
|
|
|
113
113
|
def init_window(self):
|
|
@@ -118,7 +118,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
118
118
|
# Prepare HeaderBar
|
|
119
119
|
self.hb.props.title = "Upload Tests"
|
|
120
120
|
|
|
121
|
-
# Active
|
|
121
|
+
# Active button in header
|
|
122
122
|
button = Gtk.Button()
|
|
123
123
|
icon = Gio.ThemedIcon(name="document-send-symbolic")
|
|
124
124
|
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
@@ -353,7 +353,9 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
353
353
|
|
|
354
354
|
def find_attachments(self):
|
|
355
355
|
"""Find Attachments in payload."""
|
|
356
|
-
|
|
356
|
+
# We used to clean the attachmetns, but this would remove the ones given
|
|
357
|
+
# in the contructor.
|
|
358
|
+
# self.attachments = []
|
|
357
359
|
if "attachments" in self.data:
|
|
358
360
|
for A in self.data["attachments"]:
|
|
359
361
|
if not Path(A["path"]).exists():
|
itkdb_gtk/__init__.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
""" itkdb-gtk python module
|
|
2
|
+
"""
|
|
3
|
+
__version__ = "0.10.0.dev2"
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
def dash_board():
|
|
@@ -19,9 +21,9 @@ def glueWeight():
|
|
|
19
21
|
main()
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
def
|
|
24
|
+
def petalReceptionTests():
|
|
23
25
|
"""GND/VI tests."""
|
|
24
|
-
from .
|
|
26
|
+
from .PetalReceptionTests import main
|
|
25
27
|
main()
|
|
26
28
|
|
|
27
29
|
|