itkdb-gtk 0.18.0.dev2__tar.gz → 0.19.0__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.
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/PKG-INFO +1 -1
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/CreateShipments.py +3 -4
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/GetShipments.py +3 -4
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ITkDButils.py +5 -10
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/PanelVisualInspection.py +3 -5
- itkdb_gtk-0.19.0/itkdb_gtk/QRScanner.py +119 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/VisualInspection.py +3 -4
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/__init__.py +1 -1
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/dbGtkUtils.py +0 -29
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/findComponent.py +22 -18
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/PKG-INFO +1 -1
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/SOURCES.txt +1 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/pyproject.toml +1 -1
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/README.md +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/GlueWeight.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ITkDB.desktop +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ITkDB.svg +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ITkDBlogin.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/SensorUtils.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ShowAttachments.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ShowComments.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/ShowDefects.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/UploadModuleIV.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/UploadMultipleTests.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/UploadTest.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/WireBondGui.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/dashBoard.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/readGoogleSheet.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk/untrash_component.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/entry_points.txt +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/requires.txt +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/itkdb_gtk.egg-info/top_level.txt +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/setup.cfg +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/testAnimated.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/testBatch.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/testComponent.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/testRange.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/testThread.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/test_attachment.py +0 -0
- {itkdb_gtk-0.18.0.dev2 → itkdb_gtk-0.19.0}/test/test_holes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itkdb_gtk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.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
|
|
@@ -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
|
|
@@ -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:
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"""Utilities for the inteaction with the ITkDB."""
|
|
2
|
-
import mimetypes
|
|
3
|
-
import traceback
|
|
4
2
|
from collections.abc import Iterable
|
|
5
3
|
from datetime import datetime
|
|
6
4
|
from pathlib import Path
|
|
@@ -8,8 +6,6 @@ import getpass
|
|
|
8
6
|
|
|
9
7
|
import dateutil.parser
|
|
10
8
|
import itkdb
|
|
11
|
-
import magic
|
|
12
|
-
import locale
|
|
13
9
|
|
|
14
10
|
# The response of the DB
|
|
15
11
|
db_response = ""
|
|
@@ -205,7 +201,7 @@ def create_component_attachment(client, SN, file_path, title=None, description="
|
|
|
205
201
|
global db_response
|
|
206
202
|
db_response = None
|
|
207
203
|
path = Path(file_path).expanduser().resolve()
|
|
208
|
-
filetype =
|
|
204
|
+
filetype = itkdb.utils.get_mimetype(path, None)
|
|
209
205
|
if title is None:
|
|
210
206
|
title = path.name
|
|
211
207
|
|
|
@@ -380,7 +376,7 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
380
376
|
if newRn not in runN:
|
|
381
377
|
data["runNumber"] = newRn
|
|
382
378
|
break
|
|
383
|
-
|
|
379
|
+
|
|
384
380
|
# Try to upload the test
|
|
385
381
|
try:
|
|
386
382
|
db_response = client.post("uploadTestRunResults", json=data)
|
|
@@ -390,7 +386,7 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
390
386
|
except Exception as e:
|
|
391
387
|
msg = "Could not upload the test:\n{}".format(str(e))
|
|
392
388
|
return msg
|
|
393
|
-
|
|
389
|
+
|
|
394
390
|
try:
|
|
395
391
|
# Handle attachments.
|
|
396
392
|
attachment_urls = {}
|
|
@@ -410,7 +406,7 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
410
406
|
print("File {} does not exist".format(path))
|
|
411
407
|
continue
|
|
412
408
|
|
|
413
|
-
data["url"] =
|
|
409
|
+
data["url"] = path.as_uri()
|
|
414
410
|
filetype = itkdb.utils.get_mimetype(path.as_posix(), None)
|
|
415
411
|
attachment = {'data': (path.as_posix(), open(path.as_posix(), 'rb'), filetype)}
|
|
416
412
|
else:
|
|
@@ -432,9 +428,8 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
432
428
|
return None
|
|
433
429
|
|
|
434
430
|
except Exception as e:
|
|
435
|
-
print(traceback.format_exc())
|
|
436
431
|
return "Could not upload attachment:\n{}".format(str(e))
|
|
437
|
-
|
|
432
|
+
|
|
438
433
|
|
|
439
434
|
def set_test_run_parameter(session, test_run, parameter, value):
|
|
440
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
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""A set of utilities for teh warp scanner."""
|
|
3
|
+
import pathlib
|
|
4
|
+
import serial
|
|
5
|
+
import serial.tools.list_ports as list_ports
|
|
6
|
+
|
|
7
|
+
import gi
|
|
8
|
+
gi.require_version("Gtk", "3.0")
|
|
9
|
+
from gi.repository import GLib
|
|
10
|
+
|
|
11
|
+
class QRScanner:
|
|
12
|
+
"""Contains information to detect the scanner."""
|
|
13
|
+
def __init__(self, callback):
|
|
14
|
+
self.reader = None
|
|
15
|
+
self.callback = callback
|
|
16
|
+
self.timer_id = None
|
|
17
|
+
self.source_id = None
|
|
18
|
+
self.init_scanner()
|
|
19
|
+
|
|
20
|
+
def init_scanner(self):
|
|
21
|
+
"""Sets the scanner."""
|
|
22
|
+
self.setup_scanner()
|
|
23
|
+
if self.reader is None:
|
|
24
|
+
self.timer_id = GLib.timeout_add(500, self.find_scanner)
|
|
25
|
+
else:
|
|
26
|
+
print("Found scanner in {}".format(self.reader.name))
|
|
27
|
+
|
|
28
|
+
def find_scanner(self, *args):
|
|
29
|
+
"""Check if the scanner is there."""
|
|
30
|
+
# if the reader is there, stop the timeput
|
|
31
|
+
if self.reader is not None:
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
# Try to setup the scanner
|
|
35
|
+
self.setup_scanner()
|
|
36
|
+
if self.reader is not None:
|
|
37
|
+
self.timer_id = None
|
|
38
|
+
print("Found scanner in {}".format(self.reader.name))
|
|
39
|
+
return False
|
|
40
|
+
else:
|
|
41
|
+
return True
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def setup_scanner(self):
|
|
45
|
+
"""Setup scanner and callback function."""
|
|
46
|
+
if self.reader is not None:
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
self.reader = None
|
|
50
|
+
device_signature = '05f9:4204'
|
|
51
|
+
candidates = list(list_ports.grep(device_signature))
|
|
52
|
+
if not candidates:
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
self.reader = serial.Serial(candidates[0].device, 9600)
|
|
56
|
+
self.source_id = GLib.unix_fd_add_full(
|
|
57
|
+
GLib.PRIORITY_DEFAULT,
|
|
58
|
+
self.reader.fileno(),
|
|
59
|
+
GLib.IOCondition.IN | GLib.IOCondition.ERR | GLib.IOCondition.NVAL,
|
|
60
|
+
self.get_line,
|
|
61
|
+
self.callback,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def finish_timeout(self):
|
|
66
|
+
"""Finishes the timeout."""
|
|
67
|
+
GLib.source_remove(self.source_id)
|
|
68
|
+
self.source_id = None
|
|
69
|
+
|
|
70
|
+
self.reader.close()
|
|
71
|
+
self.reader = None
|
|
72
|
+
|
|
73
|
+
# re-start the search of the scanner
|
|
74
|
+
self.timer_id = GLib.timeout_add(500, self.find_scanner)
|
|
75
|
+
|
|
76
|
+
def get_line(self, fd, state, callback):
|
|
77
|
+
"""Has to info to read."""
|
|
78
|
+
if state == GLib.IOCondition.IN:
|
|
79
|
+
try:
|
|
80
|
+
available = self.reader.in_waiting
|
|
81
|
+
while True:
|
|
82
|
+
delta = self.reader.in_waiting - available
|
|
83
|
+
if not delta:
|
|
84
|
+
break
|
|
85
|
+
|
|
86
|
+
# Get data from serial device passed in via
|
|
87
|
+
data = self.reader.read_until(expected='\r', size=self.reader.in_waiting).strip()
|
|
88
|
+
txt = data.decode('utf-8')
|
|
89
|
+
if callback:
|
|
90
|
+
callback(txt)
|
|
91
|
+
|
|
92
|
+
except OSError:
|
|
93
|
+
if not pathlib.Path(self.reader.name).exists():
|
|
94
|
+
print("Device unplugged.")
|
|
95
|
+
self.finish_timeout()
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
return True
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
else:
|
|
102
|
+
self.finish_timeout()
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
def get_text_from_scanner(txt):
|
|
106
|
+
"""Callback where the scanners sends the text."""
|
|
107
|
+
print("### {}".format(txt))
|
|
108
|
+
|
|
109
|
+
def test_scanner():
|
|
110
|
+
"""Test the thing."""
|
|
111
|
+
scanner = QRScanner(get_text_from_scanner)
|
|
112
|
+
loop = GLib.MainLoop()
|
|
113
|
+
try:
|
|
114
|
+
loop.run()
|
|
115
|
+
except KeyboardInterrupt:
|
|
116
|
+
loop.quit()
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
test_scanner()
|
|
@@ -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
|
|
|
@@ -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,
|
|
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
|
-
|
|
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.
|
|
3
|
+
Version: 0.19.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|