itkdb-gtk 0.18.0.dev1__tar.gz → 0.18.0.dev3__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 (41) hide show
  1. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/PKG-INFO +1 -1
  2. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/CreateShipments.py +3 -4
  3. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/GetShipments.py +3 -4
  4. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ITkDButils.py +11 -6
  5. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/PanelVisualInspection.py +3 -5
  6. itkdb_gtk-0.18.0.dev3/itkdb_gtk/QRScanner.py +150 -0
  7. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/UploadMultipleTests.py +6 -3
  8. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/VisualInspection.py +3 -4
  9. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/__init__.py +6 -1
  10. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/dbGtkUtils.py +0 -29
  11. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/findComponent.py +22 -18
  12. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/PKG-INFO +1 -1
  13. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/SOURCES.txt +1 -0
  14. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/entry_points.txt +1 -0
  15. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/pyproject.toml +2 -1
  16. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/README.md +0 -0
  17. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/GlueWeight.py +0 -0
  18. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ITkDB.desktop +0 -0
  19. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ITkDB.svg +0 -0
  20. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ITkDBlogin.py +0 -0
  21. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/SensorUtils.py +0 -0
  22. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ShowAttachments.py +0 -0
  23. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ShowComments.py +0 -0
  24. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/ShowDefects.py +0 -0
  25. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/UploadModuleIV.py +0 -0
  26. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/UploadTest.py +0 -0
  27. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/WireBondGui.py +0 -0
  28. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/dashBoard.py +0 -0
  29. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/readGoogleSheet.py +0 -0
  30. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk/untrash_component.py +0 -0
  31. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
  32. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/requires.txt +0 -0
  33. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/itkdb_gtk.egg-info/top_level.txt +0 -0
  34. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/setup.cfg +0 -0
  35. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/testAnimated.py +0 -0
  36. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/testBatch.py +0 -0
  37. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/testComponent.py +0 -0
  38. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/testRange.py +0 -0
  39. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/testThread.py +0 -0
  40. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/test_attachment.py +0 -0
  41. {itkdb_gtk-0.18.0.dev1 → itkdb_gtk-0.18.0.dev3}/test/test_holes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itkdb_gtk
3
- Version: 0.18.0.dev1
3
+ Version: 0.18.0.dev3
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
@@ -15,7 +15,7 @@ except ImportError:
15
15
  cwd = Path(__file__).parent.parent
16
16
  sys.path.append(cwd.as_posix())
17
17
 
18
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
18
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner
19
19
 
20
20
  import gi
21
21
  gi.require_version("Gtk", "3.0")
@@ -51,7 +51,7 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
51
51
  self.set_border_width(10)
52
52
 
53
53
  # intercept keyboard
54
- dbGtkUtils.setup_scanner(self.get_qrcode)
54
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
55
55
 
56
56
  # Prepare HeaderBar
57
57
  self.hb.props.title = "Create Shipment"
@@ -300,9 +300,8 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
300
300
  else:
301
301
  self.write_message("No attachment found\n")
302
302
 
303
- def get_qrcode(self, fd, state, reader):
303
+ def get_qrcode(self, txt):
304
304
  """Gets data from QR scanner."""
305
- txt = dbGtkUtils.scanner_get_line(reader)
306
305
  self.write_message("{}\n".format(txt))
307
306
 
308
307
  # Try to add item to the list
@@ -10,7 +10,7 @@ except ImportError:
10
10
  cwd = Path(__file__).parent.parent
11
11
  sys.path.append(cwd.as_posix())
12
12
 
13
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
13
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner
14
14
  import gi
15
15
 
16
16
  gi.require_version("Gtk", "3.0")
@@ -77,7 +77,7 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
77
77
  self.set_border_width(10)
78
78
 
79
79
  # intercept keyboard
80
- dbGtkUtils.setup_scanner(self.get_qrcode)
80
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
81
81
 
82
82
  # Prepare HeaderBar
83
83
  self.hb.props.title = "{} shipments".format(self.recipient)
@@ -183,9 +183,8 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
183
183
 
184
184
  return scrolled
185
185
 
186
- def get_qrcode(self, fd, state, reader):
186
+ def get_qrcode(self, txt):
187
187
  """Gets data from QR scanner."""
