itkdb-gtk 0.11.0__tar.gz → 0.14.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of itkdb-gtk might be problematic. Click here for more details.

Files changed (40) hide show
  1. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/PKG-INFO +1 -1
  2. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ITkDButils.py +35 -2
  3. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/UploadMultipleTests.py +14 -10
  4. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/__init__.py +1 -8
  5. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/dashBoard.py +44 -31
  6. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/PKG-INFO +1 -1
  7. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/SOURCES.txt +0 -1
  8. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/entry_points.txt +0 -1
  9. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/pyproject.toml +1 -2
  10. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/testBatch.py +17 -6
  11. itkdb_gtk-0.11.0/itkdb_gtk/PetalReceptionTests.py +0 -308
  12. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/README.md +0 -0
  13. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/CreateShipments.py +0 -0
  14. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/GetShipments.py +0 -0
  15. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/GlueWeight.py +0 -0
  16. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ITkDB.desktop +0 -0
  17. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ITkDB.svg +0 -0
  18. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ITkDBlogin.py +0 -0
  19. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/PanelVisualInspection.py +0 -0
  20. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/SensorUtils.py +0 -0
  21. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ShowAttachments.py +0 -0
  22. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ShowComments.py +0 -0
  23. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/ShowDefects.py +0 -0
  24. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/UploadModuleIV.py +0 -0
  25. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/UploadTest.py +0 -0
  26. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/VisualInspection.py +0 -0
  27. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/WireBondGui.py +0 -0
  28. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/dbGtkUtils.py +0 -0
  29. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/readGoogleSheet.py +0 -0
  30. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk/untrash_component.py +0 -0
  31. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/dependency_links.txt +0 -0
  32. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/requires.txt +0 -0
  33. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/itkdb_gtk.egg-info/top_level.txt +0 -0
  34. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/setup.cfg +0 -0
  35. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/testAnimated.py +0 -0
  36. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/testComponent.py +0 -0
  37. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/testRange.py +0 -0
  38. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/testThread.py +0 -0
  39. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/test_attachment.py +0 -0
  40. {itkdb_gtk-0.11.0 → itkdb_gtk-0.14.1}/test/test_holes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itkdb_gtk
3
- Version: 0.11.0
3
+ Version: 0.14.1
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
@@ -90,6 +90,39 @@ def get_db_date(timestamp=None):
90
90
  return out
91
91
 
92
92
 
93
+
94
+ def get_petal_core_batches(session):
95
+ """Get list of Petal core batches"""
96
+ payload = {
97
+ "filterMap": {
98
+ "project": "S",
99
+ "batchType": ["PETAL_CORE_BATCH_TYPE"],
100
+ }
101
+ }
102
+ batch_list = session.get("listBatches", json=payload)
103
+ rc = {}
104
+ for B in batch_list:
105
+ rc[B["number"] ]= B["id"]
106
+
107
+ return rc
108
+
109
+ def set_petal_core_batch(session, petal_core):
110
+ """Set the batch of the petal core."""
111
+ if petal_core["type"]["code"] != "CORE_AVS":
112
+ return
113
+
114
+ batch_list = get_petal_core_batches(session)
115
+ aliasID = petal_core["alternativeIdentifier"]
116
+ if "PPB" in aliasID:
117
+ batch_code = "PETAL_CORE_PREPROD"
118
+ elif "PPC" in aliasID:
119
+ batch_code = "PETAL_CORE_PROD"
120
+ else:
121
+ batch_code = "PETAL_CORE_PROTO"
122
+
123
+ rc = session.post("addBatchComponent", json={"id":batch_list[batch_code], "component": petal_core["id"]})
124
+ return rc
125
+
93
126
  def registerPetalCore(client, SN, alias, HC_id=None):
