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,242 @@
1
+ #!/usr/bin/env python3
2
+ """GUI to upload tests."""
3
+ import argparse
4
+ import json
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ try:
9
+ import itkdb_gtk
10
+
11
+ except ImportError:
12
+ cwd = Path(__file__).parent.parent
13
+ sys.path.append(cwd.as_posix())
14
+
15
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner, findVTRx
16
+
17
+ import gi
18
+ gi.require_version("Gtk", "3.0")
19
+ from gi.repository import Gtk, GLib
20
+
21
+ class FindComponent(dbGtkUtils.ITkDBWindow):
22
+ """Read QR of bar code and retrieve information about component."""
23
+
24
+ def __init__(self, session, help_link=None):
25
+ """Initialization.
26
+
27
+ Args:
28
+ session: ITkDB session
29
+ help_link: link to help page.
30
+
31
+ """
32
+ super().__init__(session=session, title="Find Component", help_link=help_link)
33
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
34
+ self.ofd = None # Output file descriptor
35
+ self.init_window()
36
+
37
+ def __del__(self):
38
+ """Destructor."""
39
+ if self.ofd is not None:
40
+ self.ofd.close()
41
+
42
+ def init_window(self):
43
+ """Create the Gtk window."""
44
+ # Initial tweaks
45
+ self.set_border_width(10)
46
+
47
+ # Prepare HeaderBar
48
+ self.hb.props.title = "Find Component"
49
+
50
+
51
+ # File name
52
+ box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
53
+ self.mainBox.pack_start(box, False, False, 0)
54
+ self.open_btn = Gtk.Button(label="Output File")
55
+ self.open_btn.set_tooltip_text("Select output file to save scanned component information in CSV format.")
56
+ self.open_btn.connect("clicked", self.on_file_set)
57
+ box.pack_start(self.open_btn, False, False, 0)
58
+
59
+ self.close_btn = Gtk.Button(label="Close File")
60
+ self.close_btn.set_sensitive(False)
61
+ self.close_btn.set_tooltip_text("Close the output file.")
62
+ self.close_btn.connect("clicked", self.on_file_close)
63
+ box.pack_start(self.close_btn, False, False, 0)
64
+
65
+
66
+ self.file_name = Gtk.Label(label="No output file selected")
67
+ self.mainBox.pack_start(self.file_name, False, False, 5)
68
+
69
+ self.scanner_dev = Gtk.Label(label="No scanner found")
70
+ self.mainBox.pack_start(self.scanner_dev, False, False, 5)
71
+
72
+ # Object Data
73
+ lbl = Gtk.Label(label="Scan your QR or bar code. Information will appear below.")
74
+ self.mainBox.pack_start(lbl, False, False, 10)
75
+
76
+
77
+ #btn = Gtk.Button(label="Test Button")
78
+ #btn.connect("clicked", self.test_qrcode)
79
+ #self.mainBox.pack_start(btn, True, True, 0)
80
+
81
+ # The text view
82
+ self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
83
+
84
+ self.timer_id = GLib.timeout_add(500, self.find_scanner)
85
+
86
+ self.show_all()
87
+
88
+ def find_scanner(self, *args):
89
+ """Figure out if there is a scanner connected."""
90
+ if self.scanner.reader is None:
91
+ self.scanner_dev.set_text("No scanner found")
92
+ else:
93
+ self.scanner_dev.set_text("Found scanner in {}".format(self.scanner.reader.name))
94
+
95
+ return True
96
+
97
+ def on_file_set(self, *args):
98
+ """File selected.
99
+
100
+ Opens the file for writing the information aobut the components
101
+ scanned.
102
+ """
103
+ fc = Gtk.FileChooserDialog(title="Save data file", action=Gtk.FileChooserAction.SAVE)
104
+ fc.set_current_name("scanned_components.csv")
105
+ fc.add_buttons(
106
+ Gtk.STOCK_CANCEL,
107
+ Gtk.ResponseType.CANCEL,
108
+ Gtk.STOCK_OPEN,
109
+ Gtk.ResponseType.OK,
110
+ )
111
+ response = fc.run()
112
+ if response != Gtk.ResponseType.OK:
113
+ fc.destroy()
114
+ return
115
+
116
+ filename = fc.get_filename()
117
+
118
+ if Path(filename).exists():
119
+ overwrite = dbGtkUtils.ask_for_confirmation("File already exists. Overwrite?", "{}".format(filename))
120
+ if not overwrite:
121
+ fc.destroy()
122
+ return
123
+
124
+ fc.destroy()
125
+ self.close_btn.set_sensitive(True)
126
+ self.open_btn.set_sensitive(False)
127
+ self.file_name.set_text("Output File: {}".format(filename))
128
+ self.ofd = open(filename, "w", encoding="utf-8")
129
+ self.ofd.write("SN,AltID,Type,Location,StageCode\n")
130
+ self.ofd.flush()
131
+
132
+ def on_file_close(self, *args):
133
+ """File closed."""
134
+ if self.ofd is not None:
135
+ self.ofd.close()
136
+ self.ofd = None
137
+ self.close_btn.set_sensitive(False)
138
+ self.open_btn.set_sensitive(True)
139
+ self.file_name.set_text("No output file selected")
140
+
141
+ def get_qrcode(self, txt):
142
+ """Gets data from QR scanner."""
143
+ is_vtrx = False
144
+ if findVTRx.is_vtrx(txt):
145
+ try:
146
+ SN = findVTRx.find_vtrx(self.session, txt)
147
+ is_vtrx = True
148
+ except ValueError as e:
149
+ self.write_message("Error: {}\n".format(e))
150
+ return
151
+ else:
152
+ SN = txt
153
+
154
+ obj = ITkDButils.get_DB_component(self.session, SN)
155
+ if obj is None:
156
+ self.write_message("Object {} not found in DB\n\n".format(SN))
157
+ return
158
+
159
+ if is_vtrx and obj["alternativeIdentifier"] is None:
160
+ obj["alternativeIdentifier"] = txt
161
+
162
+ msg = "\n{}\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc. {}\nObject stage: {} - {}\n\n".format(
163
+ txt,
164
+ obj["serialNumber"],
165
+ obj["alternativeIdentifier"],
166
+ obj["componentType"]["name"],
167
+ obj["currentLocation"]["name"],
168
+ obj["currentStage"]["code"],
169
+ obj["currentStage"]["name"])
170
+ self.write_message(msg)
171
+
172
+ msg = "{}, {}, {}, {}, {}\n".format(
173
+ obj["serialNumber"],
174
+ obj["alternativeIdentifier"],
175
+ obj["componentType"]["name"],
176
+ obj["currentLocation"]["code"],
177
+ obj["currentStage"]["code"])
178
+
179
+ if self.ofd is not None:
180
+ self.ofd.write(msg)
181
+ self.ofd.flush()
182
+
183
+ def test_qrcode(self, *args):
184
+ """Gets data from QR scanner."""
185
+ txt = "a3c671bf38d3957dc053c6e5471aa27e"
186
+ self.write_message("{}\n".format(txt))
187
+
188
+ if findVTRx.is_vtrx(txt):
189
+ try:
190
+ SN = findVTRx.find_vtrx(self.session, txt)
191
+ except ValueError as e:
192
+ self.write_message("Error: {}\n".format(e))
193
+ return
194
+ else:
195
+ SN = txt
196
+
197
+ obj = ITkDButils.get_DB_component(self.session, SN)
198
+ if obj is None:
199
+ self.write_message("Object {} not found in DB\n\n".format(SN))
200
+ return
201
+
202
+
203
+ msg = "\n\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc.: {}\nObject stage: {} - {}\n".format(
204
+ obj["serialNumber"],
205
+ obj["alternativeIdentifier"],
206
+ obj["componentType"]["name"],
207
+ obj["currentLocation"]["name"],
208
+ obj["currentStage"]["code"],
209
+ obj["currentStage"]["name"])
210
+
211
+ self.write_message(msg)
212
+ self.write_message("")
213
+
214
+ def main():
215
+ """Main entry."""
216
+ HELP_LINK="https://itkdb-gtk.docs.cern.ch/uploadSingleTest.html"
217
+
218
+ # DB login
219
+ dlg = ITkDBlogin.ITkDBlogin()
220
+ client = dlg.get_client()
221
+ if client is None:
222
+ print("Could not connect to DB with provided credentials.")
223
+ dlg.die()
224
+ sys.exit()
225
+
226
+ client.user_gui = dlg
227
+
228
+ window = FindComponent(client, help_link=HELP_LINK)
229
+ window.set_accept_focus(True)
230
+ window.present()
231
+ window.connect("destroy", Gtk.main_quit)
232
+
233
+ try:
234
+ Gtk.main()
235
+
236
+ except KeyboardInterrupt:
237
+ print("Arrrgggg!!!")
238
+
239
+ dlg.die()
240
+
241
+ if __name__ == "__main__":
242
+ main()
itkdb_gtk/findVTRx.py ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env python3
2
+ """Tells which VTRx correspods to the package serial number scanned."""
3
+
4
+ import re
5
+
6
+ __valid_sn__ = re.compile("J-(SD|MT)[0-9]+")
7
+
8
+ def is_vtrx(SN):
9
+ """Checks if the SN corresponds to a VTRx."""
10
+ if __valid_sn__.match(SN) is None:
11
+ return False
12
+ return True
13
+
14
+ def find_vtrx(client, SN):
15
+ """Searches VTRx."""
16
+ if not is_vtrx(SN):
17
+ return None
18
+
19
+ payload = {
20
+ "filterMap": {
21
+ "project": "CE",
22
+ "componentType": ["VTRX"],
23
+ "propertyFilter": [{"code": "PACKAGE_SN", "operator": "=", "value": SN}],
24
+ }
25
+ }
26
+ out = client.get("listComponentsByProperty", json=payload)
27
+ vtrx = None
28
+ nitem = 0
29
+ for item in out:
30
+ vtrx = item["serialNumber"]
31
+ nitem += 1
32
+
33
+ if nitem > 1:
34
+ raise ValueError("Too many VTRx with same device SN.")
35
+
36
+ return vtrx
@@ -13,7 +13,7 @@ SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
13
13
 
