itkdb-gtk 0.0.14__py3-none-any.whl → 0.0.16__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.

@@ -8,19 +8,18 @@ import sys
8
8
  from pathlib import Path
9
9
 
10
10
  try:
11
- import dbGtkUtils
12
- import ITkDBlogin
13
- import ITkDButils
14
- from ShowComments import ShowComments
15
- from ShowAttachments import ShowAttachments
16
- from ShowDefects import ShowDefects
17
- from uploadTest import create_json_data_editor
18
- except ModuleNotFoundError:
19
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
20
- from itkdb_gtk.ShowComments import ShowComments
21
- from itkdb_gtk.ShowAttachments import ShowAttachments
22
- from itkdb_gtk.ShowDefects import ShowDefects
23
- from itkdb_gtk.uploadTest import create_json_data_editor
11
+ import itkdb_gtk
12
+
13
+ except ImportError:
14
+ from pathlib import Path
15
+ cwd = Path(sys.argv[0]).parent.parent
16
+ sys.path.append(cwd.as_posix())
17
+
18
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
19
+ from itkdb_gtk.ShowComments import ShowComments
20
+ from itkdb_gtk.ShowAttachments import ShowAttachments
21
+ from itkdb_gtk.ShowDefects import ShowDefects
22
+ from itkdb_gtk.UploadTest import create_json_data_editor
24
23
 
25
24
  import gi
26
25
  gi.require_version("Gtk", "3.0")
@@ -172,8 +171,7 @@ class UploadMultipleTests(dbGtkUtils.ITkDBWindow):
172
171
  paned.add1(tree_view)
173
172
 
174
173
  # The text view
175
- frame = self.create_text_view()
176
- paned.add2(frame)
174
+ paned.add2(self.message_panel.frame)
177
175
 
178
176
  self.show_all()
179
177
 
@@ -13,15 +13,15 @@ gi.require_version("Gtk", "3.0")
13
13
  from gi.repository import Gtk, Gio
14
14
 
15
15
  try:
16
- import readAVSdata
17
- import ITkDBlogin
18
- import ITkDButils
16
+ import itkdb_gtk
17
+
18
+ except ImportError:
19
+ from pathlib import Path
20
+ cwd = Path(sys.argv[0]).parent.parent
21
+ sys.path.append(cwd.as_posix())
19
22
 
20
- from dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
21
-
22
- except ModuleNotFoundError:
23
- from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils
24
- from itkdb_gtk.dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
23
+ from itkdb_gtk import readAVSdata, ITkDBlogin, ITkDButils
24
+ from itkdb_gtk.dbGtkUtils import replace_in_container, complain, DictDialog, ask_for_confirmation
25
25
 
26
26
 
27
27
  def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
@@ -261,7 +261,7 @@ class AVSPanel(Gtk.Window):
261
261
  replace_in_container(self.test_panel[key], scrolled)
262
262
 
263
263
  def check_register_petal(self, SN):
264
- """Register teal core in DB.
264
+ """Register petal core in DB.
265
265
 
266
266
  Args:
267
267
  ----
@@ -6,18 +6,17 @@ import sys
6
6
  from pathlib import Path
7
7
 
8
8
  try:
9
- import dbGtkUtils
10
- import ITkDBlogin
11
- import ITkDButils
12
- from ShowComments import ShowComments
13
- from ShowAttachments import ShowAttachments
14
- from ShowDefects import ShowDefects
15
-
16
- except ModuleNotFoundError:
17
- from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
18
- from itkdb_gtk.ShowComments import ShowComments
19
- from itkdb_gtk.ShowAttachments import ShowAttachments
20
- from itkdb_gtk.ShowDefects import ShowDefects
9
+ import itkdb_gtk
10
+
11
+ except ImportError:
12
+ from pathlib import Path
13
+ cwd = Path(sys.argv[0]).parent.parent
14
+ sys.path.append(cwd.as_posix())
15
+
16
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
17
+ from itkdb_gtk.ShowComments import ShowComments
18
+ from itkdb_gtk.ShowAttachments import ShowAttachments
19
+ from itkdb_gtk.ShowDefects import ShowDefects
21
20
 