94
127
  """Register a Petal Core in the DB.
95
128
 
@@ -115,14 +148,14 @@ def registerPetalCore(client, SN, alias, HC_id=None):
115
148
  if HC_id is not None:
116
149
  dto["properties"]["HC_ID"] = HC_id
117
150
 
118
- db_response = client.post('registerComponent', json=dto)
119
151
  try:
152
+ db_response = client.post('registerComponent', json=dto)
153
+ set_petal_core_batch(client, db_response["component"])
120
154
  return db_response['component']
121
155
 
122
156
  except KeyError:
123
157
  return None
124
158
 
125
-
126
159
  def create_component_attachment(client, SN, file_path, title=None, description="", item_type="component"):
127
160
  """Create an attachment to the given component.
128
161
 
@@ -331,7 +331,6 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
331
331
  model.set_value(lv_iter, TestList.Date, handle_test_date(payload["date"]))
332
332
  model.set_value(lv_iter, TestList.Institute, handle_test_date(payload["institution"]))
333
333
 
334
-
335
334
  dlg.hide()
336
335
  dlg.destroy()
337
336
 
@@ -391,7 +390,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
391
390
 
392
391
  box.pack_start(Gtk.Label(label="Select an Institute"), False, True, 0)
393
392
 
394
- combo = self.create_institute_combo()
393
+ combo = self.create_institute_combo(only_user=True)
395
394
  box.pack_start(combo, False, True, 5)
396
395
 
397
396
  btn = Gtk.CheckButton(label="Use as default for other tests missing institute ?")
@@ -441,11 +440,9 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
441
440
 
442
441
  model[lv_iter][TestList.Json] = data
443
442
 
444
-
445
443
  dlg.hide()
446
444
  dlg.destroy()
447
445
 
448
-
449
446
  def get_component_stages(self, SN):
450
447
  """Create a combo with the stages."""
451
448
  try:
@@ -468,11 +465,9 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
468
465
  self.write_message("Something went wrong with the stages\n")
469
466
  return [None, None]
470
467
 
471
- def add_test_data_to_view(self, data, ifile=None, folder=None):
468
+ def add_test_data_to_view(self, data, default_site=None, use_default=False, ifile=None, folder=None):
472
469
  """Add a test data to the tree view."""
473
470
  has_errors = False
474
- default_site = None
475
-
476
471
  errors, missing = check_data(data)
477
472
  if len(missing) > 0:
478
473
  self.write_message("Some keys are missing in the JSon file.\n")
@@ -533,16 +528,25 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
533
528
  ifile, data, len(attachments), attachments,
534
529
  len(comments), comments, len(defects), defects, color])
535
530
 
531
+ return default_site, use_default
532
+
536
533
  def add_tests_to_view(self, files):
537
534
  """Add the input fiels to the treeview."""
535
+ default_site = None
536
+ use_default = False
538
537
  for ifile in files:
539
538
  try:
540
539
  self.write_message("{}\n".format(Path(ifile).name))
541
540
  folder = Path(ifile).parent
542
541
 
543
- data = json.loads(open(ifile, 'r', encoding="UTF-8").read())
544
- self.add_test_data_to_view(data, ifile=ifile, folder=folder)
545
-
542
+ data = json.loads(open(ifile, "r", encoding="UTF-8").read())
543
+ default_site, use_default = self.add_test_data_to_view(
544
+ data,
545
+ default_site=default_site,
546
+ use_default=use_default,
547
+ ifile=ifile,
548
+ folder=folder,
549
+ )
546
550
 
547
551
  except Exception as E:
548
552
  self.write_message("Cannot load file {}\n".format(ifile))
@@ -1,6 +1,6 @@
1
1
  """ itkdb-gtk python module
2
2
  """
3
- __version__ = "0.11.0"
3
+ __version__ = "0.14.1"
4
4
 
5
5
 
6
6
  def dash_board():
@@ -20,13 +20,6 @@ def glueWeight():
20
20
  from .GlueWeight import main
21
21
  main()
22
22
 
23
-
24
- def petalReceptionTests():
25
- """GND/VI tests."""
26
- from .PetalReceptionTests import main
27
- main()
28
-
29
-
30
23
  def createShipments():
31
24
  """Send items."""
