itkdb-gtk 0.10.9.dev4__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.

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