From 8092701b3c228aceef6837c289cb1d6a7ce06b07 Mon Sep 17 00:00:00 2001 From: Marko Mecina <marko.mecina@univie.ac.at> Date: Mon, 20 Nov 2023 14:03:25 +0100 Subject: [PATCH] add button to open test spec JSON in TST from progress viewer --- Tst/connect_apps.py | 7 +++---- Tst/progress_view/progress_view.py | 6 +++--- Tst/tst/file_management.py | 1 - Tst/tst/tst.py | 11 ++++++++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Tst/connect_apps.py b/Tst/connect_apps.py index 378e366..1da9822 100644 --- a/Tst/connect_apps.py +++ b/Tst/connect_apps.py @@ -61,14 +61,13 @@ def connect_to_tst(logger=module_logger): obj = bus.get_object(bus_name=bus_name, object_path=obj_path) interface_actions = dbus.Interface(obj, 'org.gtk.Actions') actions = interface_actions.List() - print('Available Actions:') + logger.debug('Available Actions for {}:'.format(bus_name)) for item in actions: - print(item) - print('closing the current page in Tst') - interface_actions.Activate(actions[0], [], []) + logger.debug('{}'.format(item)) return interface_actions except dbus.exceptions.DBusException as dbe: logger.exception(dbe) + raise dbe def connect_to_progress_viewer(logger=module_logger): diff --git a/Tst/progress_view/progress_view.py b/Tst/progress_view/progress_view.py index 4373c76..e86f877 100644 --- a/Tst/progress_view/progress_view.py +++ b/Tst/progress_view/progress_view.py @@ -153,8 +153,8 @@ class TestProgressView(Gtk.ApplicationWindow): self.open_json_btn = Gtk.Button() self.open_json_btn.set_label('Open JSON in TST') self.open_json_btn.set_size_request(185, -1) - # self.open_json_btn.connect('clicked', self.on_open_json_tst) - # self.box_file_path_1.pack_start(self.open_json_btn, False, True, 5) + self.open_json_btn.connect('clicked', self.on_open_json_tst) + self.box_file_path_1.pack_start(self.open_json_btn, False, True, 5) self.path_box.pack_start(self.box_file_path_1, True, True, 0) # select file - command log @@ -196,7 +196,7 @@ class TestProgressView(Gtk.ApplicationWindow): self.title_box = Gtk.HBox() self.test_label = Gtk.Label() - self.test_label.set_markup('<big>Test:</big>') + # self.test_label.set_markup('<big>Test:</big>') self.test_title = Gtk.Label() self.set_test_title() diff --git a/Tst/tst/file_management.py b/Tst/tst/file_management.py index 9157043..dfa4873 100644 --- a/Tst/tst/file_management.py +++ b/Tst/tst/file_management.py @@ -48,7 +48,6 @@ def open_file(file_name, *args): data_from_file = None with open(file_name, 'r') as file: data_from_file = _from_json(file) - file.close() return data_from_file diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py index 2b554a0..d06ce7e 100755 --- a/Tst/tst/tst.py +++ b/Tst/tst/tst.py @@ -621,14 +621,19 @@ class TstAppWindow(Gtk.ApplicationWindow): file_selected = dialog.get_filename() cfg.save_option_to_file('tst-history', 'last-folder', os.path.dirname(file_selected)) - self.load_test_spec(file_selected) + self.load_test_spec(None, file_selected) dialog.destroy() - def load_test_spec(self, json_path): + def load_test_spec(self, simple_action, json_path, *args): + + # cast to string if called from open-test-spec action via DBus + if isinstance(json_path, GLib.Variant): + json_path = json_path.get_string() + try: json_type = True - data_from_file = file_management.open_file(file_name=json_path) + data_from_file = file_management.open_file(json_path) filename = json_path except json.decoder.JSONDecodeError: data_from_file = spec_to_json.run(specfile=json_path, gen_cmd=True, save_json=False) -- GitLab