32
25
  from .CreateShipments import main
@@ -13,7 +13,6 @@ except ImportError:
13
13
 
14
14
  from itkdb_gtk import dbGtkUtils
15
15
  from itkdb_gtk import GetShipments
16
- from itkdb_gtk import PetalReceptionTests
17
16
  from itkdb_gtk import ITkDBlogin
18
17
  from itkdb_gtk import CreateShipments
19
18
  from itkdb_gtk import UploadTest
@@ -31,6 +30,7 @@ try:
31
30
  from petal_qc.thermal.coreThermal import CoreThermal
32
31
  from petal_qc.thermal.IRPetalParam import IRPetalParam
33
32
  from petal_qc.metrology.uploadPetalInformation import AVSPanel, AVSOptions
33
+ from petal_qc import PetalReceptionTests
34
34
 
35
35
  HAS_PETALQC = True
36
36
  except ImportError as E:
@@ -50,7 +50,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
50
50
  UPLOAD_MANY_TESTS = 2
51
51
  CREATE_SHIPMNT = 3
52
52
  RECV_SHIPMNT = 4
53
- PETAL_GND = 5
53
+ PETAL_RECEPTION = 5
54
54
  GLUE_WEIGHT = 6
55
55
  MOD_IV = 7
56
56
  WIRE_BOND = 8
@@ -69,9 +69,9 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
69
69
  self.set_border_width(10)
70
70
 
71
71
  # Prepare dashboard
72
- lbl = Gtk.Label()
73
- lbl.set_markup("<big><b>ITkDB available commands.</b></big>")
74
- self.mainBox.pack_start(lbl, True, True, 0)
72
+ #lbl = Gtk.Label()
73
+ #lbl.set_markup("<big><b>ITkDB available commands.</b></big>")
74
+ #self.mainBox.pack_start(lbl, True, True, 0)
75
75
 
76
76
  grid = Gtk.Grid(column_spacing=5, row_spacing=5)
77
77
  self.mainBox.pack_start(grid, False, True, 5)
@@ -91,15 +91,20 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
91
91
  btnTest.connect("clicked", self.upload_multiple_tests)
92
92
  grid.attach(btnTest, 1, irow, 1, 1)
93
93
 
94
- irow += 1
95
- btnGnd = Gtk.Button(label="Petal Reception")
96
- btnGnd.connect("clicked", self.petal_gnd)
97
- grid.attach(btnGnd, 0, irow, 1, 1)
94
+ irow +=1
95
+ separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
96
+ grid.attach(separator, 0, irow, 2, 1)
98
97
 
99
- btnWeight = Gtk.Button(label="GlueWeight")
100
- btnWeight.connect("clicked", self.glue_weight)
101
- grid.attach(btnWeight, 1, irow, 1, 1)
98
+ irow += 1
99
+ btnModVI = Gtk.Button(label="Module/Sensor Visual Insp.")
100
+ btnModVI.connect("clicked", self.module_VI)
101
+ grid.attach(btnModVI, 0, irow, 1, 1)
102
+
102
103
 
104
+ btnPanelVI = Gtk.Button(label="Panel Visual Insp.")
105
+ btnPanelVI.connect("clicked", self.panel_VI)
106
+ grid.attach(btnPanelVI, 1, irow, 1, 1)
107
+
103
108
  irow += 1
104
109
  btnModIV = Gtk.Button(label="Sensor/Module IV")
105
110
  btnModIV.connect("clicked", self.module_IV)
@@ -110,20 +115,26 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
110
115
  grid.attach(btnWireBond, 1, irow, 1, 1)
111
116
 
112
117
  irow += 1
113
- btnPanelVI = Gtk.Button(label="Panel Visual Insp.")
114
- btnPanelVI.connect("clicked", self.panel_VI)
115
- grid.attach(btnPanelVI, 1, irow, 1, 1)
118
+ btnWeight = Gtk.Button(label="GlueWeight")
119
+ btnWeight.connect("clicked", self.glue_weight)
120
+ grid.attach(btnWeight, 0, irow, 1, 1)
121
+
116
122
 