22
21
  import gi
23
22
  gi.require_version("Gtk", "3.0")
@@ -88,7 +87,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
88
87
  ----
89
88
  session: ITkDB session
90
89
  payload: path of test file
91
- attachment: an Attachment object.
90
+ attachment: an Attachment object or list of attachments.
92
91
 
93
92
  """
94
93
  self.payload = payload
@@ -101,7 +100,12 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
101
100
  if attachment.path is not None:
102
101
  self.attachments.append(attachment)
103
102
  else:
104
- print("Wrong attachment: {}".format(attachment))
103
+ try:
104
+ for att in attachment:
105
+ self.attachments.append(att)
106
+
107
+ except TypeError:
108
+ print("Wrong attachment: {}".format(attachment))
105
109
 
106
110
  global gtk_runs
107
111
  if gtk_runs:
@@ -168,15 +172,15 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
168
172
  # The "Add attachment" button.
169
173
  box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
170
174
  self.mainBox.pack_start(box, False, False, 0)
171
- dbGtkUtils.add_button_to_container(box, "Attachments",
175
+ self.btn_attch = dbGtkUtils.add_button_to_container(box, "Attachments",
172
176
  "Click to edit attachments.",
173
177
  self.edit_attachments)
174
178
 
175
- dbGtkUtils.add_button_to_container(box, "Comments",
179
+ self.btn_comments = dbGtkUtils.add_button_to_container(box, "Comments",
176
180
  "Click to edit comments.",
177
181
  self.edit_comments)
178
182
 
179
- dbGtkUtils.add_button_to_container(box, "Defects",
183
+ self.btn_defects = dbGtkUtils.add_button_to_container(box, "Defects",
180
184
  "Click to edit defects.",
181
185
  self.edit_defects)
182
186
 
@@ -185,26 +189,40 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
185
189
  self.upload_test_gui)
186
190
 
187
191
  # The text view
188
- frame = self.create_text_view()
189
- self.mainBox.pack_start(frame, True, True, 0)
192
+ self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
190
193
 
191
194
  self.show_all()
192
195
 
193
196
  if self.payload:
194
- the_path = Path(self.payload).expanduser().resolve()
195
- if the_path.exists():
196
- ifile = Path(self.payload).expanduser().resolve().as_posix()
197
- self.testF.set_filename(ifile)
198
- self.on_test_file(self.testF)
197
+ try:
198
+ the_path = Path(self.payload).expanduser().resolve()
199
+ if the_path.exists():
200
+ ifile = Path(self.payload).expanduser().resolve().as_posix()
201
+ self.testF.set_filename(ifile)
202
+ self.on_test_file(self.testF)
203
+ self.write_message("Loaded {}".format(the_path.name))
199
204
 
200
- else:
201
- print("Input file does not exists: {}".format(self.payload))
205
+ else:
206
+ print("Input file does not exists: {}".format(self.payload))
207
+
208
+ except TypeError:
209
+ self.load_payload(self.payload)
210
+ self.write_message("Loaded memory payload.")
211
+
212
+ #if len(self.attachments):
213
+ # dC = [A for A in self.attachments]
214
+ # self.attachments.clear()
215
+ # for A in dC:
216
+ # self.append_attachment_to_view(A)
217
+ if len(self.attachments) > 0:
218
+ self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
219
+
220
+ if len(self.comments) > 0:
221
+ self.btn_comments.set_label("Comments ({})".format(len(self.comments)))
222
+
223
+ if len(self.defects) > 0:
224
+ self.btn_defects.set_label("Defects ({})".format(len(self.defects)))
202
225
 
203
- if len(self.attachments):
204
- dC = [A for A in self.attachments]
205
- self.attachments.clear()
206
- for A in dC:
207
- self.append_attachment_to_view(A)
208
226
 
209
227
  def get_test_institute(self):
210
228
  """Select an institue."""
@@ -231,6 +249,12 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
231
249
  dlg.destroy()
232
250
  return out
233
251
 
252
+ def load_payload(self, data):
253
+ """Payloadis given as a dict."""
254
+ self.data = data
255
+ errors, missing = check_data(self.data)
256
+ self.complete_missing(missing, errors)
257
+
234
258
  def on_test_file(self, fdlg):
235
259
  """Test file browser clicked."""
236
260
  fnam = fdlg.get_filename()
@@ -239,30 +263,34 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
239
263
  try:
240
264
  self.data = json.loads(open(fnam).read())
241
265
  errors, missing = check_data(self.data)
242
-
243
- if len(missing):
244
- self.write_message("Some keys are missing in the JSon file.\n")
245
- self.write_message("{}\n".format("\n".join(['\t'+line for line in missing])))
246
-
247
- if "institution" in missing and len(missing) == 1:
248
- site = self.get_test_institute()
249
- if site:
250
- self.data["institution"] = site
251
- self.write_message("Setting Institution to {}\n".format(self.data["institution"]))
252
-
253
- else:
254
- dbGtkUtils.complain("Invalid JSON file\n{}".format('\n'.join(errors)), fnam)
255
-
256
- self.entrySN.set_text(self.data["component"])
257
- self.entryTest.set_text(self.data["testType"])
258
- self.comments = self.data.get("comments", [])
259
- self.defects = self.data.get("defects", [])
266
+ self.complete_missing(missing, errors)
260
267
 
261
268
  except Exception as E:
262
269
  self.data = None
263
270
  self.write_message("Cannot load file {}\n".format(fnam))
264
271
  self.write_message("{}\n".format(str(E)))
265
272
 
273
+ def complete_missing(self, missing, errors):
274
+ """Completes missing parts."""
275
+ if len(missing):
276
+ self.write_message("Some keys are missing in the JSon file.\n")
277
+ self.write_message("{}\n".format("\n".join(['\t'+line for line in missing])))
278
+
279
+ if "institution" in missing and len(missing) == 1:
280
+ site = self.get_test_institute()
281
+ if site:
282
+ self.data["institution"] = site
283
+ self.write_message("Setting Institution to {}\n".format(self.data["institution"]))
284
+
285
+ else:
286
+ dbGtkUtils.complain("Invalid JSON data".format('\n'.join(errors)))
287
+
288
+ self.entrySN.set_text(self.data["component"] if self.data["component"] else "")
289
+ self.entryTest.set_text(self.data["testType"])
290
+ self.comments = self.data.get("comments", [])
291
+ self.defects = self.data.get("defects", [])
292
+
293
+
266
294
  def show_data(self, *args):
267
295
  """Show data button clicked."""
268
296
  if self.data is None:
@@ -286,6 +314,10 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
286
314
  SA.hide()
287
315
  SA.destroy()
288
316
 
317
+ if len(self.attachments) > 0:
318
+ self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
319
+
320
+
289
321
  def edit_comments(self, *args):
290
322
  """Edit test comments."""
291
323
  SC = ShowComments("Test Comments", self.comments, self)
@@ -296,6 +328,9 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
296
328
  SC.hide()
297
329
  SC.destroy()
298
330
 
331
+ if len(self.comments) > 0:
332
+ self.btn_comments.set_label("Comments ({})".format(len(self.comments)))
333
+
299
334
  def edit_defects(self, *args):
300
335
  """Edit test defects."""
301
336
  SD = ShowDefects("Test Defects", self.defects, self)
@@ -306,6 +341,9 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
306
341
  SD.hide()
307
342
  SD.destroy()
308
343
 
344
+ if len(self.defects) > 0:
345
+ self.btn_defects.set_label("Defects ({})".format(len(self.defects)))
346
+
309
347
  def upload_test_gui(self, *args):
310
348
  """Uploads test and attachments."""
311
349
  self.upload_test()