itkdb-gtk 0.10.9.dev3__tar.gz → 0.10.10__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.10.9.dev3 → itkdb_gtk-0.10.10}/PKG-INFO +1 -1
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/CreateShipments.py +30 -24
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/GetShipments.py +83 -81
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/GlueWeight.py +35 -51
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ITkDBlogin.py +6 -2
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ITkDButils.py +138 -19
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/PanelVisualInspection.py +258 -73
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/PetalReceptionTests.py +20 -11
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/SensorUtils.py +16 -14
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ShowAttachments.py +3 -1
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/UploadModuleIV.py +8 -8
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/UploadMultipleTests.py +174 -109
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/UploadTest.py +17 -14
- itkdb_gtk-0.10.10/itkdb_gtk/VisualInspection.py +299 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/WireBondGui.py +556 -163
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/__init__.py +7 -7
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/dashBoard.py +86 -19
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/dbGtkUtils.py +79 -25
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/PKG-INFO +1 -1
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/SOURCES.txt +4 -2
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/entry_points.txt +1 -1
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/pyproject.toml +2 -2
- itkdb_gtk-0.10.10/test/testBatch.py +126 -0
- itkdb_gtk-0.10.10/test/testRange.py +58 -0
- itkdb_gtk-0.10.10/test/testThread.py +18 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/test/test_attachment.py +3 -3
- itkdb_gtk-0.10.9.dev3/itkdb_gtk/UploadPetalInformation.py +0 -711
- itkdb_gtk-0.10.9.dev3/itkdb_gtk/readAVSdata.py +0 -693
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/README.md +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ITkDB.desktop +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ITkDB.svg +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ShowComments.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/ShowDefects.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/readGoogleSheet.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk/untrash_component.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/requires.txt +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/itkdb_gtk.egg-info/top_level.txt +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/setup.cfg +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/test/testAnimated.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/test/testComponent.py +0 -0
- {itkdb_gtk-0.10.9.dev3 → itkdb_gtk-0.10.10}/test/test_holes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itkdb_gtk
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.10
|
|
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,7 +9,7 @@ import re
|
|
|
9
9
|
|
|
10
10
|
try:
|
|
11
11
|
import itkdb_gtk
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
except ImportError:
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
cwd = Path(__file__).parent.parent
|
|
@@ -19,7 +19,7 @@ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
|
|
|
19
19
|
|
|
20
20
|
import gi
|
|
21
21
|
gi.require_version("Gtk", "3.0")
|
|
22
|
-
from gi.repository import Gtk, Gio
|
|
22
|
+
from gi.repository import Gtk, Gio
|
|
23
23
|
|
|
24
24
|
# Check if Gtk can be open
|
|
25
25
|
gtk_runs, gtk_args = Gtk.init_check()
|
|
@@ -28,7 +28,7 @@ gtk_runs, gtk_args = Gtk.init_check()
|
|
|
28
28
|
class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
29
29
|
"""Create a shipment from input."""
|
|
30
30
|
|
|
31
|
-
def __init__(self, session,
|
|
31
|
+
def __init__(self, session, help_link=None):
|
|
32
32
|
"""Initialization.
|
|
33
33
|
|
|
34
34
|
Args:
|
|
@@ -41,7 +41,8 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
41
41
|
self.attachment = None
|
|
42
42
|
global gtk_runs
|
|
43
43
|
if gtk_runs:
|
|
44
|
-
super().__init__(session=session, title="
|
|
44
|
+
super().__init__(session=session, title="Create Shipment",
|
|
45
|
+
help_link=help_link, gtk_runs=gtk_runs)
|
|
45
46
|
self.init_window()
|
|
46
47
|
|
|
47
48
|
def init_window(self):
|
|
@@ -180,6 +181,9 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
180
181
|
# For the later we get the SN in the argument list.
|
|
181
182
|
if isinstance(args[0], Gtk.Button):
|
|
182
183
|
txt = dbGtkUtils.get_a_value("Enter item SN", is_tv=True)
|
|
184
|
+
if txt is None:
|
|
185
|
+
return
|
|
186
|
+
|
|
183
187
|
tmp = re.split(';|,| |\n|\t', txt)
|
|
184
188
|
SNlist = [s.strip() for s in tmp if len(s.strip())>0]
|
|
185
189
|
else:
|
|
@@ -193,28 +197,28 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
193
197
|
dbGtkUtils.complain("Item {} is already in transit".format(SN),
|
|
194
198
|
"This item is already in transit to {}".format(rc['shipmentDestination']['code']))
|
|
195
199
|
return
|
|
196
|
-
|
|
200
|
+
|
|
197
201
|
nick = rc['alternativeIdentifier']
|
|
198
|
-
|
|
202
|
+
obj_id = rc['id']
|
|
199
203
|
obj = rc['componentType']['name']
|
|
200
204
|
loc = rc['currentLocation']['code']
|
|
201
205
|
serialN = rc['serialNumber']
|
|
202
206
|
if serialN is None:
|
|
203
|
-
serialN =
|
|
207
|
+
serialN = obj_id
|
|
204
208
|
|
|
205
209
|
# Check tha tthe input is not already there
|
|
206
210
|
model = self.tree.get_model()
|
|
207
|
-
|
|
208
|
-
while
|
|
209
|
-
if model.get_value(
|
|
211
|
+
lv_iter = model.get_iter_first()
|
|
212
|
+
while lv_iter:
|
|
213
|
+
if model.get_value(lv_iter, 0) == SN:
|
|
210
214
|
dbGtkUtils.complain("Duplicated item.",
|
|
211
215
|
"Object {} is already in the list".format(SN))
|
|
212
216
|
return
|
|
213
217
|
|
|
214
|
-
|
|
218
|
+
lv_iter = model.iter_next(lv_iter)
|
|
215
219
|
|
|
216
220
|
# Add the item in the liststore.
|
|
217
|
-
model.append([serialN, nick, obj, loc,
|
|
221
|
+
model.append([serialN, nick, obj, loc, obj_id])
|
|
218
222
|
|
|
219
223
|
except Exception:
|
|
220
224
|
dbGtkUtils.complain("Error querying DB",
|
|
@@ -224,12 +228,12 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
224
228
|
def remove_item(self, *args):
|
|
225
229
|
"""Remove selected item."""
|
|
226
230
|
select = self.tree.get_selection()
|
|
227
|
-
model,
|
|
228
|
-
if
|
|
229
|
-
values = model[
|
|
231
|
+
model, lv_iter = select.get_selected()
|
|
232
|
+
if lv_iter:
|
|
233
|
+
values = model[lv_iter]
|
|
230
234
|
rc = dbGtkUtils.ask_for_confirmation("Remove this items ?", values[0])
|
|
231
235
|
if rc:
|
|
232
|
-
model.remove(
|
|
236
|
+
model.remove(lv_iter)
|
|
233
237
|
|
|
234
238
|
def add_attachment_dialog(self):
|
|
235
239
|
"""Create the add attachment dialog."""
|
|
@@ -282,7 +286,7 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
282
286
|
|
|
283
287
|
T = T if len(T) else None
|
|
284
288
|
D = D if len(D) else None
|
|
285
|
-
att = ITkDButils.Attachment(path, T, D)
|
|
289
|
+
att = ITkDButils.Attachment(path=path, title=T, desc=D)
|
|
286
290
|
self.attachment = att
|
|
287
291
|
|
|
288
292
|
dlg.hide()
|
|
@@ -309,16 +313,16 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
309
313
|
def send_items(self, *args):
|
|
310
314
|
"""Send items in liststore."""
|
|
311
315
|
model = self.tree.get_model()
|
|
312
|
-
|
|
316
|
+
lv_iter = model.get_iter_first()
|
|
313
317
|
items = []
|
|
314
318
|
senders = {}
|
|
315
|
-
while
|
|
316
|
-
values = model[
|
|
319
|
+
while lv_iter:
|
|
320
|
+
values = model[lv_iter]
|
|
317
321
|
items.append(values[0])
|
|
318
322
|
senders[values[3]] = senders.setdefault(values[3], 0) + 1
|
|
319
|
-
|
|
323
|
+
lv_iter = model.iter_next(lv_iter)
|
|
320
324
|
|
|
321
|
-
if len(items):
|
|
325
|
+
if len(items)>0:
|
|
322
326
|
if len(senders) != 1:
|
|
323
327
|
dbGtkUtils.complain("Too many senders.",
|
|
324
328
|
"There are objects located in differen sites:{}".format('\n'.join(senders.keys())))
|
|
@@ -345,7 +349,7 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
345
349
|
self.tree.set_model(model)
|
|
346
350
|
self.comments.set_text("")
|
|
347
351
|
self.name.set_text("")
|
|
348
|
-
self.
|
|
352
|
+
self.attachment = None
|
|
349
353
|
|
|
350
354
|
else:
|
|
351
355
|
self.write_message("Empty list of items when creating shipment.")
|
|
@@ -354,6 +358,8 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
354
358
|
def main():
|
|
355
359
|
"""Main entry."""
|
|
356
360
|
# main entry of the program
|
|
361
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch"
|
|
362
|
+
|
|
357
363
|
dlg = ITkDBlogin.ITkDBlogin()
|
|
358
364
|
client = dlg.get_client()
|
|
359
365
|
if client is None:
|
|
@@ -362,7 +368,7 @@ def main():
|
|
|
362
368
|
sys.exit()
|
|
363
369
|
|
|
364
370
|
client.user_gui = dlg
|
|
365
|
-
IS = CreateShipments(client)
|
|
371
|
+
IS = CreateShipments(client, help_link="{}/createShipment.html".format(HELP_LINK))
|
|
366
372
|
IS.set_accept_focus(True)
|
|
367
373
|
IS.present()
|
|
368
374
|
IS.connect("destroy", Gtk.main_quit)
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""GEt shipments to a particular site (default is IFIC)."""
|
|
3
|
-
import pathlib
|
|
4
3
|
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
7
|
import itkdb_gtk
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
except ImportError:
|
|
10
|
-
from pathlib import Path
|
|
11
10
|
cwd = Path(__file__).parent.parent
|
|
12
11
|
sys.path.append(cwd.as_posix())
|
|
13
12
|
|
|
14
13
|
from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
|
|
15
14
|
import gi
|
|
16
|
-
import serial
|
|
17
15
|
|
|
18
16
|
gi.require_version("Gtk", "3.0")
|
|
19
17
|
from gi.repository import Gtk, Gio, GLib
|
|
@@ -40,13 +38,13 @@ def find_vtrx(client, SN):
|
|
|
40
38
|
|
|
41
39
|
if nitem > 1:
|
|
42
40
|
raise ValueError("Too many VTRx with same device SN.")
|
|
43
|
-
|
|
44
|
-
return vtrx
|
|
41
|
+
|
|
42
|
+
return vtrx
|
|
45
43
|
|
|
46
44
|
class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
47
45
|
"""Find shipments related to given recipient."""
|
|
48
46
|
|
|
49
|
-
def __init__(self, session, recipient=
|
|
47
|
+
def __init__(self, session, recipient=None, help_link=None):
|
|
50
48
|
"""Initialization.
|
|
51
49
|
|
|
52
50
|
Args:
|
|
@@ -54,20 +52,24 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
54
52
|
recipient: default recipient
|
|
55
53
|
|
|
56
54
|
"""
|
|
57
|
-
self.recipient = recipient
|
|
58
55
|
self.state = "inTransit"
|
|
59
56
|
self.institute = None
|
|
60
57
|
self.model = None
|
|
61
58
|
self.store = None
|
|
59
|
+
self.tree = None
|
|
62
60
|
self.shipments = {}
|
|
63
61
|
|
|
64
62
|
global gtk_runs
|
|
65
63
|
if gtk_runs:
|
|
66
|
-
super().__init__(session=session, title="
|
|
64
|
+
super().__init__(session=session, title="Receive Shipments",
|
|
67
65
|
show_search="Click to search shipments",
|
|
68
|
-
gtk_runs=gtk_runs,
|
|
66
|
+
gtk_runs=gtk_runs, help_link=help_link)
|
|
69
67
|
|
|
68
|
+
self.recipient = self.pdb_user["institutions"][0]["code"]
|
|
70
69
|
self.init_window()
|
|
70
|
+
else:
|
|
71
|
+
pdb_user = ITkDButils.get_db_user(session)
|
|
72
|
+
self.recipient = pdb_user["institutions"][0]["code"]
|
|
71
73
|
|
|
72
74
|
def init_window(self):
|
|
73
75
|
"""Initialize window."""
|
|
@@ -94,7 +96,7 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
94
96
|
self.mainBox.pack_start(grid, False, True, 0)
|
|
95
97
|
|
|
96
98
|
# The shipment receiver
|
|
97
|
-
receiver = self.create_institute_combo()
|
|
99
|
+
receiver = self.create_institute_combo(only_user=True)
|
|
98
100
|
receiver.connect("changed", self.on_receiver)
|
|
99
101
|
receiver.set_tooltip_text("Select the Institute receiving the items.")
|
|
100
102
|
dbGtkUtils.set_combo_iter(receiver, self.recipient)
|
|
@@ -134,6 +136,12 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
134
136
|
btn.connect("clicked", self.receive_items)
|
|
135
137
|
grid.attach(btn, 2, 3, 1, 1)
|
|
136
138
|
|
|
139
|
+
self.check_all = Gtk.ToggleButton(label="Check A_ll", use_underline=True)
|
|
140
|
+
self.check_all.set_active(1)
|
|
141
|
+
self.check_all.set_tooltip_text("If toggled, items will need to be `received`\none by one by unchecking the check box.")
|
|
142
|
+
grid.attach(self.check_all, 3, 3, 1, 1)
|
|
143
|
+
|
|
144
|
+
|
|
137
145
|
# Add a Separator
|
|
138
146
|
self.mainBox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, True, 0)
|
|
139
147
|
|
|
@@ -184,36 +192,21 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
184
192
|
try:
|
|
185
193
|
txt = find_vtrx(self.session, txt)
|
|
186
194
|
except ValueError as e:
|
|
187
|
-
self.write_message("Error: {}".format(e))
|
|
195
|
+
self.write_message("Error: {}\n".format(e))
|
|
188
196
|
return
|
|
189
197
|
|
|
190
198
|
# search code in the list
|
|
191
199
|
if self.store:
|
|
192
|
-
|
|
193
|
-
while
|
|
194
|
-
if
|
|
200
|
+
lv_iter = self.store.get_iter_first()
|
|
201
|
+
while lv_iter:
|
|
202
|
+
if self.store.get_value(lv_iter, 0) == txt:
|
|
195
203
|
self.write_message("...found\n")
|
|
196
|
-
self.store[
|
|
204
|
+
self.store[lv_iter][3] = False
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
lv_iter = self.store.iter_next(lv_iter)
|
|
199
207
|
|
|
200
208
|
return True
|
|
201
209
|
|
|
202
|
-
def get_institute_list(self):
|
|
203
|
-
"""Get the institute list."""
|
|
204
|
-
sites = self.session.get("listInstitutions", json={})
|
|
205
|
-
liststore = Gtk.ListStore(str, str)
|
|
206
|
-
for site in sites:
|
|
207
|
-
self.code2inst[site['code']] = site['name']
|
|
208
|
-
self.inst2code[site['name']] = site['code']
|
|
209
|
-
liststore.append([site["code"], site["code"]])
|
|
210
|
-
liststore.append([site["name"], site["code"]])
|
|
211
|
-
|
|
212
|
-
completion = Gtk.EntryCompletion()
|
|
213
|
-
completion.set_model(liststore)
|
|
214
|
-
completion.set_text_column(0)
|
|
215
|
-
return completion
|
|
216
|
-
|
|
217
210
|
def on_cell_toggled(self, widget, path):
|
|
218
211
|
"""A cell has been toggled."""
|
|
219
212
|
model = self.tree.get_model()
|
|
@@ -234,9 +227,9 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
234
227
|
|
|
235
228
|
# Store the model associated to this shipment.
|
|
236
229
|
self.store = self.shipments[shpmnt]
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
self.tree.set_model(
|
|
230
|
+
sfilter = self.store.filter_new()
|
|
231
|
+
sfilter.set_visible_column(3)
|
|
232
|
+
self.tree.set_model(sfilter)
|
|
240
233
|
|
|
241
234
|
def on_status_changed(self, combo):
|
|
242
235
|
"""Status changed."""
|
|
@@ -250,30 +243,12 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
250
243
|
|
|
251
244
|
self.state = name
|
|
252
245
|
|
|
253
|
-
def get_institute_from_combo(self, combo):
|
|
254
|
-
"""Get Institute from combo."""
|
|
255
|
-
tree_iter = combo.get_active_iter()
|
|
256
|
-
if tree_iter is not None:
|
|
257
|
-
model = combo.get_model()
|
|
258
|
-
name = model[tree_iter][1]
|
|
259
|
-
|
|
260
|
-
else:
|
|
261
|
-
name = combo.get_child().get_text()
|
|
262
|
-
if name in self.inst2code:
|
|
263
|
-
name = self.inst2code[name]
|
|
264
|
-
|
|
265
|
-
elif name not in self.code2inst:
|
|
266
|
-
name = None
|
|
267
|
-
|
|
268
|
-
return name
|
|
269
|
-
|
|
270
246
|
def on_receiver(self, combo):
|
|
271
247
|
"""Sets the recipient."""
|
|
272
248
|
name = self.get_institute_from_combo(combo)
|
|
273
249
|
if name:
|
|
274
250
|
self.recipient = name
|
|
275
|
-
|
|
276
|
-
hb.props.title = "{} shipments".format(self.recipient)
|
|
251
|
+
self.set_window_title("{} shipments".format(self.recipient))
|
|
277
252
|
|
|
278
253
|
def on_institute(self, combo):
|
|
279
254
|
"""New institute chosen."""
|
|
@@ -287,12 +262,14 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
287
262
|
|
|
288
263
|
def query_db(self, *args):
|
|
289
264
|
"""Query for shipments in DB."""
|
|
290
|
-
if self.
|
|
265
|
+
if self.state == "":
|
|
291
266
|
return
|
|
292
267
|
|
|
293
268
|
payload = {
|
|
294
|
-
"
|
|
295
|
-
|
|
269
|
+
"filterMap": {
|
|
270
|
+
"code": self.recipient,
|
|
271
|
+
"status": self.state
|
|
272
|
+
}
|
|
296
273
|
}
|
|
297
274
|
shpmts = self.session.get("listShipmentsByInstitution", json=payload)
|
|
298
275
|
|
|
@@ -301,7 +278,11 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
301
278
|
# the tree view.
|
|
302
279
|
cmb_store = Gtk.ListStore(str, str)
|
|
303
280
|
for s in shpmts:
|
|
304
|
-
|
|
281
|
+
valid_sender = True
|
|
282
|
+
if self.institute is not None:
|
|
283
|
+
valid_sender = s['sender']['code'] == self.institute
|
|
284
|
+
|
|
285
|
+
if s["recipient"]["code"] == self.recipient and valid_sender:
|
|
305
286
|
store = self.get_tree_view_model()
|
|
306
287
|
cmb_store.append([s['name'], s['id']])
|
|
307
288
|
items = self.session.get("listShipmentItems", json={"shipment": s["id"]})
|
|
@@ -319,35 +300,54 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
319
300
|
self.write_message("Could not find any shipment in DB.\n")
|
|
320
301
|
|
|
321
302
|
self.cmb_shipment.set_model(cmb_store)
|
|
322
|
-
|
|
323
|
-
|
|
303
|
+
if len(cmb_store)>0:
|
|
304
|
+
self.cmb_shipment.set_entry_text_column(0)
|
|
305
|
+
self.cmb_shipment.set_active(0)
|
|
306
|
+
else:
|
|
307
|
+
self.cmb_shipment.set_active(-1)
|
|
308
|
+
self.cmb_shipment.get_child().set_text("")
|
|
309
|
+
self.tree.set_model(Gtk.ListStore(str, str, str, bool))
|
|
310
|
+
|
|
311
|
+
def mark_all_as_delivered(self):
|
|
312
|
+
"""Mark all items in current shipment as delivered."""
|
|
313
|
+
if self.store is None:
|
|
314
|
+
return
|
|
315
|
+
|
|
316
|
+
lv_iter = self.store.get_iter_first()
|
|
317
|
+
while lv_iter:
|
|
318
|
+
val = self.store[lv_iter][3]
|
|
319
|
+
self.store[lv_iter][3] = not val
|
|
320
|
+
lv_iter = self.store.iter_next(lv_iter)
|
|
324
321
|
|
|
325
322
|
def receive_items(self, *args):
|
|
326
323
|
"""Receive shipment items."""
|
|
327
324
|
data = {}
|
|
328
325
|
names = {}
|
|
326
|
+
if not self.store:
|
|
327
|
+
self.write_message("Empty list of items.\n")
|
|
328
|
+
return
|
|
329
|
+
|
|
330
|
+
if not self.check_all.get_active():
|
|
331
|
+
self.mark_all_as_delivered()
|
|
329
332
|
|
|
330
333
|
# self.store is the model of the tree view
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
names[shpmnt] = self.store.get_value(iter, 4)
|
|
334
|
+
lv_iter = self.store.get_iter_first()
|
|
335
|
+
while lv_iter:
|
|
336
|
+
shpmnt = self.store.get_value(lv_iter, 2)
|
|
337
|
+
if shpmnt not in data:
|
|
338
|
+
data[shpmnt] = create_shipment_status(shpmnt)
|
|
339
|
+
names[shpmnt] = self.store.get_value(lv_iter, 4)
|
|
338
340
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
item = {
|
|
342
|
+
"code": self.store[lv_iter][5],
|
|
343
|
+
"delivered": not self.store[lv_iter][3]
|
|
344
|
+
}
|
|
345
|
+
data[shpmnt]["shipmentItems"].append(item)
|
|
344
346
|
|
|
345
|
-
|
|
347
|
+
lv_iter = self.store.iter_next(lv_iter)
|
|
346
348
|
|
|
347
|
-
else:
|
|
348
|
-
self.write_message("Empty list of items.\n")
|
|
349
349
|
|
|
350
|
-
for
|
|
350
|
+
for oid, S in data.items():
|
|
351
351
|
# Check that all items are there
|
|
352
352
|
nlost = 0
|
|
353
353
|
for item in S["shipmentItems"]:
|
|
@@ -366,7 +366,7 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
366
366
|
return
|
|
367
367
|
|
|
368
368
|
# Open dialog to fill-in questions
|
|
369
|
-
create_check_list(S["checklist"]["questionList"], names[
|
|
369
|
+
create_check_list(S["checklist"]["questionList"], names[oid])
|
|
370
370
|
|
|
371
371
|
# send the update to the DB
|
|
372
372
|
S['status'] = "delivered"
|
|
@@ -382,10 +382,10 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
382
382
|
self.write_message("Could not update the shipment status.\n{}\n".foramt(rc))
|
|
383
383
|
|
|
384
384
|
else:
|
|
385
|
-
self.write_message("Shipment {} received\n".format(names[
|
|
385
|
+
self.write_message("Shipment {} received\n".format(names[oid]))
|
|
386
386
|
# Now remove the current shipment
|
|
387
|
-
|
|
388
|
-
self.cmb_shipment.get_model().remove(
|
|
387
|
+
lv_iter = self.cmb_shipment.get_active_iter()
|
|
388
|
+
self.cmb_shipment.get_model().remove(lv_iter)
|
|
389
389
|
self.cmb_shipment.set_active(0)
|
|
390
390
|
|
|
391
391
|
|
|
@@ -525,6 +525,8 @@ def create_shipment_status(shpmnt):
|
|
|
525
525
|
|
|
526
526
|
def main():
|
|
527
527
|
"""Main entry."""
|
|
528
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch/receiveShipments.html"
|
|
529
|
+
|
|
528
530
|
dlg = ITkDBlogin.ITkDBlogin()
|
|
529
531
|
client = dlg.get_client()
|
|
530
532
|
if client is None:
|
|
@@ -533,7 +535,7 @@ def main():
|
|
|
533
535
|
sys.exit()
|
|
534
536
|
|
|
535
537
|
client.user_gui = dlg
|
|
536
|
-
IS = ReceiveShipments(client)
|
|
538
|
+
IS = ReceiveShipments(client, help_link=HELP_LINK)
|
|
537
539
|
IS.set_accept_focus(True)
|
|
538
540
|
IS.present()
|
|
539
541
|
IS.connect("destroy", Gtk.main_quit)
|
|
@@ -8,13 +8,14 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
try:
|
|
10
10
|
import itkdb_gtk
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
except ImportError:
|
|
13
|
-
from pathlib import Path
|
|
14
13
|
cwd = Path(__file__).parent.parent
|
|
15
14
|
sys.path.append(cwd.as_posix())
|
|
16
15
|
|
|
17
|
-
from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
|
|
16
|
+
from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils, UploadMultipleTests
|
|
17
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch"
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
import gi
|
|
20
21
|
gi.require_version("Gtk", "3.0")
|
|
@@ -83,18 +84,17 @@ def remove_defaul_keys(data, default_value=-9999):
|
|
|
83
84
|
return data
|
|
84
85
|
|
|
85
86
|
|
|
86
|
-
class GlueWeight(
|
|
87
|
+
class GlueWeight(dbGtkUtils.ITkDBWindow):
|
|
87
88
|
"""Upluead Glue Weight test."""
|
|
88
89
|
|
|
89
|
-
def __init__(self, session, ifile=None,
|
|
90
|
+
def __init__(self, session, ifile=None, help_link=None):
|
|
90
91
|
"""Initialization.
|
|
91
|
-
|
|
92
|
+
|
|
92
93
|
Args:
|
|
93
94
|
session: ITkDB session_
|
|
94
95
|
ifile (optional): Input file. Defaults to None.
|
|
95
96
|
|
|
96
97
|
"""
|
|
97
|
-
global gtk_runs
|
|
98
98
|
self.ifile = ifile
|
|
99
99
|
self.session = session
|
|
100
100
|
self.modules = []
|
|
@@ -112,34 +112,24 @@ class GlueWeight(Gtk.Window):
|
|
|
112
112
|
self.skeleton = ITkDButils.get_test_skeleton(
|
|
113
113
|
session, "MODULE", "GLUE_WEIGHT", defaults)
|
|
114
114
|
|
|
115
|
+
global gtk_runs
|
|
115
116
|
if gtk_runs:
|
|
116
|
-
super().__init__(
|
|
117
|
+
super().__init__(session=session,
|
|
118
|
+
title="Upload Glue Weight",
|
|
119
|
+
help_link=help_link)
|
|
117
120
|
self.init_window()
|
|
121
|
+
else:
|
|
122
|
+
self.pdb_user = ITkDButils.get_db_user(session)
|
|
118
123
|
|
|
119
124
|
def init_window(self):
|
|
120
125
|
"""Initialize window."""
|
|
121
126
|
#
|
|
122
127
|
# Prepare HeaderBar
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
self.
|
|
127
|
-
|
|
128
|
-
button = Gtk.Button()
|
|
129
|
-
icon = Gio.ThemedIcon(name="document-send-symbolic")
|
|
130
|
-
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
|
131
|
-
button.add(image)
|
|
132
|
-
button.set_tooltip_text("Click to upload test shown in notebook.")
|
|
133
|
-
button.connect("clicked", self.upload_current_test)
|
|
134
|
-
hb.pack_end(button)
|
|
135
|
-
|
|
136
|
-
self.userLabel = Gtk.Label()
|
|
137
|
-
self.userLabel.set_text(self.session.user.name)
|
|
138
|
-
hb.pack_start(self.userLabel)
|
|
139
|
-
|
|
140
|
-
# Create main content box
|
|
141
|
-
self.mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
|
142
|
-
self.add(self.mainBox)
|
|
128
|
+
self.set_border_width(10)
|
|
129
|
+
|
|
130
|
+
# Prepare HeaderBar
|
|
131
|
+
self.hb.props.title = "Glue height"
|
|
132
|
+
|
|
143
133
|
# file entry and search button
|
|
144
134
|
self.file_name = Gtk.FileChooserButton()
|
|
145
135
|
self.file_name.connect("file-set", self.on_file_set)
|
|
@@ -167,6 +157,11 @@ class GlueWeight(Gtk.Window):
|
|
|
167
157
|
self.modules = self.parse_file(self.ifile)
|
|
168
158
|
self.populate_notebook()
|
|
169
159
|
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# The text view
|
|
163
|
+
self.mainBox.pack_end(self.message_panel.frame, True, True, 5)
|
|
164
|
+
|
|
170
165
|
# The button box
|
|
171
166
|
btnBox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
|
|
172
167
|
self.buttons = []
|
|
@@ -183,19 +178,10 @@ class GlueWeight(Gtk.Window):
|
|
|
183
178
|
self.buttons.append(btn)
|
|
184
179
|
btnBox.add(btn)
|
|
185
180
|
|
|
186
|
-
btn = Gtk.Button(label="Quit")
|
|
187
|
-
btn.connect("clicked", self.quit)
|
|
188
|
-
btnBox.add(btn)
|
|
189
|
-
|
|
190
181
|
self.mainBox.pack_start(btnBox, False, True, 0)
|
|
191
182
|
|
|
192
183
|
self.show_all()
|
|
193
184
|
|
|
194
|
-
def quit(self, *args):
|
|
195
|
-
"""Quits the application."""
|
|
196
|
-
self.hide()
|
|
197
|
-
self.destroy()
|
|
198
|
-
|
|
199
185
|
def create_test_window(self, test_json, test_name, label):
|
|
200
186
|
"""Create the dialog for a DB test and add it to the notebook.
|
|
201
187
|
|
|
@@ -257,7 +243,7 @@ class GlueWeight(Gtk.Window):
|
|
|
257
243
|
|
|
258
244
|
def read_file(self, path):
|
|
259
245
|
"""Parse file."""
|
|
260
|
-
with open(path, "r") as ifile:
|
|
246
|
+
with open(path, "r", encoding="UTF-8") as ifile:
|
|
261
247
|
self.modules = self.parse_file(ifile)
|
|
262
248
|
|
|
263
249
|
def parse_file(self, ifile, module_sep="MODULE_SN"):
|
|
@@ -346,22 +332,20 @@ class GlueWeight(Gtk.Window):
|
|
|
346
332
|
|
|
347
333
|
def upload_tests(self):
|
|
348
334
|
"""Upload tests to DB."""
|
|
349
|
-
|
|
335
|
+
W = UploadMultipleTests.UploadMultipleTests(
|
|
336
|
+
self.session,
|
|
337
|
+
help_link="{}/uploadMultipleTests.html".format(HELP_LINK)
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
if len(self.test_list)>0:
|
|
350
341
|
for G in self.test_list:
|
|
351
342
|
m = G.values
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if resp is not None:
|
|
356
|
-
print(resp)
|
|
343
|
+
W.add_test_data_to_view(m)
|
|
344
|
+
|
|
357
345
|
|
|
358
346
|
else:
|
|
359
347
|
for m in self.modules:
|
|
360
|
-
|
|
361
|
-
resp = ITkDButils.upload_test(self.session, m)
|
|
362
|
-
|
|
363
|
-
if resp is not None:
|
|
364
|
-
print(resp)
|
|
348
|
+
W.add_test_data_to_view(m)
|
|
365
349
|
|
|
366
350
|
|
|
367
351
|
def main():
|
|
@@ -386,7 +370,7 @@ def main():
|
|
|
386
370
|
|
|
387
371
|
else:
|
|
388
372
|
try:
|
|
389
|
-
ifile = open(options.files[0], 'r')
|
|
373
|
+
ifile = open(options.files[0], 'r') if len(options.files)>0 else None
|
|
390
374
|
|
|
391
375
|
except Exception as e:
|
|
392
376
|
print(e)
|
|
@@ -399,7 +383,7 @@ def main():
|
|
|
399
383
|
print("Could not connect to DB with provided credentials.")
|
|
400
384
|
sys.exit()
|
|
401
385
|
|
|
402
|
-
GW = GlueWeight(session, ifile)
|
|
386
|
+
GW = GlueWeight(session, ifile, help_link=HELP_LINK)
|
|
403
387
|
if gtk_runs:
|
|
404
388
|
GW.show_all()
|
|
405
389
|
GW.set_accept_focus(True)
|
|
@@ -239,10 +239,10 @@ class ITkDBlogin(Gtk.Dialog):
|
|
|
239
239
|
self.ac1.set_visibility(False)
|
|
240
240
|
self.ac2.set_visibility(False)
|
|
241
241
|
|
|
242
|
-
grid.attach(Gtk.Label(label="
|
|
242
|
+
grid.attach(Gtk.Label(label="Access Code 1"), 0, irow, 1, 1)
|
|
243
243
|
grid.attach(self.ac1, 1, irow, 1, 1)
|
|
244
244
|
irow = irow + 1
|
|
245
|
-
grid.attach(Gtk.Label(label="
|
|
245
|
+
grid.attach(Gtk.Label(label="Access Code 2"), 0, irow, 1, 1)
|
|
246
246
|
grid.attach(self.ac2, 1, irow, 1, 1)
|
|
247
247
|
|
|
248
248
|
btn = self.get_widget_for_response(Gtk.ResponseType.OK)
|
|
@@ -336,6 +336,10 @@ if __name__ == "__main__":
|
|
|
336
336
|
# print(l)
|
|
337
337
|
|
|
338
338
|
print("Hello {}".format(dlg.name))
|
|
339
|
+
|
|
340
|
+
rc = client.get("getUser", json={"userIdentity": dlg.user.identity})
|
|
341
|
+
print(rc)
|
|
342
|
+
|
|
339
343
|
if gtk_runs:
|
|
340
344
|
try:
|
|
341
345
|
while True:
|