itkdb-gtk 0.10.9.dev4__py3-none-any.whl → 0.10.10__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 +9 -4
- itkdb_gtk/GetShipments.py +65 -62
- itkdb_gtk/GlueWeight.py +34 -50
- itkdb_gtk/ITkDBlogin.py +6 -2
- itkdb_gtk/ITkDButils.py +44 -22
- itkdb_gtk/PanelVisualInspection.py +16 -11
- itkdb_gtk/PetalReceptionTests.py +16 -7
- itkdb_gtk/UploadMultipleTests.py +125 -63
- itkdb_gtk/UploadTest.py +10 -7
- itkdb_gtk/VisualInspection.py +299 -0
- itkdb_gtk/WireBondGui.py +482 -138
- itkdb_gtk/__init__.py +6 -6
- itkdb_gtk/dashBoard.py +81 -15
- itkdb_gtk/dbGtkUtils.py +60 -17
- {itkdb_gtk-0.10.9.dev4.dist-info → itkdb_gtk-0.10.10.dist-info}/METADATA +1 -1
- itkdb_gtk-0.10.10.dist-info/RECORD +28 -0
- {itkdb_gtk-0.10.9.dev4.dist-info → itkdb_gtk-0.10.10.dist-info}/WHEEL +1 -1
- {itkdb_gtk-0.10.9.dev4.dist-info → itkdb_gtk-0.10.10.dist-info}/entry_points.txt +1 -1
- itkdb_gtk/UploadPetalInformation.py +0 -710
- itkdb_gtk/readAVSdata.py +0 -693
- itkdb_gtk-0.10.9.dev4.dist-info/RECORD +0 -29
- {itkdb_gtk-0.10.9.dev4.dist-info → itkdb_gtk-0.10.10.dist-info}/top_level.txt +0 -0
itkdb_gtk/CreateShipments.py
CHANGED
|
@@ -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()
|
|
@@ -41,7 +41,7 @@ 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
45
|
help_link=help_link, gtk_runs=gtk_runs)
|
|
46
46
|
self.init_window()
|
|
47
47
|
|
|
@@ -181,6 +181,9 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
181
181
|
# For the later we get the SN in the argument list.
|
|
182
182
|
if isinstance(args[0], Gtk.Button):
|
|
183
183
|
txt = dbGtkUtils.get_a_value("Enter item SN", is_tv=True)
|
|
184
|
+
if txt is None:
|
|
185
|
+
return
|
|
186
|
+
|
|
184
187
|
tmp = re.split(';|,| |\n|\t', txt)
|
|
185
188
|
SNlist = [s.strip() for s in tmp if len(s.strip())>0]
|
|
186
189
|
else:
|
|
@@ -346,7 +349,7 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
346
349
|
self.tree.set_model(model)
|
|
347
350
|
self.comments.set_text("")
|
|
348
351
|
self.name.set_text("")
|
|
349
|
-
self.
|
|
352
|
+
self.attachment = None
|
|
350
353
|
|
|
351
354
|
else:
|
|
352
355
|
self.write_message("Empty list of items when creating shipment.")
|
|
@@ -355,6 +358,8 @@ class CreateShipments(dbGtkUtils.ITkDBWindow):
|
|
|
355
358
|
def main():
|
|
356
359
|
"""Main entry."""
|
|
357
360
|
# main entry of the program
|
|
361
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch"
|
|
362
|
+
|
|
358
363
|
dlg = ITkDBlogin.ITkDBlogin()
|
|
359
364
|
client = dlg.get_client()
|
|
360
365
|
if client is None:
|
|
@@ -363,7 +368,7 @@ def main():
|
|
|
363
368
|
sys.exit()
|
|
364
369
|
|
|
365
370
|
client.user_gui = dlg
|
|
366
|
-
IS = CreateShipments(client)
|
|
371
|
+
IS = CreateShipments(client, help_link="{}/createShipment.html".format(HELP_LINK))
|
|
367
372
|
IS.set_accept_focus(True)
|
|
368
373
|
IS.present()
|
|
369
374
|
IS.connect("destroy", Gtk.main_quit)
|
itkdb_gtk/GetShipments.py
CHANGED
|
@@ -44,7 +44,7 @@ def find_vtrx(client, SN):
|
|
|
44
44
|
class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
45
45
|
"""Find shipments related to given recipient."""
|
|
46
46
|
|
|
47
|
-
def __init__(self, session, recipient=
|
|
47
|
+
def __init__(self, session, recipient=None, help_link=None):
|
|
48
48
|
"""Initialization.
|
|
49
49
|
|
|
50
50
|
Args:
|
|
@@ -52,7 +52,6 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
52
52
|
recipient: default recipient
|
|
53
53
|
|
|
54
54
|
"""
|
|
55
|
-
self.recipient = recipient
|
|
56
55
|
self.state = "inTransit"
|
|
57
56
|
self.institute = None
|
|
58
57
|
self.model = None
|
|
@@ -62,11 +61,15 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
62
61
|
|
|
63
62
|
global gtk_runs
|
|
64
63
|
if gtk_runs:
|
|
65
|
-
super().__init__(session=session, title="
|
|
64
|
+
super().__init__(session=session, title="Receive Shipments",
|
|
66
65
|
show_search="Click to search shipments",
|
|
67
66
|
gtk_runs=gtk_runs, help_link=help_link)
|
|
68
67
|
|
|
68
|
+
self.recipient = self.pdb_user["institutions"][0]["code"]
|
|
69
69
|
self.init_window()
|
|
70
|
+
else:
|
|
71
|
+
pdb_user = ITkDButils.get_db_user(session)
|
|
72
|
+
self.recipient = pdb_user["institutions"][0]["code"]
|
|
70
73
|
|
|
71
74
|
def init_window(self):
|
|
72
75
|
"""Initialize window."""
|
|
@@ -93,7 +96,7 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
93
96
|
self.mainBox.pack_start(grid, False, True, 0)
|
|
94
97
|
|
|
95
98
|
# The shipment receiver
|
|
96
|
-
receiver = self.create_institute_combo()
|
|
99
|
+
receiver = self.create_institute_combo(only_user=True)
|
|
97
100
|
receiver.connect("changed", self.on_receiver)
|
|
98
101
|
receiver.set_tooltip_text("Select the Institute receiving the items.")
|
|
99
102
|
dbGtkUtils.set_combo_iter(receiver, self.recipient)
|
|
@@ -133,6 +136,12 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
133
136
|
btn.connect("clicked", self.receive_items)
|
|
134
137
|
grid.attach(btn, 2, 3, 1, 1)
|
|
135
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
|
+
|
|
136
145
|
# Add a Separator
|
|
137
146
|
self.mainBox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, True, 0)
|
|
138
147
|
|
|
@@ -183,14 +192,14 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
183
192
|
try:
|
|
184
193
|
txt = find_vtrx(self.session, txt)
|
|
185
194
|
except ValueError as e:
|
|
186
|
-
self.write_message("Error: {}".format(e))
|
|
195
|
+
self.write_message("Error: {}\n".format(e))
|
|
187
196
|
return
|
|
188
197
|
|
|
189
198
|
# search code in the list
|
|
190
199
|
if self.store:
|
|
191
200
|
lv_iter = self.store.get_iter_first()
|
|
192
201
|
while lv_iter:
|
|
193
|
-
if
|
|
202
|
+
if self.store.get_value(lv_iter, 0) == txt:
|
|
194
203
|
self.write_message("...found\n")
|
|
195
204
|
self.store[lv_iter][3] = False
|
|
196
205
|
|
|
@@ -198,21 +207,6 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
198
207
|
|
|
199
208
|
return True
|
|
200
209
|
|
|
201
|
-
def get_institute_list(self):
|
|
202
|
-
"""Get the institute list."""
|
|
203
|
-
sites = self.session.get("listInstitutions", json={})
|
|
204
|
-
liststore = Gtk.ListStore(str, str)
|
|
205
|
-
for site in sites:
|
|
206
|
-
self.code2inst[site['code']] = site['name']
|
|
207
|
-
self.inst2code[site['name']] = site['code']
|
|
208
|
-
liststore.append([site["code"], site["code"]])
|
|
209
|
-
liststore.append([site["name"], site["code"]])
|
|
210
|
-
|
|
211
|
-
completion = Gtk.EntryCompletion()
|
|
212
|
-
completion.set_model(liststore)
|
|
213
|
-
completion.set_text_column(0)
|
|
214
|
-
return completion
|
|
215
|
-
|
|
216
210
|
def on_cell_toggled(self, widget, path):
|
|
217
211
|
"""A cell has been toggled."""
|
|
218
212
|
model = self.tree.get_model()
|
|
@@ -249,30 +243,12 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
249
243
|
|
|
250
244
|
self.state = name
|
|
251
245
|
|
|
252
|
-
def get_institute_from_combo(self, combo):
|
|
253
|
-
"""Get Institute from combo."""
|
|
254
|
-
tree_iter = combo.get_active_iter()
|
|
255
|
-
if tree_iter is not None:
|
|
256
|
-
model = combo.get_model()
|
|
257
|
-
name = model[tree_iter][1]
|
|
258
|
-
|
|
259
|
-
else:
|
|
260
|
-
name = combo.get_child().get_text()
|
|
261
|
-
if name in self.inst2code:
|
|
262
|
-
name = self.inst2code[name]
|
|
263
|
-
|
|
264
|
-
elif name not in self.code2inst:
|
|
265
|
-
name = None
|
|
266
|
-
|
|
267
|
-
return name
|
|
268
|
-
|
|
269
246
|
def on_receiver(self, combo):
|
|
270
247
|
"""Sets the recipient."""
|
|
271
248
|
name = self.get_institute_from_combo(combo)
|
|
272
249
|
if name:
|
|
273
250
|
self.recipient = name
|
|
274
|
-
|
|
275
|
-
hb.props.title = "{} shipments".format(self.recipient)
|
|
251
|
+
self.set_window_title("{} shipments".format(self.recipient))
|
|
276
252
|
|
|
277
253
|
def on_institute(self, combo):
|
|
278
254
|
"""New institute chosen."""
|
|
@@ -286,12 +262,14 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
286
262
|
|
|
287
263
|
def query_db(self, *args):
|
|
288
264
|
"""Query for shipments in DB."""
|
|
289
|
-
if self.
|
|
265
|
+
if self.state == "":
|
|
290
266
|
return
|
|
291
267
|
|
|
292
268
|
payload = {
|
|
293
|
-
"
|
|
294
|
-
|
|
269
|
+
"filterMap": {
|
|
270
|
+
"code": self.recipient,
|
|
271
|
+
"status": self.state
|
|
272
|
+
}
|
|
295
273
|
}
|
|
296
274
|
shpmts = self.session.get("listShipmentsByInstitution", json=payload)
|
|
297
275
|
|
|
@@ -300,7 +278,11 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
300
278
|
# the tree view.
|
|
301
279
|
cmb_store = Gtk.ListStore(str, str)
|
|
302
280
|
for s in shpmts:
|
|
303
|
-
|
|
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:
|
|
304
286
|
store = self.get_tree_view_model()
|
|
305
287
|
cmb_store.append([s['name'], s['id']])
|
|
306
288
|
items = self.session.get("listShipmentItems", json={"shipment": s["id"]})
|
|
@@ -318,33 +300,52 @@ class ReceiveShipments(dbGtkUtils.ITkDBWindow):
|
|
|
318
300
|
self.write_message("Could not find any shipment in DB.\n")
|
|
319
301
|
|
|
320
302
|
self.cmb_shipment.set_model(cmb_store)
|
|
321
|
-
|
|
322
|
-
|
|
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)
|
|
323
321
|
|
|
324
322
|
def receive_items(self, *args):
|
|
325
323
|
"""Receive shipment items."""
|
|
326
324
|
data = {}
|
|
327
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()
|
|
328
332
|
|
|
329
333
|
# self.store is the model of the tree view
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
names[shpmnt] = self.store.get_value(lv_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)
|
|
337
340
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
item = {
|
|
342
|
+
"code": self.store[lv_iter][5],
|
|
343
|
+
"delivered": not self.store[lv_iter][3]
|
|
344
|
+
}
|
|
345
|
+
data[shpmnt]["shipmentItems"].append(item)
|
|
343
346
|
|
|
344
|
-
|
|
347
|
+
lv_iter = self.store.iter_next(lv_iter)
|
|
345
348
|
|
|
346
|
-
else:
|
|
347
|
-
self.write_message("Empty list of items.\n")
|
|
348
349
|
|
|
349
350
|
for oid, S in data.items():
|
|
350
351
|
# Check that all items are there
|
|
@@ -524,6 +525,8 @@ def create_shipment_status(shpmnt):
|
|
|
524
525
|
|
|
525
526
|
def main():
|
|
526
527
|
"""Main entry."""
|
|
528
|
+
HELP_LINK="https://itkdb-gtk.docs.cern.ch/receiveShipments.html"
|
|
529
|
+
|
|
527
530
|
dlg = ITkDBlogin.ITkDBlogin()
|
|
528
531
|
client = dlg.get_client()
|
|
529
532
|
if client is None:
|
|
@@ -532,7 +535,7 @@ def main():
|
|
|
532
535
|
sys.exit()
|
|
533
536
|
|
|
534
537
|
client.user_gui = dlg
|
|
535
|
-
IS = ReceiveShipments(client)
|
|
538
|
+
IS = ReceiveShipments(client, help_link=HELP_LINK)
|
|
536
539
|
IS.set_accept_focus(True)
|
|
537
540
|
IS.present()
|
|
538
541
|
IS.connect("destroy", Gtk.main_quit)
|
itkdb_gtk/GlueWeight.py
CHANGED
|
@@ -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
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)
|
itkdb_gtk/ITkDBlogin.py
CHANGED
|
@@ -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:
|
itkdb_gtk/ITkDButils.py
CHANGED
|
@@ -56,7 +56,6 @@ def get_db_response():
|
|
|
56
56
|
It is stores in a global variable. Trust the function if call
|
|
57
57
|
right after your interaction with the DB.
|
|
58
58
|
"""
|
|
59
|
-
global db_response
|
|
60
59
|
return db_response
|
|
61
60
|
|
|
62
61
|
|
|
@@ -84,7 +83,8 @@ def get_db_date(timestamp=None):
|
|
|
84
83
|
try:
|
|
85
84
|
this_date = dateutil.parser.parse(timestamp)
|
|
86
85
|
out = date2string(this_date)
|
|
87
|
-
|
|
86
|
+
|
|
87
|
+
except (OverflowError, dateutil.parser.ParserError):
|
|
88
88
|
out = ""
|
|
89
89
|
|
|
90
90
|
return out
|
|
@@ -282,10 +282,7 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
282
282
|
# Check the given run_number. If already existing, give another one which
|
|
283
283
|
# will try to be consecutive.
|
|
284
284
|
if check_runNumber:
|
|
285
|
-
|
|
286
|
-
run_no = max([x for x in values.keys()])+1
|
|
287
|
-
return run_no
|
|
288
|
-
|
|
285
|
+
# Get all the runNumbers in this test
|
|
289
286
|
test_list = client.get("listTestRunsByComponent",
|
|
290
287
|
json={
|
|
291
288
|
"filterMap":{
|
|
@@ -295,20 +292,27 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
295
292
|
}
|
|
296
293
|
}
|
|
297
294
|
)
|
|
298
|
-
|
|
295
|
+
runN= {}
|
|
299
296
|
for T in test_list:
|
|
300
|
-
|
|
301
|
-
run_no = int(T["runNumber"])
|
|
302
|
-
except ValueError:
|
|
303
|
-
run_no = get_new_value(values)
|
|
297
|
+
runN[T["runNumber"]] = 1
|
|
304
298
|
|
|
305
|
-
|
|
299
|
+
if data["runNumber"] in runN:
|
|
300
|
+
# if the given runNumber is there, try to create a new one.
|
|
301
|
+
#print("runNumber {} already in {} of {}".format(data["runNumber"], data["testType"], data["component"]))
|
|
302
|
+
try:
|
|
303
|
+
irun = int(data["runNumber"])
|
|
304
|
+
for i in range(irun+1, 100):
|
|
305
|
+
newRn = "{}".format(i)
|
|
306
|
+
if newRn not in runN:
|
|
307
|
+
data["runNumber"] = newRn
|
|
308
|
+
break
|
|
306
309
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
except ValueError:
|
|
311
|
+
for i in range(100):
|
|
312
|
+
newRn = "{}_{}".format(data["runNumber"], i+1)
|
|
313
|
+
if newRn not in runN:
|
|
314
|
+
data["runNumber"] = newRn
|
|
315
|
+
break
|
|
312
316
|
|
|
313
317
|
# Try to upload the test
|
|
314
318
|
try:
|
|
@@ -346,7 +350,8 @@ def upload_test(client, data, attachments=None, check_runNumber=False):
|
|
|
346
350
|
data=data,
|
|
347
351
|
files=attachment)
|
|
348
352
|
try:
|
|
349
|
-
|
|
353
|
+
url = db_response['url'].replace("https://eosatlas.cern.ch","https://cernbox.cern.ch/files/spaces")
|
|
354
|
+
attachment_urls[path.name] = url
|
|
350
355
|
|
|
351
356
|
except KeyError:
|
|
352
357
|
pass
|
|
@@ -368,10 +373,10 @@ def set_test_run_parameter(session, test_run, parameter, value):
|
|
|
368
373
|
"""
|
|
369
374
|
global db_response
|
|
370
375
|
try:
|
|
371
|
-
db_response = session.post("setTestRunParameter",
|
|
376
|
+
db_response = session.post("setTestRunParameter",
|
|
372
377
|
json={"testRun": test_run, "code": parameter, "value": value})
|
|
373
378
|
return None
|
|
374
|
-
|
|
379
|
+
|
|
375
380
|
except Exception as E:
|
|
376
381
|
return (str(E))
|
|
377
382
|
|
|
@@ -380,11 +385,11 @@ def create_test_run_comment(session, test_run, comments):
|
|
|
380
385
|
global db_response
|
|
381
386
|
if not isinstance(comments, Iterable):
|
|
382
387
|
comments = (comments)
|
|
383
|
-
|
|
388
|
+
|
|
384
389
|
try:
|
|
385
390
|
db_response = session.post("createTestRunComment", json={"testRun": test_run, "comments": comments})
|
|
386
391
|
return None
|
|
387
|
-
|
|
392
|
+
|
|
388
393
|
except Exception as E:
|
|
389
394
|
return (str(E))
|
|
390
395
|
|
|
@@ -666,3 +671,20 @@ def create_client():
|
|
|
666
671
|
client.user.authenticate()
|
|
667
672
|
print("Hello {} !".format(client.user.name))
|
|
668
673
|
return client
|
|
674
|
+
|
|
675
|
+
def get_db_user(client):
|
|
676
|
+
"""REturn PDB information of current user.
|
|
677
|
+
|
|
678
|
+
Args:
|
|
679
|
+
client (itkdb.Client): The DB client.
|
|
680
|
+
|
|
681
|
+
"""
|
|
682
|
+
global db_response
|
|
683
|
+
if client is None:
|
|
684
|
+
return None
|
|
685
|
+
|
|
686
|
+
try:
|
|
687
|
+
db_response = client.get("getUser", json={"userIdentity": client.user.identity})
|
|
688
|
+
return db_response
|
|
689
|
+
except Exception:
|
|
690
|
+
return None
|