itkdb-gtk 0.10.10.dev4__tar.gz → 0.10.10.dev6__tar.gz
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-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/PKG-INFO +1 -1
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/UploadMultipleTests.py +64 -11
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/UploadTest.py +5 -4
- itkdb_gtk-0.10.10.dev6/itkdb_gtk/VisualInspection.py +272 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/WireBondGui.py +296 -148
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/__init__.py +6 -6
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/dashBoard.py +52 -6
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/PKG-INFO +1 -1
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/SOURCES.txt +3 -2
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/entry_points.txt +1 -1
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/pyproject.toml +2 -2
- itkdb_gtk-0.10.10.dev6/test/testRange.py +58 -0
- itkdb_gtk-0.10.10.dev6/test/testThread.py +18 -0
- itkdb_gtk-0.10.10.dev4/itkdb_gtk/UploadPetalInformation.py +0 -749
- itkdb_gtk-0.10.10.dev4/itkdb_gtk/readAVSdata.py +0 -693
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/README.md +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/CreateShipments.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/GetShipments.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/GlueWeight.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ITkDB.desktop +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ITkDB.svg +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ITkDBlogin.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ITkDButils.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/PanelVisualInspection.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/PetalReceptionTests.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/SensorUtils.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ShowAttachments.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ShowComments.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/ShowDefects.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/UploadModuleIV.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/dbGtkUtils.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/readGoogleSheet.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk/untrash_component.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/requires.txt +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/itkdb_gtk.egg-info/top_level.txt +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/setup.cfg +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/test/testAnimated.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/test/testBatch.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/test/testComponent.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/test/test_attachment.py +0 -0
- {itkdb_gtk-0.10.10.dev4 → itkdb_gtk-0.10.10.dev6}/test/test_holes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itkdb_gtk
|
|
3
|
-
Version: 0.10.10.
|
|
3
|
+
Version: 0.10.10.dev6
|
|
4
4
|
Summary: A collection of Gtk based GUI to access ITkDB.
|
|
5
5
|
Author-email: Carlos Lacasta <carlos.lacasta@cern.ch>
|
|
6
6
|
Project-URL: Homepage, https://gitlab.cern.ch/atlas-itk/sw/db/itk-pdb-gtk-gui-utils
|
|
@@ -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
|
|
@@ -64,7 +63,26 @@ def all_files(root, patterns='*', single_level=False, yield_folders=False):
|
|
|
64
63
|
|
|
65
64
|
|
|
66
65
|
class TestList(object):
|
|
67
|
-
|
|
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)
|
|
68
86
|
|
|
69
87
|
|
|
70
88
|
def check_data(data):
|
|
@@ -113,6 +131,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
113
131
|
self.tests = []
|
|
114
132
|
self.data = None
|
|
115
133
|
self.tree = None
|
|
134
|
+
self.def_color = None
|
|
116
135
|
|
|
117
136
|
self.init_window()
|
|
118
137
|
|
|
@@ -174,7 +193,23 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
174
193
|
|
|
175
194
|
def create_tree_view(self, size=150):
|
|
176
195
|
"""Creates the tree vew with the attachments."""
|
|
177
|
-
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
|
+
)
|
|
178
213
|
self.tree = Gtk.TreeView(model=model)
|
|
179
214
|
self.tree.connect("button-press-event", self.button_pressed)
|
|
180
215
|
scrolled = Gtk.ScrolledWindow()
|
|
@@ -187,7 +222,8 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
187
222
|
self.tree.append_column(column)
|
|
188
223
|
|
|
189
224
|
renderer = Gtk.CellRendererText()
|
|
190
|
-
|
|
225
|
+
self.def_color = renderer.get_property("foreground-rgba").to_string()
|
|
226
|
+
column = Gtk.TreeViewColumn("Test Type", renderer, text=TestList.TestType, foreground=TestList.Color)
|
|
191
227
|
self.tree.append_column(column)
|
|
192
228
|
|
|
193
229
|
renderer = Gtk.CellRendererText()
|
|
@@ -376,7 +412,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
376
412
|
"""Set the test stage."""
|
|
377
413
|
model, lv_iter, val = data
|
|
378
414
|
SN = val[TestList.SN]
|
|
379
|
-
combo,
|
|
415
|
+
combo, _ = self.get_component_stages(SN)
|
|
380
416
|
|
|
381
417
|
dlg = Gtk.Dialog(title="Add Attachment")
|
|
382
418
|
|
|
@@ -429,7 +465,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
429
465
|
return combo, currentStage
|
|
430
466
|
|
|
431
467
|
except Exception:
|
|
432
|
-
self.write_message("Something went
|
|
468
|
+
self.write_message("Something went wrong with the stages\n")
|
|
433
469
|
return [None, None]
|
|
434
470
|
|
|
435
471
|
def add_tests_to_view(self, files):
|
|
@@ -473,8 +509,8 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
473
509
|
path = folder / path.name
|
|
474
510
|
|
|
475
511
|
if path.exists():
|
|
476
|
-
attachments.append(ITkDButils.Attachment(path=path,
|
|
477
|
-
title=att["title"],
|
|
512
|
+
attachments.append(ITkDButils.Attachment(path=path,
|
|
513
|
+
title=att["title"],
|
|
478
514
|
desc=att["description"]))
|
|
479
515
|
else:
|
|
480
516
|
self.write_message("Ignoring atachment {}".format(data["path"]))
|
|
@@ -487,10 +523,18 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
487
523
|
defects = data.get("defects", [])
|
|
488
524
|
the_date = handle_test_date(data["date"])
|
|
489
525
|
combo, currentStage = self.get_component_stages(data["component"])
|
|
526
|
+
if data["passed"]:
|
|
527
|
+
if data["problems"]:
|
|
528
|
+
color = "orange"
|
|
529
|
+
else:
|
|
530
|
+
color = self.def_color
|
|
531
|
+
else:
|
|
532
|
+
color = "firebrick"
|
|
533
|
+
|
|
490
534
|
model.append([data["component"], data["testType"], data["runNumber"], the_date,
|
|
491
535
|
data["institution"], currentStage, currentStage,
|
|
492
536
|
ifile, data, len(attachments), attachments,
|
|
493
|
-
len(comments), comments, len(defects), defects])
|
|
537
|
+
len(comments), comments, len(defects), defects, color])
|
|
494
538
|
|
|
495
539
|
except Exception as E:
|
|
496
540
|
self.write_message("Cannot load file {}\n".format(ifile))
|
|
@@ -600,6 +644,8 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
600
644
|
"""Uploads tests and attachments."""
|
|
601
645
|
model = self.tree.get_model()
|
|
602
646
|
lv_iter = model.get_iter_first()
|
|
647
|
+
ngood = 0
|
|
648
|
+
nbad = 0
|
|
603
649
|
while lv_iter:
|
|
604
650
|
past_iter = None
|
|
605
651
|
values = model[lv_iter]
|
|
@@ -611,17 +657,24 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
|
|
|
611
657
|
if rc:
|
|
612
658
|
ipos = rc.find("The following details may help:")
|
|
613
659
|
msg = rc[ipos:]
|
|
614
|
-
dbGtkUtils.complain("Failed uploading test {}-{}".format(payload["component"], payload["testType"])
|
|
615
|
-
self.write_message(msg)
|
|
660
|
+
dbGtkUtils.complain("Failed uploading test {}-{}".format(payload["component"], payload["testType"]))
|
|
661
|
+
self.write_message("Failed uploading test {}-{}\n{}\n".format(payload["component"], payload["testType"], msg))
|
|
662
|
+
nbad += 1
|
|
616
663
|
|
|
617
664
|
else:
|
|
618
665
|
self.write_message("Upload {}-{} successfull\n".format(payload["component"], payload["testType"]))
|
|
619
666
|
past_iter = lv_iter
|
|
667
|
+
ngood += 1
|
|
620
668
|
|
|
621
669
|
lv_iter = model.iter_next(lv_iter)
|
|
622
670
|
if past_iter:
|
|
623
671
|
model.remove(past_iter)
|
|
624
672
|
|
|
673
|
+
if nbad>0:
|
|
674
|
+
dbGtkUtils.complain("Failed to upload all tests", "{} test had errors.\nThey are left in the ListView.")
|
|
675
|
+
else:
|
|
676
|
+
dbGtkUtils.complain("All {} tests uploaded succesfully".format(ngood))
|
|
677
|
+
|
|
625
678
|
|
|
626
679
|
def main():
|
|
627
680
|
"""Main entry."""
|
|
@@ -9,7 +9,6 @@ try:
|
|
|
9
9
|
import itkdb_gtk
|
|
10
10
|
|
|
11
11
|
except ImportError:
|
|
12
|
-
from pathlib import Path
|
|
13
12
|
cwd = Path(__file__).parent.parent
|
|
14
13
|
sys.path.append(cwd.as_posix())
|
|
15
14
|
|
|
@@ -93,6 +92,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
93
92
|
self.attachments = []
|
|
94
93
|
self.comments = []
|
|
95
94
|
self.defects = []
|
|
95
|
+
self.currentStage = None
|
|
96
96
|
if attachment is not None:
|
|
97
97
|
if isinstance(attachment, ITkDButils.Attachment):
|
|
98
98
|
if attachment.path is not None:
|
|
@@ -219,6 +219,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
219
219
|
except TypeError:
|
|
220
220
|
self.load_payload(self.payload)
|
|
221
221
|
self.write_message("Loaded memory payload.\n")
|
|
222
|
+
self.testF.set_sensitive(False)
|
|
222
223
|
|
|
223
224
|
if len(self.attachments) > 0:
|
|
224
225
|
self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
|
|
@@ -293,7 +294,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
293
294
|
self.objStage.set_active(indx)
|
|
294
295
|
|
|
295
296
|
except Exception:
|
|
296
|
-
self.write_message("Something went
|
|
297
|
+
self.write_message("Something went wrong with the stages\n")
|
|
297
298
|
|
|
298
299
|
|
|
299
300
|
def on_test_file(self, fdlg):
|
|
@@ -303,7 +304,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
303
304
|
|
|
304
305
|
# The file exists by definition
|
|
305
306
|
try:
|
|
306
|
-
self.data = json.loads(open(fnam).read())
|
|
307
|
+
self.data = json.loads(open(fnam, encoding="UTF-8").read())
|
|
307
308
|
errors, missing = check_data(self.data)
|
|
308
309
|
self.complete_missing(missing, errors)
|
|
309
310
|
self.set_stages()
|
|
@@ -326,7 +327,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
|
|
|
326
327
|
self.write_message("Setting Institution to {}\n".format(self.data["institution"]))
|
|
327
328
|
|
|
328
329
|
else:
|
|
329
|
-
dbGtkUtils.complain("Invalid JSON data".format('\n'.join(errors)))
|
|
330
|
+
dbGtkUtils.complain("Invalid JSON data\n{}".format('\n'.join(errors)))
|
|
330
331
|
|
|
331
332
|
self.find_attachments()
|
|
332
333
|
self.find_comments()
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Module Visual inspection GUI."""
|
|
3
|
+
import sys
|
|
4
|
+
import re
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
import itkdb_gtk
|
|
9
|
+
|
|
10
|
+
except ImportError:
|
|
11
|
+
cwd = Path(__file__).parent.parent
|
|
12
|
+
sys.path.append(cwd.as_posix())
|
|
13
|
+
|
|
14
|
+
from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
|
|
15
|
+
from itkdb_gtk.ShowComments import ShowComments
|
|
16
|
+
from itkdb_gtk.ShowDefects import ShowDefects
|
|
17
|
+
from itkdb_gtk.ShowAttachments import ShowAttachments
|
|
18
|
+
from itkdb_gtk.UploadTest import UploadTest
|
|
19
|
+
|
|
20
|
+
import gi
|
|
21
|
+
gi.require_version("Gtk", "3.0")
|
|
22
|
+
from gi.repository import Gtk, Gio
|
|
23
|
+
|
|
24
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch/moduleVisualInspection.html"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
module_type = re.compile("20USE(M[0-5]{1}|[345]{1}[LR]{1})[0-9]{7}")
|
|
28
|
+
sensor_type = re.compile("20USES[0-5]{1}[0-9]{7}")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ModuleVisualInspection(dbGtkUtils.ITkDBWindow):
|
|
32
|
+
"""Module/Sensor Visual Inspection."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, session, title="Visual Inspection", help_link=HELP_LINK):
|
|
35
|
+
super().__init__(title=title,
|
|
36
|
+
session=session,
|
|
37
|
+
show_search="Find object with given SN.",
|
|
38
|
+
help_link=help_link)
|
|
39
|
+
|
|
40
|
+
self.institute = self.pdb_user["institutions"][0]["code"]
|
|
41
|
+
self.global_image = None
|
|
42
|
+
self.global_link = None
|
|
43
|
+
self.data = None
|
|
44
|
+
self.attachments = []
|
|
45
|
+
self.comments = []
|
|
46
|
+
self.defects = []
|
|
47
|
+
|
|
48
|
+
# action button in header
|
|
49
|
+
button = Gtk.Button()
|
|
50
|
+
icon = Gio.ThemedIcon(name="document-send-symbolic")
|
|
51
|
+
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
52
|
+
button.add(image)
|
|
53
|
+
button.set_tooltip_text("Click to upload the test.")
|
|
54
|
+
button.connect("clicked", self.upload_test)
|
|
55
|
+
self.hb.pack_end(button)
|
|
56
|
+
|
|
57
|
+
grid = Gtk.Grid(column_spacing=5, row_spacing=5)
|
|
58
|
+
self.mainBox.pack_start(grid, False, False, 5)
|
|
59
|
+
|
|
60
|
+
irow = 0
|
|
61
|
+
receiver = self.create_institute_combo(only_user=True)
|
|
62
|
+
receiver.connect("changed", self.on_institute)
|
|
63
|
+
receiver.set_tooltip_text("Select the Institute making the test.")
|
|
64
|
+
dbGtkUtils.set_combo_iter(receiver, self.institute)
|
|
65
|
+
|
|
66
|
+
lbl = Gtk.Label(label="Institute")
|
|
67
|
+
lbl.set_xalign(0)
|
|
68
|
+
grid.attach(lbl, 0, irow, 1, 1)
|
|
69
|
+
grid.attach(receiver, 1, irow, 1, 1)
|
|
70
|
+
|
|
71
|
+
irow += 1
|
|
72
|
+
lbl = Gtk.Label(label="Serial Number")
|
|
73
|
+
lbl.set_xalign(0)
|
|
74
|
+
grid.attach(lbl, 0, irow, 1, 1)
|
|
75
|
+
|
|
76
|
+
self.SN = dbGtkUtils.TextEntry(small=True)
|
|
77
|
+
self.SN.connect("text_changed", self.SN_ready)
|
|
78
|
+
self.SN.widget.set_tooltip_text("Enter SN of module.")
|
|
79
|
+
grid.attach(self.SN.widget, 1, irow, 1, 1)
|
|
80
|
+
|
|
81
|
+
self.obj_type = None
|
|
82
|
+
self.obj_type_label = Gtk.Label()
|
|
83
|
+
grid.attach(self.obj_type_label, 2, irow, 1, 1)
|
|
84
|
+
|
|
85
|
+
irow += 1
|
|
86
|
+
lbl = Gtk.Label(label="Date")
|
|
87
|
+
lbl.set_xalign(0)
|
|
88
|
+
grid.attach(lbl, 0, irow, 1, 1)
|
|
89
|
+
|
|
90
|
+
self.date = dbGtkUtils.TextEntry(small=True)
|
|
91
|
+
grid.attach(self.date.widget, 1, irow, 1, 1)
|
|
92
|
+
self.date.entry.set_text(ITkDButils.get_db_date())
|
|
93
|
+
self.date.connect("text_changed", self.new_date)
|
|
94
|
+
|
|
95
|
+
irow +=1
|
|
96
|
+
self.passed = Gtk.Switch()
|
|
97
|
+
self.passed.props.halign = Gtk.Align.START
|
|
98
|
+
self.passed.set_active(True)
|
|
99
|
+
lbl = Gtk.Label(label="Passed")
|
|
100
|
+
lbl.set_xalign(0)
|
|
101
|
+
grid.attach(lbl, 0, irow, 1, 1)
|
|
102
|
+
grid.attach(self.passed, 1, irow, 1, 1)
|
|
103
|
+
|
|
104
|
+
irow +=1
|
|
105
|
+
self.problems = Gtk.Switch()
|
|
106
|
+
self.problems.props.halign = Gtk.Align.START
|
|
107
|
+
self.problems.set_active(False)
|
|
108
|
+
lbl = Gtk.Label(label="Problems")
|
|
109
|
+
lbl.set_xalign(0)
|
|
110
|
+
grid.attach(lbl, 0, irow, 1, 1)
|
|
111
|
+
grid.attach(self.problems, 1, irow, 1, 1)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# The "Add attachment" button.
|
|
115
|
+
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
|
116
|
+
self.mainBox.pack_start(box, False, False, 0)
|
|
117
|
+
self.btn_attch = dbGtkUtils.add_button_to_container(box, "Attachments",
|
|
118
|
+
"Click to edit attachments.",
|
|
119
|
+
self.edit_attachments)
|
|
120
|
+
|
|
121
|
+
self.btn_comments = dbGtkUtils.add_button_to_container(box, "Comments",
|
|
122
|
+
"Click to edit comments.",
|
|
123
|
+
self.edit_comments)
|
|
124
|
+
|
|
125
|
+
self.btn_defects = dbGtkUtils.add_button_to_container(box, "Defects",
|
|
126
|
+
"Click to edit defects.",
|
|
127
|
+
self.edit_defects)
|
|
128
|
+
|
|
129
|
+
self.mainBox.pack_start(self.message_panel.frame, True, True, 5)
|
|
130
|
+
self.write_message("Module Visual Inspection\n")
|
|
131
|
+
self.show_all()
|
|
132
|
+
|
|
133
|
+
dbGtkUtils.setup_scanner(self.get_qrcode)
|
|
134
|
+
|
|
135
|
+
def on_institute(self, combo):
|
|
136
|
+
"""A new recipient has been chosen."""
|
|
137
|
+
name = self.get_institute_from_combo(combo)
|
|
138
|
+
if name:
|
|
139
|
+
self.institute = name
|
|
140
|
+
|
|
141
|
+
def new_date(self, entry, value):
|
|
142
|
+
"""new date given at input."""
|
|
143
|
+
d = dbGtkUtils.parse_date_as_string(value)
|
|
144
|
+
if d is not None:
|
|
145
|
+
self.date.set_text(d)
|
|
146
|
+
|
|
147
|
+
def SN_ready(self, *args):
|
|
148
|
+
"""SN is ready in the TextEnttry."""
|
|
149
|
+
SN = self.SN.get_text()
|
|
150
|
+
# GEt children.
|
|
151
|
+
module = ITkDButils.get_DB_component(self.session, SN)
|
|
152
|
+
if module is None:
|
|
153
|
+
self.write_message(ITkDButils.get_db_response())
|
|
154
|
+
return
|
|
155
|
+
|
|
156
|
+
SN = module["serialNumber"]
|
|
157
|
+
if module_type.match(SN):
|
|
158
|
+
self.obj_type_label.set_text("Module")
|
|
159
|
+
self.obj_type = "MODULE"
|
|
160
|
+
elif sensor_type.match(SN):
|
|
161
|
+
self.obj_type_label.set_text("Sensor")
|
|
162
|
+
self.obj_type = "SENSOR"
|
|
163
|
+
else:
|
|
164
|
+
self.obj_type_label.set_text("Invalid SN")
|
|
165
|
+
self.obj_type = None
|
|
166
|
+
dbGtkUtils.complain("Invalid SN", "Not a module nor a sensor.")
|
|
167
|
+
|
|
168
|
+
args[0].set_text(SN)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def edit_attachments(self, *args):
|
|
172
|
+
"""Edit test attachmetns."""
|
|
173
|
+
SA = ShowAttachments("Test Attachments", self.session, self.attachments, parent=self)
|
|
174
|
+
response = SA.run()
|
|
175
|
+
if response == Gtk.ResponseType.OK:
|
|
176
|
+
self.attachments = SA.attachments
|
|
177
|
+
|
|
178
|
+
SA.hide()
|
|
179
|
+
SA.destroy()
|
|
180
|
+
|
|
181
|
+
if len(self.attachments) > 0:
|
|
182
|
+
self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
|
|
183
|
+
|
|
184
|
+
def edit_comments(self, *args):
|
|
185
|
+
"""Edit test comments."""
|
|
186
|
+
SC = ShowComments("Test Comments", self.comments, self)
|
|
187
|
+
rc = SC.run()
|
|
188
|
+
if rc == Gtk.ResponseType.OK:
|
|
189
|
+
self.comments = SC.comments
|
|
190
|
+
|
|
191
|
+
SC.hide()
|
|
192
|
+
SC.destroy()
|
|
193
|
+
|
|
194
|
+
if len(self.comments) > 0:
|
|
195
|
+
self.btn_comments.set_label("Comments ({})".format(len(self.comments)))
|
|
196
|
+
|
|
197
|
+
def edit_defects(self, *args):
|
|
198
|
+
"""Edit test defects."""
|
|
199
|
+
SD = ShowDefects("Test Defects", self.defects, self)
|
|
200
|
+
rc = SD.run()
|
|
201
|
+
if rc == Gtk.ResponseType.OK:
|
|
202
|
+
self.defects = SD.defects
|
|
203
|
+
|
|
204
|
+
SD.hide()
|
|
205
|
+
SD.destroy()
|
|
206
|
+
|
|
207
|
+
if len(self.defects) > 0:
|
|
208
|
+
self.btn_defects.set_label("Defects ({})".format(len(self.defects)))
|
|
209
|
+
|
|
210
|
+
def upload_test(self, *args):
|
|
211
|
+
"""Upload the test."""
|
|
212
|
+
SN = self.SN.get_text()
|
|
213
|
+
if len(SN) == 0 or self.obj_type is None:
|
|
214
|
+
dbGtkUtils.complain("Invalid Serial Number", SN)
|
|
215
|
+
return
|
|
216
|
+
|
|
217
|
+
defaults = {
|
|
218
|
+
"component": SN,
|
|
219
|
+
"institution": self.institute,
|
|
220
|
+
"passed": self.passed.get_active(),
|
|
221
|
+
"problems": self.problems.get_active(),
|
|
222
|
+
"runNumber": "1",
|
|
223
|
+
"date": self.date.get_text()
|
|
224
|
+
}
|
|
225
|
+
test_type = "VISUAL_INSPECTION"
|
|
226
|
+
if self.obj_type == "SENSOR":
|
|
227
|
+
test_type = "VIS_INSP_RES_MOD_V2"
|
|
228
|
+
|
|
229
|
+
self.data = ITkDButils.get_test_skeleton(self.session,
|
|
230
|
+
self.obj_type,
|
|
231
|
+
test_type,
|
|
232
|
+
defaults)
|
|
233
|
+
|
|
234
|
+
self.data["comments"] = self.comments
|
|
235
|
+
self.data["defects"] = self.defects
|
|
236
|
+
uploadW = UploadTest(self.session, self.data, self.attachments)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def get_qrcode(self, fd, state, reader):
|
|
241
|
+
"""Read SN from scanner."""
|
|
242
|
+
txt = dbGtkUtils.scanner_get_line(reader)
|
|
243
|
+
self.write_message("SN: {}\n".format(txt))
|
|
244
|
+
self.SN_ready(txt, self.SN.widget)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def main():
|
|
248
|
+
"""Main entry."""
|
|
249
|
+
# DB login
|
|
250
|
+
dlg = ITkDBlogin.ITkDBlogin()
|
|
251
|
+
client = dlg.get_client()
|
|
252
|
+
if client is None:
|
|
253
|
+
print("Could not connect to DB with provided credentials.")
|
|
254
|
+
dlg.die()
|
|
255
|
+
sys.exit()
|
|
256
|
+
|
|
257
|
+
client.user_gui = dlg
|
|
258
|
+
|
|
259
|
+
gTest = ModuleVisualInspection(client)
|
|
260
|
+
|
|
261
|
+
gTest.present()
|
|
262
|
+
gTest.connect("destroy", Gtk.main_quit)
|
|
263
|
+
try:
|
|
264
|
+
Gtk.main()
|
|
265
|
+
|
|
266
|
+
except KeyboardInterrupt:
|
|
267
|
+
print("Arrrgggg!!!")
|
|
268
|
+
|
|
269
|
+
dlg.die()
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
main()
|