117
- btnModVI = Gtk.Button(label="Module/Sensor Visual Insp.")
118
- btnModVI.connect("clicked", self.module_VI)
119
- grid.attach(btnModVI, 0, irow, 1, 1)
120
123
 
121
124
  if HAS_PETALQC:
125
+ irow +=1
126
+ separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
127
+ grid.attach(separator, 0, irow, 2, 1)
128
+
122
129
  irow +=1
123
130
  btnPetalInfo = Gtk.Button(label="AVS Petal Info")
124
131
  btnPetalInfo.connect("clicked", self.upload_petal_info)
125
132
  grid.attach(btnPetalInfo, 0, irow, 1, 1)
126
133
 
134
+ btnGnd = Gtk.Button(label="Petal Reception")
135
+ btnGnd.connect("clicked", self.petal_reception)
136
+ grid.attach(btnGnd, 1, irow, 1, 1)
137
+
127
138
  irow +=1
128
139
  btnPetalMetrology = Gtk.Button(label="Petal Core Metrology")
129
140
  btnPetalMetrology.connect("clicked", self.petal_metrology)
@@ -211,19 +222,6 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
211
222
  )
212
223
  W.connect("destroy", self.app_closed, bitn)
213
224
 
214
- def petal_gnd(self, *args):
215
- """Petal GND/VI test."""
216
- bitn = DashWindow.PETAL_GND
217
- bt = 1 << bitn
218
- if self.mask & bt:
219
- return
220
-
221
- self.mask |= bt
222
- W = PetalReceptionTests.PetalReceptionTests(
223
- self.session,
224
- help_link="{}/petalReceptionTests.html".format(HELP_LINK)
225
- )
226
- W.connect("destroy", self.app_closed, bitn)
227
225
 
228
226
  def glue_weight(self, *args):
229
227
  """Glue Weight test."""
@@ -297,6 +295,21 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
297
295
  )
298
296
  W.connect("destroy", self.app_closed, bitn)
299
297
  W.show_all()
298
+
299
+ def petal_reception(self, *args):
300
+ """Petal GND/VI test."""
301
+ bitn = DashWindow.PETAL_RECEPTION
302
+ bt = 1 << bitn
303
+ if self.mask & bt:
304
+ return
305
+
306
+ self.mask |= bt
307
+ W = PetalReceptionTests.PetalReceptionTests(
308
+ self.session,
309
+ help_link="{}/petalReceptionTests.html".format(HELP_LINK)
310
+ )
311
+ W.connect("destroy", self.app_closed, bitn)
312
+
300
313
 
301
314
  def upload_petal_info(self, *srgs):
