itkdb-gtk 0.17.0__tar.gz → 0.18.0.dev2__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.

Files changed (40) hide show
  1. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/PKG-INFO +1 -1
  2. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ITkDButils.py +16 -6
  3. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/UploadMultipleTests.py +6 -3
  4. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/__init__.py +6 -1
  5. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/dashBoard.py +30 -0
  6. itkdb_gtk-0.18.0.dev2/itkdb_gtk/findComponent.py +141 -0
  7. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/PKG-INFO +1 -1
  8. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/SOURCES.txt +1 -0
  9. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/entry_points.txt +1 -0
  10. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/pyproject.toml +2 -1
  11. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/README.md +0 -0
  12. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/CreateShipments.py +0 -0
  13. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/GetShipments.py +0 -0
  14. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/GlueWeight.py +0 -0
  15. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ITkDB.desktop +0 -0
  16. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ITkDB.svg +0 -0
  17. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ITkDBlogin.py +0 -0
  18. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/PanelVisualInspection.py +0 -0
  19. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/SensorUtils.py +0 -0
  20. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ShowAttachments.py +0 -0
  21. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ShowComments.py +0 -0
  22. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/ShowDefects.py +0 -0
  23. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/UploadModuleIV.py +0 -0
  24. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/UploadTest.py +0 -0
  25. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/VisualInspection.py +0 -0
  26. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/WireBondGui.py +0 -0
  27. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/dbGtkUtils.py +0 -0
  28. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/readGoogleSheet.py +0 -0
  29. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk/untrash_component.py +0 -0
  30. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
  31. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/requires.txt +0 -0
  32. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/itkdb_gtk.egg-info/top_level.txt +0 -0
  33. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/setup.cfg +0 -0
  34. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/testAnimated.py +0 -0
  35. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/testBatch.py +0 -0
  36. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/testComponent.py +0 -0
  37. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/testRange.py +0 -0
  38. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/testThread.py +0 -0
  39. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/test_attachment.py +0 -0
  40. {itkdb_gtk-0.17.0 → itkdb_gtk-0.18.0.dev2}/test/test_holes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itkdb_gtk
3
- Version: 0.17.0
3
+ Version: 0.18.0.dev2
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,5 +1,6 @@
1
1
  """Utilities for the inteaction with the ITkDB."""
2
2
  import mimetypes
3
+ import traceback
3
4
  from collections.abc import Iterable
4
5
  from datetime import datetime
5
6
  from pathlib import Path
@@ -7,6 +8,8 @@ import getpass
7
8
 
8
9
  import dateutil.parser
9
10
  import itkdb
11
+ import magic
12
+ import locale
10
13
 
11
14
  # The response of the DB
12
15
  db_response = ""
@@ -377,13 +380,18 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
377
380
  if newRn not in runN:
378
381
  data["runNumber"] = newRn
379
382
  break
380
-
383
+
381
384
  # Try to upload the test
382
385
  try:
383
386
  db_response = client.post("uploadTestRunResults", json=data)
384
387
  testRun = db_response["testRun"]["id"]
385
388
  uploaded_test_runs.append(testRun)
386
389
 
390
+ except Exception as e:
391
+ msg = "Could not upload the test:\n{}".format(str(e))
392
+ return msg
393
+
394
+ try:
387
395
  # Handle attachments.
388
396
  attachment_urls = {}
389
397
  if attachments is not None:
@@ -402,12 +410,12 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
402
410
  print("File {} does not exist".format(path))
403
411
  continue
404
412
 
405
- data["url"] = path.as_uri()
406
- filetype = mimetypes.guess_type(path.name)
407
- attachment = {'data': (path.as_posix(), open(path.as_posix(), 'rb'), filetype[0])}
413
+ data["url"] = str(path.as_uri())
414
+ filetype = itkdb.utils.get_mimetype(path.as_posix(), None)
415
+ attachment = {'data': (path.as_posix(), open(path.as_posix(), 'rb'), filetype)}
408
416
  else:
409
417
  data["url"] = att.url
410
- filetype = mimetypes.guess_type(att.url)
418
+ filetype = itkdb.utils.get_mimetype(att.url, None)
411
419
  attachment = {'data':(att.url, None, "text/x-uri") }
412
420
 