188
- txt = dbGtkUtils.scanner_get_line(reader)
189
188
  self.write_message("{}\n".format(txt))
190
189
 
191
190
  if txt.find("J-SD") == 0:
@@ -1,5 +1,4 @@
1
1
  """Utilities for the inteaction with the ITkDB."""
2
- import mimetypes
3
2
  from collections.abc import Iterable
4
3
  from datetime import datetime
5
4
  from pathlib import Path
@@ -202,7 +201,7 @@ def create_component_attachment(client, SN, file_path, title=None, description="
202
201
  global db_response
203
202
  db_response = None
204
203
  path = Path(file_path).expanduser().resolve()
205
- filetype = mimetypes.guess_type(path)
204
+ filetype = itkdb.utils.get_mimetype(path, None)
206
205
  if title is None:
207
206
  title = path.name
208
207
 
@@ -384,6 +383,11 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
384
383
  testRun = db_response["testRun"]["id"]
385
384
  uploaded_test_runs.append(testRun)
386
385
 
386
+ except Exception as e:
387
+ msg = "Could not upload the test:\n{}".format(str(e))
388
+ return msg
389
+
390
+ try:
387
391
  # Handle attachments.
388
392
  attachment_urls = {}
389
393
  if attachments is not None:
@@ -403,11 +407,11 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
403
407
  continue
404
408
 
405
409
  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])}
410
+ filetype = itkdb.utils.get_mimetype(path.as_posix(), None)
411
+ attachment = {'data': (path.as_posix(), open(path.as_posix(), 'rb'), filetype)}
408
412
  else:
409
413
  data["url"] = att.url
410
- filetype = mimetypes.guess_type(att.url)
414
+ filetype = itkdb.utils.get_mimetype(att.url, None)
411
415
  attachment = {'data':(att.url, None, "text/x-uri") }
412
416
 
