itkdb-gtk 0.16.0__py3-none-any.whl → 0.18.0__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.
Potentially problematic release.
This version of itkdb-gtk might be problematic. Click here for more details.
- itkdb_gtk/CreateShipments.py +3 -4
- itkdb_gtk/GetShipments.py +7 -6
- itkdb_gtk/ITkDButils.py +11 -6
- itkdb_gtk/PanelVisualInspection.py +3 -5
- itkdb_gtk/QRScanner.py +150 -0
- itkdb_gtk/UploadMultipleTests.py +6 -3
- itkdb_gtk/VisualInspection.py +3 -4
- itkdb_gtk/__init__.py +6 -1
- itkdb_gtk/dashBoard.py +30 -0
- itkdb_gtk/dbGtkUtils.py +0 -29
- itkdb_gtk/findComponent.py +145 -0
- {itkdb_gtk-0.16.0.dist-info → itkdb_gtk-0.18.0.dist-info}/METADATA +1 -1
- itkdb_gtk-0.18.0.dist-info/RECORD +29 -0
- {itkdb_gtk-0.16.0.dist-info → itkdb_gtk-0.18.0.dist-info}/entry_points.txt +1 -0
- itkdb_gtk-0.16.0.dist-info/RECORD +0 -27
- {itkdb_gtk-0.16.0.dist-info → itkdb_gtk-0.18.0.dist-info}/WHEEL +0 -0
- {itkdb_gtk-0.16.0.dist-info → itkdb_gtk-0.18.0.dist-info}/top_level.txt +0 -0
itkdb_gtk/CreateShipments.py
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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
|
itkdb_gtk/GetShipments.py
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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:
|
|
@@ -199,8 +198,10 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
199
198
|
if self.store:
|
|
200
199
|
lv_iter = self.store.get_iter_first()
|
|
201
200
|
while lv_iter:
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
mSN = self.store.get_value(lv_iter, 0)
|
|
202
|
+
mID = self.store.get_value(lv_iter, 5)
|
|
203
|
+
if mSN == txt or mID == txt:
|
|
204
|
+
self.write_message("...found {}\n".format(mSN))
|
|
204
205
|
self.store[lv_iter][3] = False
|
|
205
206
|
|
|
206
207
|
lv_iter = self.store.iter_next(lv_iter)
|
itkdb_gtk/ITkDButils.py
CHANGED
|
@@ -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 =
|
|
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 =
|
|
407
|
-
attachment = {'data': (path.as_posix(), open(path.as_posix(), 'rb'), filetype
|
|
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 =
|
|
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,
|
|
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
|
|
itkdb_gtk/QRScanner.py
ADDED
|
@@ -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()
|
itkdb_gtk/UploadMultipleTests.py
CHANGED
|
@@ -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
|
-
|
|
691
|
-
|
|
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
|
|
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
|
|
itkdb_gtk/VisualInspection.py
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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
|
|
itkdb_gtk/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
""" itkdb-gtk python module
|
|
2
2
|
"""
|
|
3
|
-
__version__ = "0.
|
|
3
|
+
__version__ = "0.18.0"
|
|
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()
|
itkdb_gtk/dashBoard.py
CHANGED
|
@@ -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
|
itkdb_gtk/dbGtkUtils.py
CHANGED
|
@@ -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:
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
|
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.scanner = QRScanner.QRScanner(self.get_qrcode)
|
|
36
|
+
self.init_window()
|
|
37
|
+
|
|
38
|
+
def init_window(self):
|
|
39
|
+
"""Create the Gtk window."""
|
|
40
|
+
# Initial tweaks
|
|
41
|
+
self.set_border_width(10)
|
|
42
|
+
|
|
43
|
+
# Prepare HeaderBar
|
|
44
|
+
self.hb.props.title = "Find Component"
|
|
45
|
+
|
|
46
|
+
# Object Data
|
|
47
|
+
lbl = Gtk.Label(label="Scan your QR or bar code. Information will appear below.")
|
|
48
|
+
self.mainBox.pack_start(lbl, False, False, 10)
|
|
49
|
+
|
|
50
|
+
#btn = Gtk.Button(label="Test Button")
|
|
51
|
+
#btn.connect("clicked", self.test_qrcode)
|
|
52
|
+
#self.mainBox.pack_start(btn, True, True, 0)
|
|
53
|
+
|
|
54
|
+
# The text view
|
|
55
|
+
self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
|
|
56
|
+
|
|
57
|
+
self.show_all()
|
|
58
|
+
|
|
59
|
+
def get_qrcode(self, txt):
|
|
60
|
+
"""Gets data from QR scanner."""
|
|
61
|
+
if txt.find("J-SD") == 0:
|
|
62
|
+
try:
|
|
63
|
+
SN = find_vtrx(self.session, txt)
|
|
64
|
+
except ValueError as e:
|
|
65
|
+
self.write_message("Error: {}\n".format(e))
|
|
66
|
+
return
|
|
67
|
+
else:
|
|
68
|
+
SN = txt
|
|
69
|
+
|
|
70
|
+
obj = ITkDButils.get_DB_component(self.session, SN)
|
|
71
|
+
if obj is None:
|
|
72
|
+
self.write_message("Object not found in DB\n")
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
msg = "\n{}\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc. {}\nObject stage: {} - {}\n".format(
|
|
76
|
+
txt,
|
|
77
|
+
obj["serialNumber"],
|
|
78
|
+
obj["alternativeIdentifier"],
|
|
79
|
+
obj["componentType"]["name"],
|
|
80
|
+
obj["currentLocation"]["name"],
|
|
81
|
+
obj["currentStage"]["code"],
|
|
82
|
+
obj["currentStage"]["name"])
|
|
83
|
+
|
|
84
|
+
self.write_message(msg)
|
|
85
|
+
|
|
86
|
+
def test_qrcode(self, *args):
|
|
87
|
+
"""Gets data from QR scanner."""
|
|
88
|
+
txt = "a3c671bf38d3957dc053c6e5471aa27e"
|
|
89
|
+
self.write_message("{}\n".format(txt))
|
|
90
|
+
|
|
91
|
+
if txt.find("J-SD") == 0:
|
|
92
|
+
try:
|
|
93
|
+
SN = find_vtrx(self.session, txt)
|
|
94
|
+
except ValueError as e:
|
|
95
|
+
self.write_message("Error: {}\n".format(e))
|
|
96
|
+
return
|
|
97
|
+
else:
|
|
98
|
+
SN = txt
|
|
99
|
+
|
|
100
|
+
obj = ITkDButils.get_DB_component(self.session, SN)
|
|
101
|
+
if obj is None:
|
|
102
|
+
self.write_message("Object not found in DB\n")
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
msg = "\n\nObject SN: {}\nObject Alt. ID: {}\nObject Type: {}\nObject Loc.: {}\nObject stage: {} - {}\n".format(
|
|
107
|
+
obj["serialNumber"],
|
|
108
|
+
obj["alternativeIdentifier"],
|
|
109
|
+
obj["componentType"]["name"],
|
|
110
|
+
obj["currentLocation"]["name"],
|
|
111
|
+
obj["currentStage"]["code"],
|
|
112
|
+
obj["currentStage"]["name"])
|
|
113
|
+
|
|
114
|
+
self.write_message(msg)
|
|
115
|
+
self.write_message("")
|
|
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
|
+
window.set_accept_focus(True)
|
|
133
|
+
window.present()
|
|
134
|
+
window.connect("destroy", Gtk.main_quit)
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
Gtk.main()
|
|
138
|
+
|
|
139
|
+
except KeyboardInterrupt:
|
|
140
|
+
print("Arrrgggg!!!")
|
|
141
|
+
|
|
142
|
+
dlg.die()
|
|
143
|
+
|
|
144
|
+
if __name__ == "__main__":
|
|
145
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itkdb_gtk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.0
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
itkdb_gtk/CreateShipments.py,sha256=zE6FZ5WJebgK4MX8ps0FdcIqE51jiL00-k4TdZfrH8E,13206
|
|
2
|
+
itkdb_gtk/GetShipments.py,sha256=qz9B6ZDozvENLUQDFb5f1gq3dgqhHgllo2VwYGn1OO0,19239
|
|
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=0Uy30SNA4I-F1PJfK3tqNb6VQZLGH84VBEwlT3HdF5E,20466
|
|
9
|
+
itkdb_gtk/QRScanner.py,sha256=s37NBL1bL7y51-9ZvXij8XDp7-EQ3t3xAYnx7eEsQ3k,4499
|
|
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=4bBIpJpG9oVVIE1zLPr6YAuda4VidD5limm14vPXCIw,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=zXksALmvsKRDasYMfRETY_dYZ2P73GRLTmioVRHZD9w,4113
|
|
23
|
+
itkdb_gtk/readGoogleSheet.py,sha256=Lzm_oPWwDqZZzKoBUgsp277F9-wCfr_BA0X4VD2Eolo,2673
|
|
24
|
+
itkdb_gtk/untrash_component.py,sha256=VrN46-f-kF7voOxtoh7OL-bZSWAaIFb7-Xbx6_WT7K8,757
|
|
25
|
+
itkdb_gtk-0.18.0.dist-info/METADATA,sha256=U3SrifHzL18JiJ0_cKrkg6fNSnP4bxDRBjges7VwWuk,3149
|
|
26
|
+
itkdb_gtk-0.18.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
itkdb_gtk-0.18.0.dist-info/entry_points.txt,sha256=vN0_mqIT6NwsnHirFsf3JHu-wq8CSHXE1IlhZzB5sbU,481
|
|
28
|
+
itkdb_gtk-0.18.0.dist-info/top_level.txt,sha256=KVRrH4OS8ovzNR9bvADE0ABn5bNpSk987tuH0jCfkbU,10
|
|
29
|
+
itkdb_gtk-0.18.0.dist-info/RECORD,,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
itkdb_gtk/CreateShipments.py,sha256=eiVjw7zGLGAoqWxThBc6IVvXLUFXmtQ-_hpZzfDOKx0,13249
|
|
2
|
-
itkdb_gtk/GetShipments.py,sha256=b3TECQhHlK0kGXH6KjQs06yuzIfTN5tjtiu6wnEOuJ8,19172
|
|
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=AUYbSexIMsCsAKRoKOAVn0jM31e5JQvioEdxtgBztvg,21454
|
|
8
|
-
itkdb_gtk/PanelVisualInspection.py,sha256=96_JMfJXfaqxN4vq2Y9rjdRY7pikuobOTGmrSOxHwV8,20511
|
|
9
|
-
itkdb_gtk/SensorUtils.py,sha256=fYWF9TeutAbore53dLWNlZnVn9P3OsKYcFLNGOs8cnI,15426
|
|
10
|
-
itkdb_gtk/ShowAttachments.py,sha256=KExxPCdbcb04XS8JSUkg5xF1McvlB8e9btwctDCKNXU,8498
|
|
11
|
-
itkdb_gtk/ShowComments.py,sha256=OiMTFLnhGbbKRj5x61D517BYHAt-qY5Y1lvR3EQz3c0,3151
|
|
12
|
-
itkdb_gtk/ShowDefects.py,sha256=aVAHeaE5IztmAPEuHwhi06KWo_pi9xX2J1fTLhKyAPI,3530
|
|
13
|
-
itkdb_gtk/UploadModuleIV.py,sha256=sqh52bSxANBwlmVWZlDqFXpqRGf0rV0QsjJWC-tY_qI,17792
|
|
14
|
-
itkdb_gtk/UploadMultipleTests.py,sha256=ZT5aStkBL62_VUj41dGKN0eN95cGizYS_CLOEEFRvuo,25186
|
|
15
|
-
itkdb_gtk/UploadTest.py,sha256=ukgJ5-IG12bqa1QIp3bXIV8hkdXCv5UDxh1lQswN_ko,16832
|
|
16
|
-
itkdb_gtk/VisualInspection.py,sha256=akKPWGbE9DxqTM1csCbov9SqnlTvW_RRKtpqWV64zG4,9841
|
|
17
|
-
itkdb_gtk/WireBondGui.py,sha256=WFTLOw4l5JxSbvh4vZMxcF65fqlwvNw0fOyEru9ijqQ,39850
|
|
18
|
-
itkdb_gtk/__init__.py,sha256=3hE2Z_hJsWdbxD6S8gcExdz8TsDGLpRtDlpLVzoWAVU,1156
|
|
19
|
-
itkdb_gtk/dashBoard.py,sha256=DHoCxqhCtOvh7s3lMDJIxFVKEVCVvlnlteEyOjmUgIk,11432
|
|
20
|
-
itkdb_gtk/dbGtkUtils.py,sha256=THW-IT5UJB1YluvUVIfpy6oIY2faSHChNKGTpY5qzag,30480
|
|
21
|
-
itkdb_gtk/readGoogleSheet.py,sha256=Lzm_oPWwDqZZzKoBUgsp277F9-wCfr_BA0X4VD2Eolo,2673
|
|
22
|
-
itkdb_gtk/untrash_component.py,sha256=VrN46-f-kF7voOxtoh7OL-bZSWAaIFb7-Xbx6_WT7K8,757
|
|
23
|
-
itkdb_gtk-0.16.0.dist-info/METADATA,sha256=lXCQHXOmKPk1z38zdDAeOZFn-c_RsQV923CRr_fLib4,3149
|
|
24
|
-
itkdb_gtk-0.16.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
-
itkdb_gtk-0.16.0.dist-info/entry_points.txt,sha256=pKg7qpsrZh1GUQ-n3aFsSxmTVm0h4Qdb_6nsNO_PsFw,437
|
|
26
|
-
itkdb_gtk-0.16.0.dist-info/top_level.txt,sha256=KVRrH4OS8ovzNR9bvADE0ABn5bNpSk987tuH0jCfkbU,10
|
|
27
|
-
itkdb_gtk-0.16.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|