14
14
 
15
15
  # Get spreadsheet ID from share link
16
- re_sheet_id = re.compile(r"https://docs.google.com/spreadsheets/d/(?P<ID>\w+)", re.DOTALL)
16
+ re_sheet_id = re.compile(r"https://docs.google.com/spreadsheets/d/(?P<ID>[\w-]+)", re.DOTALL)
17
17
 
18
18
 
19
19
  def get_spreadsheet_service():
@@ -55,7 +55,6 @@ def get_spreadsheet_data(url, data_range):
55
55
  """Get the data from the given range in teh google sheet.
56
56
 
57
57
  Args:
58
- ----
59
58
  url: google sheet document url
60
59
  data_range: the data range, ej. inventory!A2:Z
61
60
 
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env python3
2
+ """Un trash a trashed component."""
3
+
4
+
5
+ def untrash_component(client, SN, reason="Accidentally trashed"):
6
+ """Un trash given component.
7
+
8
+ Args:
9
+ SN (str): Serial number of component to recover.
10
+ reason (str): message for the DB
11
+ Returna:
12
+ dict: PDB response.
13
+
14
+ """
15
+ DTO = {
16
+ 'component': SN,
17
+ 'trashed': False,
18
+ 'reason': reason
19
+ }
20
+
21
+ response = client.post('setComponentTrashed', json=DTO)
22
+ return response
23
+
24
+
25
+ if __name__ == "__main__":
26
+ import sys
27
+ from itkdb_gtk import ITkDBlogin
28
+ dlg = ITkDBlogin.ITkDBlogin()
29
+ client = dlg.get_client()
30
+
31
+ try:
32
+ response = untrash_component(client, sys.argv[1])
33
+
34
+ except Exception as E:
35
+ print(str(E))
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: itkdb-gtk
3
- Version: 0.0.3
1
+ Metadata-Version: 2.4
2
+ Name: itkdb_gtk
3
+ Version: 0.20.1
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
@@ -9,12 +9,14 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Operating System :: OS Independent
10
10
  Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
- Requires-Dist: itkdb (>=0.4.0)
12
+ Requires-Dist: itkdb>=0.4.0
13
13
  Requires-Dist: numpy
14
+ Requires-Dist: matplotlib
14
15
  Requires-Dist: openpyxl
15
16
  Requires-Dist: pyserial
16
- Requires-Dist: python-dateutil
17
+ Requires-Dist: python_dateutil
17
18
  Requires-Dist: requests
19
+ Requires-Dist: PyGObject
18
20
 
19
21
  # Interaction with the ITk PDB.
20
22
 
@@ -42,25 +44,32 @@ Reads the AVS Production Sheet and FAT reports. With this information it creates
42
44
  the petal core in the DB, if not yet there, make the assembly of the components,
43
45
  and uploadas the test runs made at AVS.
44
46
 
45
- ## uploadTest.py
47
+ ## UploadTest.py
46
48
  A GUI to upload the JSON files corresponding to a test and, also, to add
47
49
  attachmetns.
48
50
 
49
- ## getShipments.py
51
+ ## UploadMultipleTests.py
52
+ This will allow to select various test files, or even scan a whole directory to
53
+ find them, and assign comments, defects or attachments to each of the tests found.
54
+
55
+ ## GetShipments.py
50
56
  Find all shipments to be received at a given site and list them. It handles a
51
57
  barcode reader that helps identifying the items actually received for the
52
58
  reception. It will finally make the DB aware of the items receptioned.
53
59
 
54
- ## sendShipments.py
60
+ ## CreateShipments.py
55
61
  Create a new shipment. Allows to add items with the QR reader as well as from a
56
62
  GUI dialog. One can add comments and attachments to the shipment.
57
63
 
58
- ## groundingTest.py
59
- Allows to enter valueos, comments and defects for those ot items in the gounding
64
+ ## GroundVITests.py
65
+ Allows to upload and enter valueos, comments and defects for those items in the gounding
60
66
  and visual instpections tests of the petal core.
61
67
 
68
+ ## UploadModuleIV.py
69
+ The idea behind this is that we messure the IV on a Ring module and on only one of the to Half modules. The IV of the remaining half modules is derived from the other 2. Eventually the IV test can be uploaded to the DB.
70
+
62
71
  ## dashBoard.py
63
72
  This is an launcher application from which we can start most of the other
64
73
  applications. It is a very good starting point. There is a Gnome desktop file (ITkDB.desktop)
65
- that needs to be copied to $HOME/.local/share/applications and an icon (ITkDB.svg) that
66
- needs to go to $HOME/.local/share/icons
74
+ that needs to be copied to `$HOME/.local/share/applications` and an icon (ITkDB.svg) that
75
+ needs to go to `$HOME/.local/share/icons`
@@ -0,0 +1,30 @@
1
+ itkdb_gtk/CreateShipments.py,sha256=zE6FZ5WJebgK4MX8ps0FdcIqE51jiL00-k4TdZfrH8E,13206
2
+ itkdb_gtk/GetShipments.py,sha256=iiW4A7SQ8oMtUdwSdK_mOTaBr2xcc3Grl8edB4hcX-c,18728
3
+ itkdb_gtk/GlueWeight.py,sha256=IHgvbN2DlT8Ou-DMi-n3Z-3xSrPr0tlrkkEH10AshrA,11587
4
+ itkdb_gtk/ITkDB.desktop,sha256=v_K4mHsDxb912J1XGo6mOlbW2TkHvYNGrKmiOnsBQqM,172
5
+ itkdb_gtk/ITkDB.svg,sha256=Ry702zrUkxvG61SqThbUNfXySyiLMqalwYpcM-b_KWo,24242
6
+ itkdb_gtk/ITkDBlogin.py,sha256=40tipm_j5eUS4dnZnBT8VyL6Bu_8csuqS9TPWKxvKSY,10038
7
+ itkdb_gtk/ITkDButils.py,sha256=mcvxxvg1Sqhw4cGe6BUi2Zq4tDNWFWD49izFPI8qhzo,21632
8
+ itkdb_gtk/PanelVisualInspection.py,sha256=7IWrAOxn4T6S84BqeaVmwQg92_vi9ZPZqIMrDATEAww,20653
9
+ itkdb_gtk/QRScanner.py,sha256=igSxIyaPSbWxChhd6du4MKuQ0m6Sd3irrAt374KZlB0,3480
10
+ itkdb_gtk/SensorUtils.py,sha256=fYWF9TeutAbore53dLWNlZnVn9P3OsKYcFLNGOs8cnI,15426
11
+ itkdb_gtk/ShowAttachments.py,sha256=KExxPCdbcb04XS8JSUkg5xF1McvlB8e9btwctDCKNXU,8498
12
+ itkdb_gtk/ShowComments.py,sha256=OiMTFLnhGbbKRj5x61D517BYHAt-qY5Y1lvR3EQz3c0,3151
13
+ itkdb_gtk/ShowDefects.py,sha256=aVAHeaE5IztmAPEuHwhi06KWo_pi9xX2J1fTLhKyAPI,3530
14
+ itkdb_gtk/UploadModuleIV.py,sha256=sqh52bSxANBwlmVWZlDqFXpqRGf0rV0QsjJWC-tY_qI,17792
15
+ itkdb_gtk/UploadMultipleTests.py,sha256=tFXGyeIC-c1Gh_Fyjr_AddDnKReGMrMphdotRzIsR-s,25301
16
+ itkdb_gtk/UploadTest.py,sha256=ukgJ5-IG12bqa1QIp3bXIV8hkdXCv5UDxh1lQswN_ko,16832
17
+ itkdb_gtk/VisualInspection.py,sha256=sTEhWrWW9Cez2ABLq1nggnvnncT2nZEsb3KWCSN6GCM,9798
18
+ itkdb_gtk/WireBondGui.py,sha256=WFTLOw4l5JxSbvh4vZMxcF65fqlwvNw0fOyEru9ijqQ,39850
19
+ itkdb_gtk/__init__.py,sha256=f7942SiDwfXYQACCkjz1NktKHYGwnxfwxd-nEYr4vvs,1269
20
+ itkdb_gtk/dashBoard.py,sha256=1kNSJn-iJ-ME6Nhtz-TfjFQsdKIlBooExrD8U_LgyEA,12293
21
+ itkdb_gtk/dbGtkUtils.py,sha256=UEdqVdw8OxAmDzVeCKncUq7mUJkCclV7tEZu0dadics,29629
22
+ itkdb_gtk/findComponent.py,sha256=1AJc1a9USO7uFGf1q2Gtu6eroG_EFvSeCS-Jfew4yJw,7681
23
+ itkdb_gtk/findVTRx.py,sha256=BYeVuX2oO_Oib1CTUef6SrFJpmOojSpHqWI2eyNApu0,874
24
+ itkdb_gtk/readGoogleSheet.py,sha256=Lzm_oPWwDqZZzKoBUgsp277F9-wCfr_BA0X4VD2Eolo,2673
25
+ itkdb_gtk/untrash_component.py,sha256=VrN46-f-kF7voOxtoh7OL-bZSWAaIFb7-Xbx6_WT7K8,757
26
+ itkdb_gtk-0.20.1.dist-info/METADATA,sha256=696CpNzA97r8TdHxuspCZ31EsaaH4Dypu0JzlQqu8Pk,3149
27
+ itkdb_gtk-0.20.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ itkdb_gtk-0.20.1.dist-info/entry_points.txt,sha256=vN0_mqIT6NwsnHirFsf3JHu-wq8CSHXE1IlhZzB5sbU,481
29
+ itkdb_gtk-0.20.1.dist-info/top_level.txt,sha256=KVRrH4OS8ovzNR9bvADE0ABn5bNpSk987tuH0jCfkbU,10
30
+ itkdb_gtk-0.20.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,12 @@
1
+ [gui_scripts]
2
+ createShipments = itkdb_gtk:createShipments
3
+ findDBComponent = itkdb_gtk:findDBComponent
4
+ getShipments = itkdb_gtk:getShipments
5
+ glueWeight = itkdb_gtk:glueWeight
6
+ itkdb_dashBoard = itkdb_gtk:dash_board
7
+ panelVisualInspection = itkdb_gtk:panelVisualInspection
8
+ uploadModuleIV = itkdb_gtk:uploadModuleIV
9
+ uploadMultipleTests = itkdb_gtk:uploadMultipleTests
10
+ uploadTest = itkdb_gtk:uploadTest
11
+ visualInspection = itkdb_gtk:visualInspection
12
+ wirebondTest = itkdb_gtk:wirebondTest
@@ -1,131 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Check childre of DB component."""
3
-
4
- try:
5
- import readAVSdata
6
- import ITkDBlogin
7
- import ITkDButils
8
-
9
- from dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
10
-
11
- except ModuleNotFoundError:
12
- from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils
13
- from itkdb_gtk.dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
14
-
15
- import json
16
-
17
-
18
- def complain(main_msg, secondary_msg=None):
19
- """Prints an error message
20
-
21
- Args:
22
- -----
23
- main (): Main message
24
- secondary (): Seconday message
25
- """
26
- print("**Error\n{}".format(main_msg))
27
- if secondary_msg:
28
- msg = secondary_msg.replace("\n", "\n\t")
29
- print("\t{}".format(msg))
30
-
31
-
32
- def find_petal(session, SN, silent=False):
33
- """Finds petal with given SN."""
34
- try:
35
- petal_core = ITkDButils.get_DB_component(session, SN)
36
-
37
- except Exception as E:
38
- if not silent:
39
- complain("Could not find Petal Core in DB", str(E))
40
-
41
- petal_core = None
42
- return
43
-
44
- try:
45
- if petal_core["type"]["code"] != "CORE_AVS":
46
- complain("Wrong component type", "This is not an AVS petal core")
47
-
48
- # print(json.dumps(petal_core, indent=3))
49
-
50
- except KeyError:
51
- # Petal is not there
52
- petal_core = None
53
-
54
- return petal_core
55
-
56
-
57
- def get_type(child):
58
- """Return object type
59
-
60
- Args:
61
- -----
62
- child (): object
63
-
64
- Returns
65
- -------
66
- str: object type
67
-
68
- """
69
- if child["type"] is not None:
70
- ctype = child["type"]["code"]
71
- else:
72
- ctype = child["componentType"]["code"]
73
-
74
- return ctype
75
-
76
-
77
- def main():
78
- """Main entry point."""
79
- # ITk_PB authentication
80
- dlg = ITkDBlogin.ITkDBlogin()
81
- session = dlg.get_client()
82
-
83
- # find all cores
84
- # Now all the objects
85
- payload = {
86
- "componentType": ["BT"],
87
- "componentType": ["CORE_PETAL"],
88
- "type": ["CORE_AVS"],
89
- }
90
- core_list = session.get("listComponents", json=payload)
91
-
92
- for obj in core_list:
93
- SN = obj["serialNumber"]
94
- id = obj['alternativeIdentifier']
95
- core = find_petal(session, SN)
96
- if core is None:
97
- print("SN: not a petal core.")
98
- continue
99
-
100
- location = core["currentLocation"]['code']
101
- stage = core["currentStage"]['code']
102
- if "children" not in core:
103
- complain("{}[{}]".format(SN, id), "Not assembled")
104
- continue
105
-
106
- print("Petal {} [{}] - {}. {}".format(SN, id, stage, location))
107
- clist = []
108
- for child in core["children"]:
109
- cstage = "Missing"
110
- if child["component"] is None:
111
- ctype = get_type(child)
112
- clist.append((ctype, cstage, None, None))
113
-
114
- else:
115
- SN = child["component"]["serialNumber"]
116
- ctype = get_type(child)
117
- cobj = ITkDButils.get_DB_component(session, SN)
118
- cstage = cobj["currentStage"]['code']
119
- clocation = cobj["currentLocation"]['code']
120
- clist.append((ctype, cstage, SN, clocation))
121
-
122
- for item in clist:
123
- print("\t{} [{}] - {} at {}".format(item[2], item[0], item[1], item[3]))
124
-
125
- print()
126
-
127
- dlg.die()
128
-
129
-
130
- if __name__ == "__main__":
131
- main()