413
421
  db_response = client.post('createTestRunAttachment',
@@ -424,7 +432,9 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
424
432
  return None
425
433
 
426
434
  except Exception as e:
427
- return (str(e))
435
+ print(traceback.format_exc())
436
+ return "Could not upload attachment:\n{}".format(str(e))
437
+
428
438
 
429
439
  def set_test_run_parameter(session, test_run, parameter, value):
430
440
  """Modify testRun Parameter
@@ -687,8 +687,11 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
687
687
  rc = ITkDButils.upload_test(self.session, payload, values[TestList.Attachments], check_runNumber=True)
688
688
  if rc:
689
689
  ipos = rc.find("The following details may help:")
690
- msg = rc[ipos:]
691
- dbGtkUtils.complain("Failed uploading test {}-{}".format(payload["component"], payload["testType"]))
690
+ if ipos>=0:
691
+ msg = rc[ipos:]
692
+ else:
693
+ msg = rc
694
+ dbGtkUtils.complain("Failed uploading test {}-{}\n".format(payload["component"], payload["testType"]), msg)
692
695
  self.write_message("Failed uploading test {}-{}\n{}\n".format(payload["component"], payload["testType"], msg))
693
696
  nbad += 1
694
697
 
@@ -702,7 +705,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
702
705
  model.remove(past_iter)
703
706
 
704
707
  if nbad>0:
705
- dbGtkUtils.complain("Failed to upload all tests", "{} test had errors.\nThey are left in the ListView.")
708
+ dbGtkUtils.complain("Failed to upload some tests", "{}/{} tests had errors.\nThey are left in the ListView.".format(nbad, ngood))
706
709
  else:
707
710
  dbGtkUtils.complain("All {} tests uploaded succesfully".format(ngood))
708
711
 
@@ -1,6 +1,6 @@
1
1
  """ itkdb-gtk python module
2
2
  """
3
- __version__ = "0.17.0"
3
+ __version__ = "0.18.0.dev2"
4
4
 
5
5
 
6
6
  def dash_board():
@@ -55,3 +55,8 @@ def visualInspection():
55
55
  """Visual inspection of Modules/Sensors."""
56
56
  from .VisualInspection import main
57
57
  main()
58
+
59
+ def findDBComponent():
60
+ """Find object from QR or bar code"""
61
+ from .findComponent import main
62
+ main()
@@ -22,6 +22,7 @@ from itkdb_gtk import UploadModuleIV
22
22
  from itkdb_gtk import WireBondGui
23
23
  from itkdb_gtk import PanelVisualInspection
24
24
  from itkdb_gtk import VisualInspection
25
+ from itkdb_gtk import findComponent
25
26
 
26
27
 
27
28
  HAS_PETALQC=False
@@ -59,6 +60,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
59
60
  PETAL_CORE_METRO = 11
60
61
  PETAL_CORE_THERMAL = 12
61
62
  PETAL_INFORMATION = 13
63
+ FIND_COMPONENT = 14
62
64
 
63
65
  def __init__(self, session):
64
66
  """Initialization."""
@@ -162,6 +164,19 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
162
164
  recS.connect("clicked", self.receive_shipment)
163
165
  grid.attach(recS, 1, irow, 1, 1,)
164
166
 
167
+ irow += 1
168
+ lbl = Gtk.Label()
169
+ lbl.set_markup("<b>Utils</b>")
170
+ lbl.set_xalign(0)
171
+ grid.attach(lbl, 0, irow, 1, 1)
172
+
173
+ irow += 1
174
+ findC = Gtk.Button(label="Find Component")
175
+ findC.connect("clicked", self.find_component)
176
+ findC.set_tooltip_text("Scan your QR or bar code and get info from DB.")
177
+ grid.attach(findC, 0, irow, 1, 1,)
178
+
179
+
165
180
  self.mainBox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL), False, True, 5)
166
181
 
167
182
  self.show_all()
@@ -296,6 +311,21 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
296
311
  W.connect("destroy", self.app_closed, bitn)
297
312
  W.show_all()
298
313
 
314
+
315
+ def find_component(self, *args):
316
+ """Find Component."""
317
+ bitn = DashWindow.FIND_COMPONENT
318
+ bt = 1 << bitn
319
+ if self.mask & bt:
320
+ return
321
+
322
+ W = findComponent.FindComponent(
323
+ self.session,
324
+ help_link="{}/findComponent.html".format(HELP_LINK)
325
+ )
326
+
327
+ W.connect("destroy", self.app_closed, bitn)
328
+
299
329
  def petal_reception(self, *args):
300
330
  """Petal GND/VI test."""
301
331
  bitn = DashWindow.PETAL_RECEPTION
@@ -0,0 +1,141 @@
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
16
+ from itkdb_gtk.GetShipments import find_vtrx
17
+
18
+
19
+ import gi
20
+ gi.require_version("Gtk", "3.0")
21
+ from gi.repository import Gtk, Gio
22
+
23
+ class FindComponent(dbGtkUtils.ITkDBWindow):
24
+ """Read QR of bar code and retrieve information about component."""
25
+
26
+ def __init__(self, session, help_link=None):
27
+ """Initialization.
28
+
29
+ Args:
30
+ session: ITkDB session
31
+ help_link: link to help page.
32
+
33
+ """
34
+ super().__init__(session=session, title="Find Component", help_link=help_link)
35
+ self.init_window()
36
+
37
+ def init_window(self):
38
+ """Create the Gtk window."""
39
+ # Initial tweaks
40
+ self.set_border_width(10)
41
+
42
+ # Prepare HeaderBar
43
+ self.hb.props.title = "Find Component"
44
+
45
+ # Object Data
46
+ lbl = Gtk.Label(label="Scan your QR or bar code. Information will appear below.")
47
+ self.mainBox.pack_start(lbl, True, True, 0)
48
+
49
+ #btn = Gtk.Button(label="Test Button")
50
+ #btn.connect("clicked", self.test_qrcode)
51
+ #self.mainBox.pack_start(btn, True, True, 0)
52
+
53
+ # The text view
54
+ self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
55
+
56
+ self.show_all()
57
+
58
+ def get_qrcode(self, fd, state, reader):
59
+ """Gets data from QR scanner."""
60
+ txt = dbGtkUtils.scanner_get_line(reader)
61
+ self.write_message("{}\n".format(txt))
62
+
63
+ if txt.find("J-SD") == 0:
64
+ try:
65
+ SN = find_vtrx(self.session, txt)
66
+ except ValueError as e:
67
+ self.write_message("Error: {}\n".format(e))
68
+ return
69
+ else:
70
+ SN = txt
71
+
72
+ obj = ITkDButils.get_DB_component(self.session, SN)
73
+ if obj is None:
74
+ self.write_message("Object not found in DB\n")
75
+ return
76
+
77
+ msg = "\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc. {}\nObject stage: {} - {}".format(
78
+ obj["serialNumber"],
79
+ obj["alternativeIdentifier"],
80
+ obj["componentType"]["name"],
81
+ obj["currentLocation"]["name"],
82
+ obj["currentStage"]["code"],
83
+ obj["currentStage"]["name"])
84
+
85
+ self.write_message(msg)
86
+
87
+ def test_qrcode(self, *args):
88
+ """Gets data from QR scanner."""
89
+ txt = "a3c671bf38d3957dc053c6e5471aa27e"
90
+ self.write_message("{}\n".format(txt))
91
+
92
+ if txt.find("J-SD") == 0:
93
+ try:
94
+ SN = find_vtrx(self.session, txt)
95
+ except ValueError as e:
96
+ self.write_message("Error: {}\n".format(e))
97
+ return
98
+ else:
99
+ SN = txt
100
+
101
+ obj = ITkDButils.get_DB_component(self.session, SN)
102
+ if obj is None:
103
+ self.write_message("Object not found in DB\n")
104
+ return
105
+
106
+
107
+ msg = "\n\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc.: {}\nObject stage: {} - {}\n".format(
108
+ obj["serialNumber"],
109
+ obj["alternativeIdentifier"],
110
+ obj["componentType"]["name"],
111
+ obj["currentLocation"]["name"],
112
+ obj["currentStage"]["code"],
113
+ obj["currentStage"]["name"])
114
+
115
+ self.write_message(msg)
116
+
117
+ def main():
118
+ """Main entry."""
119
+ HELP_LINK="https://itkdb-gtk.docs.cern.ch/uploadSingleTest.html"
120
+
121
+ # DB login
122
+ dlg = ITkDBlogin.ITkDBlogin()
123
+ client = dlg.get_client()
124
+ if client is None:
125
+ print("Could not connect to DB with provided credentials.")
126
+ dlg.die()
127
+ sys.exit()
128
+
129
+ client.user_gui = dlg
130
+
131
+ window = FindComponent(client, help_link=HELP_LINK)
132
+ try:
133
+ Gtk.main()
134
+
135
+ except KeyboardInterrupt:
136
+ print("Arrrgggg!!!")
137
+
138
+ dlg.die()
139
+
140
+ if __name__ == "__main__":
141
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itkdb_gtk
3
- Version: 0.17.0
3
+ Version: 0.18.0.dev2
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
@@ -20,6 +20,7 @@ itkdb_gtk/WireBondGui.py
20
20
  itkdb_gtk/__init__.py
21
21
  itkdb_gtk/dashBoard.py
22
22
  itkdb_gtk/dbGtkUtils.py
23
+ itkdb_gtk/findComponent.py
23
24
  itkdb_gtk/readGoogleSheet.py
24
25
  itkdb_gtk/untrash_component.py
25
26
  itkdb_gtk.egg-info/PKG-INFO
@@ -1,5 +1,6 @@
1
1
  [gui_scripts]
2
2
  createShipments = itkdb_gtk:createShipments
3
+ findDBComponent = itkdb_gtk:findDBComponent
3
4
  getShipments = itkdb_gtk:getShipments
4
5
  glueWeight = itkdb_gtk:glueWeight
5
6
  itkdb_dashBoard = itkdb_gtk:dash_board
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itkdb_gtk"
7
- version = "0.17.0"
7
+ version = "0.18.0.dev2"
8
8
  authors = [
9
9
  { name="Carlos Lacasta", email="carlos.lacasta@cern.ch" },
10
10
  ]
@@ -37,6 +37,7 @@ uploadModuleIV = "itkdb_gtk:uploadModuleIV"
37
37
  wirebondTest = "itkdb_gtk:wirebondTest"
38
38
  panelVisualInspection = "itkdb_gtk:panelVisualInspection"
39
39
  visualInspection = "itkdb_gtk:visualInspection"
40
+ findDBComponent = "itkdb_gtk:findDBComponent"
40
41
 
41
42
  [tool.setuptools]
42
43
  include-package-data = true
File without changes
File without changes