302
315
  """Upload petal Info."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itkdb_gtk
3
- Version: 0.11.0
3
+ Version: 0.14.1
4
4
  Summary: A collection of Gtk based GUI to access ITkDB.
5
5
  Author-email: Carlos Lacasta <carlos.lacasta@cern.ch>
6
6
  Project-URL: Homepage, https://gitlab.cern.ch/atlas-itk/sw/db/itk-pdb-gtk-gui-utils
@@ -8,7 +8,6 @@ itkdb_gtk/ITkDB.svg
8
8
  itkdb_gtk/ITkDBlogin.py
9
9
  itkdb_gtk/ITkDButils.py
10
10
  itkdb_gtk/PanelVisualInspection.py
11
- itkdb_gtk/PetalReceptionTests.py
12
11
  itkdb_gtk/SensorUtils.py
13
12
  itkdb_gtk/ShowAttachments.py
14
13
  itkdb_gtk/ShowComments.py
@@ -4,7 +4,6 @@ getShipments = itkdb_gtk:getShipments
4
4
  glueWeight = itkdb_gtk:glueWeight
5
5
  itkdb_dashBoard = itkdb_gtk:dash_board
6
6
  panelVisualInspection = itkdb_gtk:panelVisualInspection
7
- petalReceptionTests = itkdb_gtk:petalReceptionTests
8
7
  uploadModuleIV = itkdb_gtk:uploadModuleIV
9
8
  uploadMultipleTests = itkdb_gtk:uploadMultipleTests
10
9
  uploadTest = itkdb_gtk:uploadTest
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itkdb_gtk"
7
- version = "0.11.0"
7
+ version = "0.14.1"
8
8
  authors = [
9
9
  { name="Carlos Lacasta", email="carlos.lacasta@cern.ch" },
10
10
  ]
@@ -30,7 +30,6 @@ classifiers = [
30
30
  itkdb_dashBoard = "itkdb_gtk:dash_board"
31
31
  getShipments = "itkdb_gtk:getShipments"
32
32
  glueWeight = "itkdb_gtk:glueWeight"
33
- petalReceptionTests = "itkdb_gtk:petalReceptionTests"
34
33
  createShipments = "itkdb_gtk:createShipments"
35
34
  uploadTest = "itkdb_gtk:uploadTest"
36
35
  uploadMultipleTests = "itkdb_gtk:uploadMultipleTests"
@@ -34,13 +34,15 @@ def get_all_Petals(session):
34
34
  def list_petal_core_batches(session):
35
35
  """Get list of Petal core batches"""
36
36
  payload = {
37
+ "filterMap": {
37
38
  "project": "S",
38
- "batchType": ["PETAL_CORE_PROTO", "PETAL_CORE_PREPROD", "PETAL_CORE_PROD"],
39
+ "batchType": ["PETAL_CORE_BATCH_TYPE"],
40
+ }
39
41
  }
40
42
  batch_list = session.get("listBatches", json=payload)
41
43
  rc = {}
42
44
  for B in batch_list:
43
- rc[B["code"] ]= B["id"]
45
+ rc[B["number"] ]= B["id"]
44
46
 
45
47
  return rc
46
48
 
@@ -50,7 +52,7 @@ def create_petal_core_batchType(session):
50
52
  out = session.post(
51
53
  "createBatchType",
52
54
  json={
53
- "code": "PETAL_CORE",
55
+ "code": "PETAL_CORE_BATCH_TYPE",
54
56
  "name": "Petal Core",
55
57
  "state": "active",
56
58
  "project": "S",
@@ -60,7 +62,7 @@ def create_petal_core_batchType(session):
60
62
  "createBatch",
61
63
  json={
62
64
  "project": "S",
63
- "batchType": "PETAL_CORE",
65
+ "batchType": "PETAL_CORE_BATCH_TYPE",
64
66
  "number": "PETAL_CORE_PROTO",
65
67
  "ownerInstituteList": ["IFIC", "AVS", "DESYHH"],
66
68
  },
@@ -69,7 +71,7 @@ def create_petal_core_batchType(session):
69
71
  "createBatch",
70
72
  json={
71
73
  "project": "S",
72
- "batchType": "PETAL_CORE",
74
+ "batchType": "PETAL_CORE_BATCH_TYPE",
73
75
  "number": "PETAL_CORE_PREPROD",
74
76
  "ownerInstituteList": ["IFIC", "AVS", "DESYHH"],
75
77
  },
@@ -78,7 +80,7 @@ def create_petal_core_batchType(session):
78
80
  "createBatch",
79
81
  json={
80
82
  "project": "S",
81
- "batchType": "PETAL_CORE",
83
+ "batchType": "PETAL_CORE_BATCH_TYPE",
82
84
  "number": "PETAL_CORE_PROD",
83
85
  "ownerInstituteList": ["IFIC", "AVS", "DESYHH"],
84
86
  },
@@ -86,6 +88,9 @@ def create_petal_core_batchType(session):
86
88
 
87
89
 
88
90
  def main(session):
91
+ """Create batchers."""
92
+ #create_petal_core_batchType(session)
93
+
89
94
  batch_list = list_petal_core_batches(session)
90
95
 
91
96
  # # create the batches
@@ -112,6 +117,10 @@ def main(session):
112
117
 
113
118
  print("{} - {}".format(aliasID, batch_code))
114
119
  rc = session.post("addBatchComponent", json={"id":batch_list[batch_code], "component": petal_core["id"]})
120
+ if rc is None:
121
+ pass
122
+ else:
123
+ pass
115
124
 
116
125
 
117
126
  if __name__ == "__main__":
@@ -124,3 +133,5 @@ if __name__ == "__main__":
124
133
 
125
134
  except Exception as E:
126
135
  print(E)
136
+
137
+ dlg.die()
@@ -1,308 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Test dashboard."""
3
- import sys
4
- import copy
5
- from pathlib import Path
6
-
7
- try:
8
- import itkdb_gtk
9
-
10
- except ImportError:
11
- cwd = Path(__file__).parent.parent
12
- sys.path.append(cwd.as_posix())
13
- import itkdb_gtk
14
-
15
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
16
-
17
- import gi
18
- gi.require_version("Gtk", "3.0")
19
- from gi.repository import Gtk, Gio
20
-
21
-
22
- def find_children(W):
23
- """Find DictDialog among the children."""
24
- try:
25
- for c in W.get_children():
26
- if "DictDialog" in c.get_name():
27
- return c
28
-
29
- else:
30
- return find_children(c)
31
-
32
- except Exception:
33
- return None
34
-
35
- return None
36
-
37
-
38
- class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
39
- """Petl Reception Test GUI."""
40
-
41
- def __init__(self, session, help_link=None):
42
- """Initialization."""
43
- super().__init__(title="Petal Reception Tests",
44
- session=session,
45
- show_search="Find object with given SN.",
46
- help_link=help_link)
47
-
48
- # Members
49
- self.dbObject = None
50
-
51
- # action button in header
52
- button = Gtk.Button()
53
- icon = Gio.ThemedIcon(name="document-send-symbolic")
54
- image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
55
- button.add(image)
56
- button.set_tooltip_text("Click to upload ALL tests.")
57
- button.connect("clicked", self.upload_tests)
58
- self.hb.pack_end(button)
59
-
60
- grid = Gtk.Grid(column_spacing=5, row_spacing=1)
61
- self.mainBox.pack_start(grid, False, False, 5)
62
-
63
- lbl = Gtk.Label(label="Serial Number")
64
- lbl.set_xalign(0)
65
- grid.attach(lbl, 0, 0, 1, 1)
66
-
67
-
68
- self.SN = itkdb_gtk.dbGtkUtils.TextEntry()
69
- self.SN.connect("text-changed", self.on_SN_changed)
70
-
71
- #self.SN = Gtk.Entry()
72
- #self.SN.connect("focus-in-event", self.on_sn_enter)
73
- #self.SN.connect("focus-out-event", self.on_sn_leave)
74
- grid.attach(self.SN.entry, 1, 0, 1, 1)
75
-
76
- self.alias = Gtk.Label(label="")
77
- grid.attach(self.alias, 2, 0, 1, 1)
78
-
79
- self.stage = Gtk.Label(label="")
80
- grid.attach(self.stage, 3, 0, 1, 1)
81
-
82
- lbl = Gtk.Label(label="Institute")
83
- lbl.set_xalign(0)
84
- grid.attach(lbl, 0, 1, 1, 1)
85
-
86
- self.institute = self.pdb_user["institutions"][0]["code"]
87
- inst = self.create_institute_combo(only_user=True)
88
- inst.connect("changed", self.new_institute)
89
- inst.set_tooltip_text("Select the Institute.")
90
- grid.attach(inst, 1, 1, 1, 1)
91
- self.inst_cmb = inst
92
-
93
- # The "Add/Remove/Send Item" buttons.
94
- box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
95
- box.set_layout(Gtk.ButtonBoxStyle.END)
96
- self.mainBox.pack_start(box, False, False, 0)
97
- dbGtkUtils.add_button_to_container(box, "Upload test", "Upload this test", self.upload_single_test)
98
- dbGtkUtils.add_button_to_container(box, "Add Defect", "Click to add a defect", self.add_defect)
99
- dbGtkUtils.add_button_to_container(box, "Add Comment", "Click to add a comment", self.add_comment)
100
-
101
- # The notebook
102
- self.notebook = Gtk.Notebook()
103
- self.notebook.set_tab_pos(Gtk.PositionType.LEFT)
104
- self.notebook.set_size_request(-1, 250)
105
- self.mainBox.pack_start(self.notebook, True, True, 0)
106
-
107
- # Create the Notebook pages
108
- self.create_test_box("Visual Inspection", "VISUAL_INSPECTION")
109
- self.create_test_box("Grounding", "GROUNDING_CHECK")
110
- self.create_test_box("Pipe bending", "BENDING120")
111
- self.create_test_box("X-rays", "XRAYIMAGING")
112
-
113
-
114
- # The text view
115
- self.mainBox.pack_end(self.message_panel.frame, True, True, 5)
116
-
117
- # Set the default institute
118
- dbGtkUtils.set_combo_iter(inst, self.institute)
119
-
120
-
121
- self.show_all()
122
-
123
- def on_SN_changed(self, entry, value):
124
- """New SN given. Ask in PDB,"""
125
- if len(value) <= 0:
126
- return None
127
-
128
- self.query_db()
129
- current_location = self.dbObject["currentLocation"]["code"]
130
- dbGtkUtils.set_combo_iter(self.inst_cmb, current_location, 0)
131
-
132
- stg = self.dbObject["currentStage"]["name"]
133
- self.stage.set_text(stg)
134
-
135
- entry.set_text(self.dbObject["serialNumber"])
136
-
137
- alias = self.dbObject["alternativeIdentifier"]
138
- self.alias.set_text(alias)
139
-
140
- npages = self.notebook.get_n_pages()
141
- for i in range(npages):
142
- page = self.notebook.get_nth_page(i)
143
- page.dict_dialog.factory_reset()
144
-
145
-
146
- def create_test_box(self, label, test_name, institute=None):
147
- """Create and add to notebook a test dialog.
148
-
149
- Args:
150
- label: The label for the Notebook
151
- test_name: The DB name of the test
152
- institute: The institute.
153
-
154
- """
155
- if institute is None:
156
- institute = self.institute
157
-
158
- defaults = {
159
- "institution": institute,
160
- "runNumber": "1",
161
- }
162
- dto = ITkDButils.get_test_skeleton(self.session, "CORE_PETAL", test_name, defaults)
163
- if test_name == "VISUAL_INSPECTION":
164
- scrolled, gM = dbGtkUtils.create_scrolled_dictdialog(dto, ("component", "testType", "results"))
165
- else:
166
- scrolled, gM = dbGtkUtils.create_scrolled_dictdialog(dto)
167
-
168
- box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
169
- box.set_border_width(5)
170
- box.pack_end(scrolled, True, True, 0)
171
- box.dict_dialog = gM
172
- gM.box = box
173
-
174
- self.notebook.append_page(box, Gtk.Label(label=label))
175
-
176
- return gM
177
-
178
- def query_db(self, *args):
179
- """Search button clicked."""
180
- SN = self.SN.get_text()
181
- if len(SN) == 0:
182
- dbGtkUtils.complain("Empty Serial number",
183
- "You should enter a valid Serial number for the petal core.",
184
- parent=self)
185
-
186
- try:
187
- self.dbObject = ITkDButils.get_DB_component(self.session, SN)
188
-
189
- except Exception as E:
190
- self.write_message(str(E)+'\n')
191
- dbGtkUtils.complain("Could not find object in DB", str(E))
192
- self.dbObject = None
193
- return
194
-
195
- #print(json.dumps(self.dbObject, indent=3))
196
-
197
- def add_defect(self, btn):
198
- """Add a new defect."""
199
- page = self.notebook.get_nth_page(self.notebook.get_current_page())
200
- values = dbGtkUtils.get_a_list_of_values("Insert new defect", ("Type", "Description/v"))
201
- if len(values)>0:
202
- defect = {"name": values[0], "description": values[1]}
203
- page.dict_dialog.values["defects"].append(defect)
204
- page.dict_dialog.refresh()
205
-
206
- def add_comment(self, btn):
207
- """Add a new comment."""
208
- page = self.notebook.get_nth_page(self.notebook.get_current_page())
209
- comment = dbGtkUtils.get_a_value("Insert new comment", is_tv=True)
210
- if comment:
211
- page.dict_dialog.values["comments"].append(comment)
212
- page.dict_dialog.refresh()
213
-
214
- def new_institute(self, combo):
215
- """A new institute has been selected."""
216
- inst = self.get_institute_from_combo(combo)
217
- if inst:
218
- self.institute = inst
219
-
220
- npages = self.notebook.get_n_pages()
221
- for i in range(npages):
222
- page = self.notebook.get_nth_page(i)
223
- page.dict_dialog.values["institution"] = self.institute
224
- page.dict_dialog.refresh()
225
-
226
- def upload_this_test(self, values):
227
- """Upload a single test."""
228
- # print(json.dumps(values, indent=2))
229
-
230
- attachments = []
231
- if values["testType"] == "XRAYIMAGING":
232
- fnam = values["results"]["IMAGELINK"]
233
- if fnam is not None and len(fnam)>0:
234
- P = Path(fnam).expanduser().resolve()
235
- if P.exists():
236
- A = ITkDButils.Attachment(path=P.as_posix(), title=P.name, desc="X-ray image")
237
- values["results"]["IMAGELINK"] = P.name
238
- attachments.append(A)
239
-
240
- rc = ITkDButils.upload_test(self.session, values, attachments=attachments, check_runNumber=True)
241
- if rc is not None:
242
- dbGtkUtils.complain("Could not upload test", rc)
243
-
244
- else:
245
- self.write_message("Test uploaded. {} - {}\n".format(values["component"], values["testType"]))
246
-
247
- def upload_single_test(self, *args):
248
- """Upload the current test."""
249
- SN = self.SN.get_text()
250
- if len(SN) == 0:
251
- dbGtkUtils.complain("Petal SN is empty")
252
- return
253
-
254
- page = self.notebook.get_nth_page(self.notebook.get_current_page())
255
- dctD = find_children(page)
256
- if dctD is None:
257
- return
258
-
259
- values = copy.deepcopy(dctD.values)
260
- values["component"] = SN
261
- self.upload_this_test(values)
262
-
263
- def upload_tests(self, *args):
264
- """Upload the current test."""
265
- SN = self.SN.get_text()
266
- if len(SN) == 0:
267
- dbGtkUtils.complain("Petal SN is empty")
268
- return
269
-
270
- for ipage in range(self.notebook.get_n_pages()):
271
- page = self.notebook.get_nth_page(ipage)
272
- dctD = find_children(page)
273
- if dctD is None:
274
- continue
275
-
276
- values = dctD.values
277
- values["component"] = SN
278
- self.upload_this_test(values)
279
-
280
- def main():
281
- """Main entry."""
282
- # DB login
283
- HELP_LINK="https://itkdb-gtk.docs.cern.ch/petalReceptionTests.html"
284
-
285
- dlg = ITkDBlogin.ITkDBlogin()
286
- client = dlg.get_client()
287
- if client is None:
288
- print("Could not connect to DB with provided credentials.")
289
- dlg.die()
290
- sys.exit()
291
-
292
- client.user_gui = dlg
293
-
294
- gTest = PetalReceptionTests(client, help_link=HELP_LINK)
295
-
296
- gTest.present()
297
- gTest.connect("destroy", Gtk.main_quit)
298
- try:
299
- Gtk.main()
300
-
301
- except KeyboardInterrupt:
302
- print("Arrrgggg!!!")
303
-
304
- dlg.die()
305
-
306
-
307
- if __name__ == "__main__":
308
- main()
File without changes
File without changes
File without changes