413
417
  db_response = client.post('createTestRunAttachment',
@@ -424,7 +428,8 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
424
428
  return None
425
429
 
426
430
  except Exception as e:
427
- return (str(e))
431
+ return "Could not upload attachment:\n{}".format(str(e))
432
+
428
433
 
429
434
  def set_test_run_parameter(session, test_run, parameter, value):
430
435
  """Modify testRun Parameter
@@ -11,7 +11,7 @@ except ImportError:
11
11
  cwd = Path(__file__).parent.parent
12
12
  sys.path.append(cwd.as_posix())
13
13
 
14
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
14
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner
15
15
  from itkdb_gtk.ShowComments import ShowComments
16
16
  from itkdb_gtk.ShowDefects import ShowDefects
17
17
  from itkdb_gtk.UploadTest import create_json_data_editor
@@ -120,8 +120,7 @@ class PanelVisualInspection(dbGtkUtils.ITkDBWindow):
120
120
 
121
121
 
122
122
  self.show_all()
123
-
124
- dbGtkUtils.setup_scanner(self.get_qrcode)
123
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
125
124
 
126
125
  def on_global_image(self, *args):
127
126
  """We choose the global image."""
@@ -553,9 +552,8 @@ class PanelVisualInspection(dbGtkUtils.ITkDBWindow):
553
552
  lv_iter = model.iter_next(lv_iter)
554
553
 
555
554
 
556
- def get_qrcode(self, fd, state, reader):
555
+ def get_qrcode(self,txt):
557
556
  """Read SN from scanner."""
558
- txt = dbGtkUtils.scanner_get_line(reader)
559
557
  self.write_message("SN: {}\n".format(txt))
560
558
  self.SN_ready(txt, self.SN.widget)
561
559
 
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env python3
2
+ """A set of utilities for teh warp scanner."""
3
+ import pathlib
4
+ import serial
5
+
6
+ import gi
7
+ gi.require_version("Gtk", "3.0")
8
+ from gi.repository import GLib
9
+
10
+ def setup_scanner(callback):
11
+ """Setup scanner and callback function."""
12
+ rdr = None
13
+ for fnam in ["/dev/ttyACM0", "/dev/cu.usbmodemS_N_G19F204881"]:
14
+ P = pathlib.Path(fnam)
15
+ if P.exists():
16
+ rdr = serial.Serial(fnam, 9600)
17
+ GLib.unix_fd_add_full(
18
+ GLib.PRIORITY_DEFAULT,
19
+ rdr.fileno(),
20
+ GLib.IOCondition.IN | GLib.IOCondition.ERR | GLib.IOCondition.HUP | GLib.IOCondition.NVAL,
21
+ callback,
22
+ rdr,
23
+ )
24
+ break
25
+
26
+ return rdr
27
+
28
+ def scanner_get_line(reader):
29
+ """Reads a line from serial."""
30
+ available = reader.in_waiting
31
+ while True:
32
+ delta = reader.in_waiting - available
33
+ if not delta:
34
+ break
35
+
36
+ # Get data from serial device passed in via
37
+ data = reader.read_until(expected='\r', size=reader.in_waiting).strip()
38
+ txt = data.decode('utf-8')
39
+ return txt
40
+
41
+
42
+ class QRScanner:
43
+ """Contains information to detect the scanner."""
44
+ def __init__(self, callback):
45
+ self.reader = None
46
+ self.callback = callback
47
+ self.timer_id = None
48
+ self.source_id = None
49
+ self.init_scanner()
50
+
51
+ def init_scanner(self):
52
+ """Sets the scanner."""
53
+ self.setup_scanner()
54
+ if self.reader is None:
55
+ self.timer_id = GLib.timeout_add(500, self.find_scanner)
56
+ else:
57
+ print("Found scanner in {}".format(self.reader.name))
58
+
59
+ def find_scanner(self, *args):
60
+ """Check if the scanner is there."""
61
+ # if the reader is there, stop the timeput
62
+ if self.reader is not None:
63
+ return False
64
+
65
+ # Try to setup the scanner
66
+ self.setup_scanner()
67
+ if self.reader is not None:
68
+ self.timer_id = None
69
+ print("Found scanner in {}".format(self.reader.name))
70
+ return False
71
+ else:
72
+ return True
73
+
74
+
75
+ def setup_scanner(self):
76
+ """Setup scanner and callback function."""
77
+ if self.reader is not None:
78
+ return
79
+
80
+ self.reader = None
81
+ for fnam in ["/dev/ttyACM0", "/dev/cu.usbmodemS_N_G19F204881"]:
82
+ P = pathlib.Path(fnam)
83
+ if P.exists():
84
+ self.reader = serial.Serial(fnam, 9600)
85
+ self.source_id = GLib.unix_fd_add_full(
86
+ GLib.PRIORITY_DEFAULT,
87
+ self.reader.fileno(),
88
+ #GLib.IOCondition.IN | GLib.IOCondition.ERR | GLib.IOCondition.HUP | GLib.IOCondition.NVAL,
89
+ GLib.IOCondition.IN | GLib.IOCondition.ERR | GLib.IOCondition.NVAL,
90
+ self.get_line,
91
+ self.callback,
92
+ )
93
+ break
94
+
95
+
96
+ def finish_timeout(self):
97
+ """Finishes the timeout."""
98
+ GLib.source_remove(self.source_id)
99
+ self.source_id = None
100
+
101
+ self.reader.close()
102
+ self.reader = None
103
+
104
+ # re-start the search of the scanner
105
+ self.timer_id = GLib.timeout_add(500, self.find_scanner)
106
+
107
+ def get_line(self, fd, state, callback):
108
+ """Has to info to read."""
109
+ if state == GLib.IOCondition.IN:
110
+ try:
111
+ available = self.reader.in_waiting
112
+ while True:
113
+ delta = self.reader.in_waiting - available
114
+ if not delta:
115
+ break
116
+
117
+ # Get data from serial device passed in via
118
+ data = self.reader.read_until(expected='\r', size=self.reader.in_waiting).strip()
119
+ txt = data.decode('utf-8')
120
+ if callback:
121
+ callback(txt)
122
+
123
+ except OSError:
124
+ if not pathlib.Path(self.reader.name).exists():
125
+ print("Device unplugged.")
126
+ self.finish_timeout()
127
+ return False
128
+
129
+ return True
130
+
131
+
132
+ else:
133
+ self.finish_timeout()
134
+ return False
135
+
136
+ def get_text_from_scanner(txt):
137
+ """Callback where the scanners sends the text."""
138
+ print("### {}".format(txt))
139
+
140
+ def test_scanner():
141
+ """Test the thing."""
142
+ scanner = QRScanner(get_text_from_scanner)
143
+ loop = GLib.MainLoop()
144
+ try:
145
+ loop.run()
146
+ except KeyboardInterrupt:
147
+ loop.quit()
148
+
149
+ if __name__ == "__main__":
150
+ test_scanner()
@@ -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
 
@@ -11,7 +11,7 @@ except ImportError:
11
11
  cwd = Path(__file__).parent.parent
12
12
  sys.path.append(cwd.as_posix())
13
13
 
14
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
14
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner
15
15
  from itkdb_gtk.ShowComments import ShowComments
16
16
  from itkdb_gtk.ShowDefects import ShowDefects
17
17
  from itkdb_gtk.ShowAttachments import ShowAttachments
@@ -142,7 +142,7 @@ class ModuleVisualInspection(dbGtkUtils.ITkDBWindow):
142
142
  self.write_message("Module Visual Inspection\n")
143
143
  self.show_all()
144
144
 
145
- dbGtkUtils.setup_scanner(self.get_qrcode)
145
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
146
146
 
147
147
  def on_institute(self, combo):
148
148
  """A new recipient has been chosen."""
@@ -261,9 +261,8 @@ class ModuleVisualInspection(dbGtkUtils.ITkDBWindow):
261
261
 
262
262
 
263
263
 
264
- def get_qrcode(self, fd, state, reader):
264
+ def get_qrcode(self, txt):
265
265
  """Read SN from scanner."""
266
- txt = dbGtkUtils.scanner_get_line(reader)
267
266
  self.write_message("SN: {}\n".format(txt))
268
267
  self.SN_ready(txt, self.SN.widget)
269
268
 
@@ -1,6 +1,6 @@
1
1
  """ itkdb-gtk python module
2
2
  """
3
- __version__ = "0.18.0.dev1"
3
+ __version__ = "0.18.0.dev3"
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()
@@ -8,7 +8,6 @@ from collections.abc import Iterable
8
8
  from copy import deepcopy
9
9
  from datetime import datetime
10
10
  import webbrowser
11
- import serial
12
11
 
13
12
  import dateutil.parser
14
13
  import numpy as np
@@ -29,34 +28,6 @@ except ImportError:
29
28
  from itkdb_gtk import ITkDButils
30
29
 
31
30
 
32
- def setup_scanner(callback):
33
- """Setup scanner and callback function."""
34
- for fnam in ["/dev/ttyACM0", "/dev/cu.usbmodemS_N_G19F204881"]:
35
- P = pathlib.Path(fnam)
36
- if P.exists():
37
- rdr = serial.Serial(fnam, 9600)
38
- GLib.unix_fd_add_full(
39
- GLib.PRIORITY_DEFAULT,
40
- rdr.fileno(),
41
- GLib.IOCondition.IN,
42
- callback,
43
- rdr,
44
- )
45
- break
46
-
47
- def scanner_get_line(reader):
48
- """Reads a line from serial."""
49
- available = reader.in_waiting
50
- while True:
51
- delta = reader.in_waiting - available
52
- if not delta:
53
- break
54
-
55
- # Get data from serial device passed in via
56
- data = reader.read_until(expected='\r', size=reader.in_waiting).strip()
57
- txt = data.decode('utf-8')
58
- return txt
59
-
60
31
  def parse_date(txt):
61
32
  """Parse a date."""
62
33
  try:
@@ -12,7 +12,7 @@ except ImportError:
12
12
  cwd = Path(__file__).parent.parent
13
13
  sys.path.append(cwd.as_posix())
14
14
 
15
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
15
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, QRScanner
16
16
  from itkdb_gtk.GetShipments import find_vtrx
17
17
 
18
18
 
@@ -32,6 +32,7 @@ class FindComponent(dbGtkUtils.ITkDBWindow):
32
32
 
33
33
  """
34
34
  super().__init__(session=session, title="Find Component", help_link=help_link)
35
+ self.scanner = QRScanner.QRScanner(self.get_qrcode)
35
36
  self.init_window()
36
37
 
37
38
  def init_window(self):
@@ -44,7 +45,7 @@ class FindComponent(dbGtkUtils.ITkDBWindow):
44
45
 
45
46
  # Object Data
46
47
  lbl = Gtk.Label(label="Scan your QR or bar code. Information will appear below.")
47
- self.mainBox.pack_start(lbl, True, True, 0)
48
+ self.mainBox.pack_start(lbl, False, False, 10)
48
49
 
49
50
  #btn = Gtk.Button(label="Test Button")
50
51
  #btn.connect("clicked", self.test_qrcode)
@@ -52,14 +53,11 @@ class FindComponent(dbGtkUtils.ITkDBWindow):
52
53
 
53
54
  # The text view
54
55
  self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
55
-
56
+
56
57
  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
58
 
59
+ def get_qrcode(self, txt):
60
+ """Gets data from QR scanner."""
63
61
  if txt.find("J-SD") == 0:
64
62
  try:
65
63
  SN = find_vtrx(self.session, txt)
@@ -68,20 +66,21 @@ class FindComponent(dbGtkUtils.ITkDBWindow):
68
66
  return
69
67
  else:
70
68
  SN = txt
71
-
69
+
72
70
  obj = ITkDButils.get_DB_component(self.session, SN)
73
71
  if obj is None:
74
72
  self.write_message("Object not found in DB\n")
75
73
  return
76
-
77
- msg = "\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc. {}\nObject stage: {} - {}".format(
78
- obj["serialNumber"],
74
+
75
+ msg = "\n{}\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc. {}\nObject stage: {} - {}\n".format(
76
+ txt,
77
+ obj["serialNumber"],
79
78
  obj["alternativeIdentifier"],
80
79
  obj["componentType"]["name"],
81
80
  obj["currentLocation"]["name"],
82
81
  obj["currentStage"]["code"],
83
82
  obj["currentStage"]["name"])
84
-
83
+
85
84
  self.write_message(msg)
86
85
 
87
86
  def test_qrcode(self, *args):
@@ -97,22 +96,23 @@ class FindComponent(dbGtkUtils.ITkDBWindow):
97
96
  return
98
97
  else:
99
98
  SN = txt
100
-
99
+
101
100
  obj = ITkDButils.get_DB_component(self.session, SN)
102
101
  if obj is None:
103
102
  self.write_message("Object not found in DB\n")
104
103
  return
105
-
106
-
104
+
105
+
107
106
  msg = "\n\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc.: {}\nObject stage: {} - {}\n".format(
108
- obj["serialNumber"],
107
+ obj["serialNumber"],
109
108
  obj["alternativeIdentifier"],
110
109
  obj["componentType"]["name"],
111
110
  obj["currentLocation"]["name"],
112
111
  obj["currentStage"]["code"],
113
112
  obj["currentStage"]["name"])
114
-
113
+
115
114
  self.write_message(msg)
115
+ self.write_message("")
116
116
 
117
117
  def main():
118
118
  """Main entry."""
@@ -129,6 +129,10 @@ def main():
129
129
  client.user_gui = dlg
130
130
 
131
131
  window = FindComponent(client, help_link=HELP_LINK)
132
+ window.set_accept_focus(True)
133
+ window.present()
134
+ window.connect("destroy", Gtk.main_quit)
135
+
132
136
  try:
133
137
  Gtk.main()
134
138
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itkdb_gtk
3
- Version: 0.18.0.dev1
3
+ Version: 0.18.0.dev3
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
@@ -8,6 +8,7 @@ itkdb_gtk/ITkDB.svg
8
8
  itkdb_gtk/ITkDBlogin.py
9
9
  itkdb_gtk/ITkDButils.py
10
10
  itkdb_gtk/PanelVisualInspection.py
11
+ itkdb_gtk/QRScanner.py
11
12
  itkdb_gtk/SensorUtils.py
12
13
  itkdb_gtk/ShowAttachments.py
13
14
  itkdb_gtk/ShowComments.py
@@ -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.18.0.dev1"
7
+ version = "0.18.0.dev3"
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