itkdb-gtk 0.0.3__py3-none-any.whl → 0.20.1__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.
Files changed (37) hide show
  1. itkdb_gtk/{sendShipments.py → CreateShipments.py} +74 -78
  2. itkdb_gtk/{getShipments.py → GetShipments.py} +99 -106
  3. itkdb_gtk/GlueWeight.py +45 -66
  4. itkdb_gtk/ITkDB.desktop +8 -0
  5. itkdb_gtk/ITkDB.svg +380 -0
  6. itkdb_gtk/ITkDBlogin.py +10 -6
  7. itkdb_gtk/ITkDButils.py +295 -57
  8. itkdb_gtk/PanelVisualInspection.py +590 -0
  9. itkdb_gtk/QRScanner.py +120 -0
  10. itkdb_gtk/SensorUtils.py +492 -0
  11. itkdb_gtk/ShowAttachments.py +267 -0
  12. itkdb_gtk/ShowComments.py +94 -0
  13. itkdb_gtk/ShowDefects.py +103 -0
  14. itkdb_gtk/UploadModuleIV.py +566 -0
  15. itkdb_gtk/UploadMultipleTests.py +746 -0
  16. itkdb_gtk/UploadTest.py +509 -0
  17. itkdb_gtk/VisualInspection.py +297 -0
  18. itkdb_gtk/WireBondGui.py +1304 -0
  19. itkdb_gtk/__init__.py +38 -12
  20. itkdb_gtk/dashBoard.py +292 -33
  21. itkdb_gtk/dbGtkUtils.py +356 -75
  22. itkdb_gtk/findComponent.py +242 -0
  23. itkdb_gtk/findVTRx.py +36 -0
  24. itkdb_gtk/readGoogleSheet.py +1 -2
  25. itkdb_gtk/untrash_component.py +35 -0
  26. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/METADATA +21 -12
  27. itkdb_gtk-0.20.1.dist-info/RECORD +30 -0
  28. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/WHEEL +1 -1
  29. itkdb_gtk-0.20.1.dist-info/entry_points.txt +12 -0
  30. itkdb_gtk/checkComponent.py +0 -131
  31. itkdb_gtk/groundingTest.py +0 -225
  32. itkdb_gtk/readAVSdata.py +0 -565
  33. itkdb_gtk/uploadPetalInformation.py +0 -604
  34. itkdb_gtk/uploadTest.py +0 -384
  35. itkdb_gtk-0.0.3.dist-info/RECORD +0 -19
  36. itkdb_gtk-0.0.3.dist-info/entry_points.txt +0 -7
  37. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,297 @@
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, QRScanner
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
+
25
+ module_type = re.compile("20USE(M[0-5]{1}|[345]{1}[LR]{1})[0-9]{7}")
26
+ sensor_type = re.compile("20USES[0-5]{1}[0-9]{7}")
27
+
28
+
29
+ class ModuleVisualInspection(dbGtkUtils.ITkDBWindow):
30
+ """Module/Sensor Visual Inspection."""
31
+
32
+ def __init__(self, session, title="Visual Inspection", help_link=None):
33
+ super().__init__(title=title,
34
+ session=session,
35
+ show_search="Find object with given SN.",
36
+ help_link=help_link)
37
+
38
+ self.institute = self.pdb_user["institutions"][0]["code"]
39
+ self.global_image = None
40
+ self.global_link = None
41
+ self.data = None
42
+ self.currentStage = None
43
+ self.attachments = []
44
+ self.comments = []
45
+ self.defects = []
46
+
47
+ # action button in header
48
+ button = Gtk.Button()
49
+ icon = Gio.ThemedIcon(name="document-send-symbolic")
50
+ image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
51
+ button.add(image)
52
+ button.set_tooltip_text("Click to upload the test.")
53
+ button.connect("clicked", self.upload_test)
54
+ self.hb.pack_end(button)
55
+
56
+ grid = Gtk.Grid(column_spacing=10, row_spacing=5)
57
+ self.mainBox.pack_start(grid, False, False, 5)
58
+
59
+ irow = 0
60
+ receiver = self.create_institute_combo(only_user=True)
61
+ receiver.connect("changed", self.on_institute)
62
+ receiver.set_tooltip_text("Select the Institute making the test.")
63
+ dbGtkUtils.set_combo_iter(receiver, self.institute)
64
+
65
+ lbl = Gtk.Label(label="Institute")
66
+ lbl.set_xalign(0)
67
+ grid.attach(lbl, 0, irow, 1, 1)
68
+ grid.attach(receiver, 1, irow, 1, 1)
69
+
70
+ self.obj_type = None
71
+ self.obj_type_label = Gtk.Label()
72
+ self.obj_type_label.set_xalign(0)
73
+ grid.attach(self.obj_type_label, 2, irow, 1, 1)
74
+
75
+ irow += 1
76
+ lbl = Gtk.Label(label="Serial Number")
77
+ lbl.set_xalign(0)
78
+ grid.attach(lbl, 0, irow, 1, 1)
79
+
80
+ self.SN = dbGtkUtils.TextEntry(small=True)
81
+ self.SN.connect("text_changed", self.SN_ready)
82
+ self.SN.widget.set_tooltip_text("Enter SN of module.")
83
+ grid.attach(self.SN.widget, 1, irow, 1, 1)
84
+
85
+
86
+ self.passed = Gtk.Switch()
87
+ self.passed.props.halign = Gtk.Align.START
88
+ self.passed.set_active(True)
89
+ lbl = Gtk.Label(label="Passed")
90
+ lbl.set_xalign(0)
91
+ grid.attach(lbl, 2, irow, 1, 1)
92
+ grid.attach(self.passed, 3, irow, 1, 1)
93
+
94
+
95
+ irow += 1
96
+ lbl = Gtk.Label(label="Date")
97
+ lbl.set_xalign(0)
98
+ grid.attach(lbl, 0, irow, 1, 1)
99
+
100
+ self.date = dbGtkUtils.TextEntry(small=True)
101
+ grid.attach(self.date.widget, 1, irow, 1, 1)
102
+ self.date.entry.set_text(ITkDButils.get_db_date())
103
+ self.date.connect("text_changed", self.new_date)
104
+
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, 2, irow, 1, 1)
111
+ grid.attach(self.problems, 3, irow, 1, 1)
112
+
113
+ irow +=1
114
+ self.reception = Gtk.Switch()
115
+ self.reception.props.halign = Gtk.Align.START
116
+ self.reception.set_active(False)
117
+ lbl = Gtk.Label(label="Reception VI")
118
+ lbl.set_xalign(0)
119
+ grid.attach(lbl, 0, irow, 1, 1)
120
+ grid.attach(self.reception, 1, irow, 1, 1)
121
+
122
+ irow +=1
123
+ lbl = Gtk.Label()
124
+ grid.attach(lbl, 0, irow, 1, 1)
125
+
126
+ # The "Add attachment" button.
127
+ box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
128
+ self.mainBox.pack_start(box, False, False, 0)
129
+ self.btn_attch = dbGtkUtils.add_button_to_container(box, "Attachments",
130
+ "Click to edit attachments.",
131
+ self.edit_attachments)
132
+
133
+ self.btn_comments = dbGtkUtils.add_button_to_container(box, "Comments",
134
+ "Click to edit comments.",
135
+ self.edit_comments)
136
+
137
+ self.btn_defects = dbGtkUtils.add_button_to_container(box, "Defects",
138
+ "Click to edit defects.",
139
+ self.edit_defects)
140
+
141
+ self.mainBox.pack_start(self.message_panel.frame, True, True, 5)
142
+ self.write_message("Module Visual Inspection\n")
143
+ self.show_all()
144
+
145
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
146
+
147
+ def on_institute(self, combo):
148
+ """A new recipient has been chosen."""
149
+ name = self.get_institute_from_combo(combo)
150
+ if name:
151
+ self.institute = name
152
+
153
+ def new_date(self, entry, value):
154
+ """new date given at input."""
155
+ d = dbGtkUtils.parse_date_as_string(value)
156
+ if d is not None:
157
+ self.date.set_text(d)
158
+
159
+ def SN_ready(self, *args):
160
+ """SN is ready in the TextEnttry."""
161
+ SN = self.SN.get_text()
162
+ # GEt children.
163
+ module = ITkDButils.get_DB_component(self.session, SN)
164
+ if module is None:
165
+ self.write_message(ITkDButils.get_db_response())
166
+ return
167
+
168
+ SN = module["serialNumber"]
169
+ if module_type.match(SN):
170
+ self.obj_type_label.set_markup("<b><big>Module</big></b>")
171
+ self.obj_type = "MODULE"
172
+ elif sensor_type.match(SN):
173
+ self.obj_type_label.set_markup("<b><big>Sensor</big></b>")
174
+ self.obj_type = "SENSOR"
175
+ else:
176
+ self.obj_type_label.set_text("Invalid SN")
177
+ self.obj_type = None
178
+ dbGtkUtils.complain("Invalid SN", "Not a module nor a sensor.")
179
+
180
+ self.reception.set_sensitive(True)
181
+ self.reception.set_active(False)
182
+ self.currentStage = module["currentStage"]["code"]
183
+ if self.obj_type == "MODULE" and self.currentStage in ["AT_LOADING_SITE", "STITCH_BONDING"]:
184
+ self.reception.set_active(True)
185
+ self.reception.set_sensitive(False)
186
+
187
+ args[0].set_text(SN)
188
+
189
+
190
+ def edit_attachments(self, *args):
191
+ """Edit test attachmetns."""
192
+ SA = ShowAttachments("Test Attachments", self.session, self.attachments, parent=self)
193
+ response = SA.run()
194
+ if response == Gtk.ResponseType.OK:
195
+ self.attachments = SA.attachments
196
+
197
+ SA.hide()
198
+ SA.destroy()
199
+
200
+ if len(self.attachments) > 0:
201
+ self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
202
+
203
+ def edit_comments(self, *args):
204
+ """Edit test comments."""
205
+ SC = ShowComments("Test Comments", self.comments, self)
206
+ rc = SC.run()
207
+ if rc == Gtk.ResponseType.OK:
208
+ self.comments = SC.comments
209
+
210
+ SC.hide()
211
+ SC.destroy()
212
+
213
+ if len(self.comments) > 0:
214
+ self.btn_comments.set_label("Comments ({})".format(len(self.comments)))
215
+
216
+ def edit_defects(self, *args):
217
+ """Edit test defects."""
218
+ SD = ShowDefects("Test Defects", self.defects, self)
219
+ rc = SD.run()
220
+ if rc == Gtk.ResponseType.OK:
221
+ self.defects = SD.defects
222
+
223
+ SD.hide()
224
+ SD.destroy()
225
+
226
+ if len(self.defects) > 0:
227
+ self.btn_defects.set_label("Defects ({})".format(len(self.defects)))
228
+
229
+ def upload_test(self, *args):
230
+ """Upload the test."""
231
+ SN = self.SN.get_text()
232
+ if len(SN) == 0 or self.obj_type is None:
233
+ dbGtkUtils.complain("Invalid Serial Number", SN)
234
+ return
235
+
236
+ defaults = {
237
+ "component": SN,
238
+ "institution": self.institute,
239
+ "passed": self.passed.get_active(),
240
+ "problems": self.problems.get_active(),
241
+ "runNumber": "1",
242
+ "date": self.date.get_text()
243
+ }
244
+
245
+ test_type = "VISUAL_INSPECTION"
246
+ if self.obj_type == "SENSOR":
247
+ test_type = "VIS_INSP_RES_MOD_V2"
248
+
249
+ else:
250
+ if self.reception.get_active():
251
+ test_type = "VISUAL_INSPECTION"
252
+
253
+ self.data = ITkDButils.get_test_skeleton(self.session,
254
+ self.obj_type,
255
+ test_type,
256
+ defaults)
257
+
258
+ self.data["comments"] = self.comments
259
+ self.data["defects"] = self.defects
260
+ uploadW = UploadTest(self.session, self.data, self.attachments)
261
+
262
+
263
+
264
+ def get_qrcode(self, txt):
265
+ """Read SN from scanner."""
266
+ self.write_message("SN: {}\n".format(txt))
267
+ self.SN_ready(txt, self.SN.widget)
268
+
269
+
270
+ def main():
271
+ """Main entry."""
272
+ HELP_LINK="https://itkdb-gtk.docs.cern.ch/moduleVisualInspection.html"
273
+
274
+ # DB login
275
+ dlg = ITkDBlogin.ITkDBlogin()
276
+ client = dlg.get_client()
277
+ if client is None:
278
+ print("Could not connect to DB with provided credentials.")
279
+ dlg.die()
280
+ sys.exit()
281
+
282
+ client.user_gui = dlg
283
+
284
+ gTest = ModuleVisualInspection(client, help_link=HELP_LINK)
285
+
286
+ gTest.present()
287
+ gTest.connect("destroy", Gtk.main_quit)
288
+ try:
289
+ Gtk.main()
290
+
291
+ except KeyboardInterrupt:
292
+ print("Arrrgggg!!!")
293
+
294
+ dlg.die()
295
+
296
+ if __name__ == "__main__":
297
+ main()