diff --git a/Tst/connect_apps.py b/Tst/connect_apps.py index 5b8b0a3412f747de766163fea8dc938b89a29c53..378e366e82a4b562ab36f6b9b4cd0968b3ed4e57 100644 --- a/Tst/connect_apps.py +++ b/Tst/connect_apps.py @@ -55,7 +55,7 @@ def connect_to_editor(logger=module_logger): def connect_to_tst(logger=module_logger): try: bus_name = confignator.get_option('dbus_names', 'tst') - obj_path = '/smile/egse/tst/editor/window/1' + obj_path = '/' + bus_name.replace('.', '/') + '/window/1' bus = dbus.SessionBus() obj = bus.get_object(bus_name=bus_name, object_path=obj_path) @@ -66,6 +66,7 @@ def connect_to_tst(logger=module_logger): print(item) print('closing the current page in Tst') interface_actions.Activate(actions[0], [], []) + return interface_actions except dbus.exceptions.DBusException as dbe: logger.exception(dbe) diff --git a/Tst/progress_view/progress_view.py b/Tst/progress_view/progress_view.py index aa23a0901520e55cd55fc7db52951c295e2b668b..4373c7643cccb0d4175f74bdae2249c41baf8f7e 100644 --- a/Tst/progress_view/progress_view.py +++ b/Tst/progress_view/progress_view.py @@ -26,6 +26,7 @@ import data_model import json import toolbox import generator +import connect_apps # create a logger log_file_path = cfg.get(section='progress-viewer-logging', option='log-file-path') @@ -135,49 +136,59 @@ class TestProgressView(Gtk.ApplicationWindow): #self.set_position(self.get_default_size()[1] * 0.2) self.path_frame = Gtk.Frame() - self.path_box = Gtk.Box() + self.path_box = Gtk.Box(spacing=0) self.path_box.set_orientation(Gtk.Orientation.VERTICAL) # select file - JSON test model self.box_file_path_1 = Gtk.Box() self.box_file_path_1.set_orientation(Gtk.Orientation.HORIZONTAL) - self.label_path_json = Gtk.Label() - self.label_path_json.set_text('Path to JSON test spec:') + self.label_path_json = Gtk.Label(xalign=0) + self.label_path_json.set_size_request(125, -1) + self.label_path_json.set_text('Test spec JSON:') self.box_file_path_1.pack_start(self.label_path_json, False, False, 0) self.text_path_json_btn = Gtk.FileChooserButton() self.text_path_json_btn.set_title('Choose a test specification JSON file') self.text_path_json_btn.connect('file-set', self.set_path_json_file) self.box_file_path_1.pack_start(self.text_path_json_btn, False, False, 0) + 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.path_box.pack_start(self.box_file_path_1, True, True, 0) # select file - command log self.box_file_path_2 = Gtk.Box() self.box_file_path_2.set_orientation(Gtk.Orientation.HORIZONTAL) - self.label_path_cmd = Gtk.Label() - self.label_path_cmd.set_text('Path to Command log:') + self.label_path_cmd = Gtk.Label(xalign=0) + self.label_path_cmd.set_size_request(125, -1) + self.label_path_cmd.set_text('Command log:') self.box_file_path_2.pack_start(self.label_path_cmd, False, False, 0) self.text_path_cmd_btn = Gtk.FileChooserButton() self.text_path_cmd_btn.connect('file-set', self.set_path_cmd_file) self.box_file_path_2.pack_start(self.text_path_cmd_btn, False, False, 0) self.del_btn_cmd = Gtk.Button() self.del_btn_cmd.set_label('Clear command log') + self.del_btn_cmd.set_size_request(185, -1) self.del_btn_cmd.connect('clicked', self.on_clear_cmd_log) - self.box_file_path_2.pack_start(self.del_btn_cmd, False, True, 0) + self.box_file_path_2.pack_start(self.del_btn_cmd, False, True, 5) self.path_box.pack_start(self.box_file_path_2, True, True, 0) # select file - verification log self.box_file_path_3 = Gtk.Box() self.box_file_path_3.set_orientation(Gtk.Orientation.HORIZONTAL) - self.label_path_vrc = Gtk.Label() - self.label_path_vrc.set_text('Path to Verification log:') + self.label_path_vrc = Gtk.Label(xalign=0) + self.label_path_vrc.set_size_request(125, -1) + self.label_path_vrc.set_text('Verification log:') self.box_file_path_3.pack_start(self.label_path_vrc, False, False, 0) self.text_path_vrc_btn = Gtk.FileChooserButton() self.text_path_vrc_btn.connect('file-set', self.set_path_vrc_file) self.box_file_path_3.pack_start(self.text_path_vrc_btn, False, False, 0) self.del_btn_vrc = Gtk.Button() self.del_btn_vrc.set_label('Clear verification log') + self.del_btn_vrc.set_size_request(185, -1) self.del_btn_vrc.connect('clicked', self.on_clear_vrc_log) - self.box_file_path_3.pack_start(self.del_btn_vrc, False, True, 0) + self.box_file_path_3.pack_start(self.del_btn_vrc, False, True, 5) self.path_box.pack_start(self.box_file_path_3, True, True, 0) self.path_frame.add(self.path_box) @@ -185,7 +196,7 @@ class TestProgressView(Gtk.ApplicationWindow): self.title_box = Gtk.HBox() self.test_label = Gtk.Label() - self.test_label.set_markup('<big>Test Title: </big>') + self.test_label.set_markup('<big>Test:</big>') self.test_title = Gtk.Label() self.set_test_title() @@ -289,12 +300,12 @@ class TestProgressView(Gtk.ApplicationWindow): self.btn_rld_all.connect('clicked', self.on_reload_all) self.box_buttons.pack_start(self.btn_rld_all, False, False, 0) self.btn_output = Gtk.Button() - self.btn_output.set_label('Generate Output File') + self.btn_output.set_label('Generate Report File') self.btn_output.connect('clicked', self.on_save_as) self.box_buttons.pack_start(self.btn_output, False, False, 0) self.sort_label = Gtk.Label() - self.sort_label.set_text('Sort by Execution') + self.sort_label.set_text('Sort by run') self.box_buttons.pack_end(self.sort_label, False, True, 0) self.sort_button = Gtk.Switch() @@ -302,7 +313,7 @@ class TestProgressView(Gtk.ApplicationWindow): self.box_buttons.pack_end(self.sort_button, False, True, 0) self.sort_label2 = Gtk.Label() - self.sort_label2.set_text('Sort by Steps') + self.sort_label2.set_text('Sort by steps') self.box_buttons.pack_end(self.sort_label2, False, True, 0) def make_treeview(self): @@ -363,7 +374,7 @@ class TestProgressView(Gtk.ApplicationWindow): # column 6 renderer_tcs = Gtk.CellRendererText() - column_tcs = Gtk.TreeViewColumn('TC\'s sent', renderer_tcs, text=5, background=7) + column_tcs = Gtk.TreeViewColumn('Sent TCs', renderer_tcs, text=5, background=7) column_tcs.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) column_tcs.set_resizable(True) column_tcs.set_min_width(50) @@ -391,25 +402,28 @@ class TestProgressView(Gtk.ApplicationWindow): return def get_log_file_paths_from_json_file_name(self, filename): - from testlib import testing_logger + paths = {} + try: - current_file_name = os.path.basename(filename) - path_test_specs = cfg.get(section='tst-paths', option='tst_products') path_test_runs = cfg.get(section='tst-logging', option='test_run') - json_file_path = os.path.join(path_test_specs, current_file_name) + json_file_path = os.path.abspath(filename) paths['json_file_path'] = json_file_path - name = generator.strip_file_extension(current_file_name) + spec = json.load(open(json_file_path, 'r')) + name = generator.create_file_name(spec['_name'].strip()) + cmd_log_file_path = os.path.join(path_test_runs, name + testing_logger.cmd_log_auxiliary) paths['cmd_log_file_path'] = cmd_log_file_path vrc_log_file_path = os.path.join(path_test_runs, name + testing_logger.vrc_log_auxiliary) paths['vrc_log_file_path'] = vrc_log_file_path + except Exception as e: - self.logger.info('Json or Log Files could not be found') + self.logger.info('Json or log files could not be found') return '' + return paths def open_test_files(self, simple_action, paths, *args): @@ -418,7 +432,7 @@ class TestProgressView(Gtk.ApplicationWindow): self.path_json = paths['json_file_path'] self.text_path_json_btn.set_file(Gio.File.new_for_path(self.path_json)) except: - logger.debug('JSon File could not be opened') + logger.debug('Json file could not be opened') try: self.path_cmd = paths['cmd_log_file_path'] @@ -571,7 +585,6 @@ class TestProgressView(Gtk.ApplicationWindow): self.make_treeview() self.on_reload_all() - def on_reload_all(self, *args): if self.path_json: self.load_json(self.path_json) @@ -580,48 +593,88 @@ class TestProgressView(Gtk.ApplicationWindow): if self.path_vrc: self.load_vrc(self.path_vrc) - def on_clear_cmd_log(self, *args): + + if self.text_path_cmd_btn.get_filename() is None: + return + + if not self._confirm_log_clear(self.text_path_cmd_btn): + return + with open(self.path_cmd, 'w') as cmd_log: cmd_log.write('') cmd_log.close() def on_clear_vrc_log(self, *args): + + if self.text_path_vrc_btn.get_filename() is None: + return + + if not self._confirm_log_clear(self.text_path_vrc_btn): + return + with open(self.path_vrc, 'w') as vrc_log: vrc_log.write('') vrc_log.close() + def _confirm_log_clear(self, pathbtn): + logpath = os.path.basename(pathbtn.get_filename()) + msg = '\nClear log file <i>{}</i>?\n\nAll results for this test will be deleted!'.format(logpath) + dialog = ConfirmClearLogDialog(msg=msg, parent=self) + + response = dialog.run() + if response == Gtk.ResponseType.OK: + confirmed = True + else: + confirmed = False + + dialog.destroy() + return confirmed + + def on_open_json_tst(self, *args): + + json_path = self.text_path_json_btn.get_filename() + + if json_path is None: + return + + json_path = os.path.abspath(json_path) + tst_app = self.connect_tst() + try: + tst_app.Activate('open-test-spec', [json_path], []) + except Exception as e: + message = 'Could not open JSON in TST' + self.logger.error(message) + self.logger.exception(e) + self.add_info_bar(message_type=Gtk.MessageType.ERROR, message=message) def on_save_as(self, *args): self.save_as_file_dialog() - return def save_as_file_dialog(self): - # If one log file is loaded use it as Log file path, otherwise ask for it in separate dialog - test_name = None + + if self.path_json: + test_spec = os.path.abspath(self.path_json) + else: + self.add_info_bar(message_type=Gtk.MessageType.ERROR, message='No Test Spec JSON selected.') + return + if self.path_cmd: - file_name = self.path_cmd.split('/')[-1] - log_file_path = self.path_cmd[:-len(file_name)] - test_name = file_name.split('_')[0] - elif self.path_vrc: - file_name = self.path_vrc.split('/')[-1] - log_file_path = self.path_vrc[:-len(file_name)] - test_name = file_name.split('_')[0] + log_file_path_cmd = os.path.abspath(self.path_cmd) else: - log_file_path=None + self.add_info_bar(message_type=Gtk.MessageType.ERROR, message='No command log selected.') + return - if not test_name and self.path_json: - test_name = self.path_json.split('/')[-1].split('.')[0] + if self.path_vrc: + log_file_path_vrc = os.path.abspath(self.path_vrc) + else: + self.add_info_bar(message_type=Gtk.MessageType.ERROR, message='No verification log selected.') + return - dialog = Save_to_File_Dialog(parent=self) # Look were the output file should be saved and which files (log, json) should be used + # Look were the output file should be saved and which files (log, json) should be used + dialog = Save_to_File_Dialog(parent=self) response = dialog.run() if response == Gtk.ResponseType.OK: - if not test_name: - test_name = dialog.test_name.get_text() - if not test_name: - dialog.destroy() - self.logger.info('Can not create Output file without test name') - return folder = dialog.get_current_folder() run_count = dialog.run_id_selection.get_active() @@ -631,48 +684,16 @@ class TestProgressView(Gtk.ApplicationWindow): for run_id in self.run_count.keys(): if self.run_count[run_id] == str(run_count): sent_run_id = run_id - if not log_file_path: - if not dialog.log_file_path_check.get_active(): - log_file_path = 'FIND' - if not self.path_json: - if dialog.log_file_path_check.get_active(): - json_file_path = None - else: - json_file_path = 'FIND' - else: - json_file_path = self.path_json - elif response == Gtk.ResponseType.CANCEL: + else: # response == Gtk.ResponseType.CANCEL: dialog.destroy() return dialog.destroy() - if log_file_path == 'FIND': # Get the log file path if they are not already given - dialog = File_Path_Dialog(parent=self, file='Command or Verification Log File', is_json=False) - response = dialog.run() - if response == Gtk.ResponseType.OK: - log_file_path = dialog.get_current_folder() - elif response == Gtk.ResponseType.CANCEL: - dialog.destroy() - return - dialog.destroy() - if json_file_path == 'FIND': # Get the json file if it is not already given - dialog = File_Path_Dialog(parent=self, file='the Json File', is_json=True) - response = dialog.run() - if response == Gtk.ResponseType.OK: - json_file_path = dialog.get_filename() - elif response == Gtk.ResponseType.CANCEL: - dialog.destroy() - return - - dialog.destroy() - - analyse_test_run.save_result_to_file(test_name=test_name, log_file_path=log_file_path, output_file_path=folder, - json_file_path=json_file_path, run_id=sent_run_id, test_report=test_report, - logger=self.logger) - - return + analyse_test_run.save_result_to_file(json_file_path=test_spec, log_file_cmd=log_file_path_cmd, + log_file_vrc=log_file_path_vrc, output_file_path=folder, + run_id=sent_run_id, test_report=test_report, logger=self.logger) def on_destroy(self, *args): self.logger.info('Self-Destruct of the ProgressView Window initiated.\n') @@ -1296,6 +1317,25 @@ class TestProgressView(Gtk.ApplicationWindow): #self.add_detailed_row(new_row_iter, tree_store) self.restore_expanded_states(tree_store) + def connect_tst(self): + try: + connect_apps.connect_to_tst(logger=self.logger) + except dbus.exceptions.DBusException: + self.logger.warning('could not connect to TST, starting it') + cfl.start_tst() + k = 0 + while k < 10: + self.logger.debug('trying to connect to the TST via DBus.') + time.sleep(0.2) + try: + prog = connect_apps.connect_to_tst(logger=self.logger) + if prog is not None: + self.logger.info('Successfully connected to TST via DBus.') + return prog + except dbus.exceptions.DBusException: + self.logger.warning('Failed to connect to TST') + k += 1 + class Save_to_File_Dialog(Gtk.FileChooserDialog): def __init__(self, parent=None): @@ -1337,12 +1377,12 @@ class Save_to_File_Dialog(Gtk.FileChooserDialog): # Select the Run ID which should be printed to the File self.run_id_selection = Gtk.ComboBoxText.new() # Make the Combobox if not self.win.sort_button.get_active(): # If sorted by steps, run id is not defined - self.run_id_selection.append_text('Whole Log File') # Only possible selection is to save whole file + self.run_id_selection.append_text('All runs') # Only possible selection is to save whole file self.run_id_selection.set_button_sensitivity(False) self.run_id_selection.set_active(0) - self.run_id_selection.set_tooltip_text('If Sorted by Executions, it is possible to limit the Output File to just one Run') + self.run_id_selection.set_tooltip_text('If Sorted by runs, it is possible to limit the output file to a specific run') else: # If sorted by executions add all available run ids - self.run_id_selection.append('0', 'Whole Log File') # Give also the possibility to save whole file + self.run_id_selection.append('0', 'All runs') # Give also the possibility to save whole file for run_id in self.win.run_count: self.run_id_selection.append(run_id, 'Run ' + self.win.run_count[run_id]) # Add all Run ids @@ -1361,12 +1401,12 @@ class Save_to_File_Dialog(Gtk.FileChooserDialog): self.run_id_selection.set_active(1) except: self.run_id_selection.set_active(0) - self.run_id_selection.set_tooltip_text('Define which Run should be saved or the whole Log File') + self.run_id_selection.set_tooltip_text('Select which run should be saved') test_report_label = Gtk.Label(label='Test Report: ') self.test_report_int = Gtk.Entry() - self.test_report_int.set_tooltip_text('Select the Test Report Number (1-999) NOTE: Prior Versions could be overwritten, If emtpy it will be automatically generated') + self.test_report_int.set_tooltip_text('Specify the Test Report version (1-999)\nNOTE: Prior versions could be overwritten. Will be automatically generated if empty') self.savedetailes.pack_end(self.run_id_selection, False, True, 10) self.savedetailes.pack_end(run_id_label, False, True, 10) @@ -1394,8 +1434,8 @@ class Save_to_File_Dialog(Gtk.FileChooserDialog): class File_Path_Dialog(Gtk.FileChooserDialog): def __init__(self, parent=None, file=None, is_json=None): super(File_Path_Dialog, self).__init__(title='Please choose {}'.format(file), - parent=parent, - action=Gtk.FileChooserAction.OPEN) + parent=parent, + action=Gtk.FileChooserAction.OPEN) self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK) @@ -1408,12 +1448,25 @@ class File_Path_Dialog(Gtk.FileChooserDialog): if not is_json: area = self.get_content_area() #main_box = Gtk.HBox() - label = Gtk.Label(label='It does not matter if Command or Verification Log File is choosen, both are in the same Folder') + label = Gtk.Label(label='It does not matter whether Command or Verification Log File is choosen, both are in the same folder') #main_box.pack_end(label, False, True, 10) area.pack_start(label, False, True, 0) self.show_all() +class ConfirmClearLogDialog(Gtk.MessageDialog): + + def __init__(self, msg='', parent=None): + super().__init__(title='Clear log', parent=parent) + + self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK) + self.set_transient_for(parent) + + self.set_markup(msg) + + self.show_all() + + def run(): bus_name = cfg.get('dbus_names', 'progress-view') dbus.validate_bus_name(bus_name) diff --git a/Tst/run_tests.py b/Tst/run_tests.py index 20d3774d7299540a5c6af79e24c9602c054021dc..b928eb6fb644289ea0995954bc2a654344e8860c 100755 --- a/Tst/run_tests.py +++ b/Tst/run_tests.py @@ -76,7 +76,7 @@ def run_test_set(ccs, pool_name, test_set=None): if len(test.step_results) == 0: if test.precond_ok is False: logger.info('Precondition not fulfilled!') - logger.info('No steps were ran successfully.') + logger.info('No steps were run successfully.') for item in test.step_results: if item['result'] is not True: if 'exception' in item: diff --git a/Tst/testing_library/testlib/analyse_test_run.py b/Tst/testing_library/testlib/analyse_test_run.py index e72bcc16e2e3f965ec5c24c07d18bbf1b16c6d90..ae1a97079b29b139547ede04923d627e20fdf8bb 100644 --- a/Tst/testing_library/testlib/analyse_test_run.py +++ b/Tst/testing_library/testlib/analyse_test_run.py @@ -8,10 +8,9 @@ import csv import datetime import os from os import listdir -from os.path import isfile, join -import os, os.path import errno import logging +import json import sys sys.path.append(confignator.get_option('paths', 'ccs')) @@ -22,8 +21,8 @@ import toolbox from testlib import analyse_verification_log from testlib import analyse_command_log -test_name = 'test' # Name of the test that should be analysed -run_id = '20210722123605' # Run ID that should be analysed or NONE for whole file +# test_name = 'test' # Name of the test that should be analysed +# run_id = '20210722123605' # Run ID that should be analysed or NONE for whole file cmd_log_file_end = '_command.log' vrc_log_file_end = '_verification.log' @@ -32,13 +31,15 @@ basic_output_file_path = confignator.get_option('tst-logging', 'output-file-path basic_json_file_path = confignator.get_option('tst-paths', 'tst_products') output_file_header = ['Item', 'Description', 'Verification', 'TestResult'] -def save_result_to_file(test_name, log_file_path=None, output_file_path=None, json_file_path=None, run_id=None, test_report=None, logger=False): + +def save_result_to_file(json_file_path=None, log_file_cmd=None, log_file_vrc=None, output_file_path=None, run_id=None, + test_report=None, logger=False): """ Analyses the command and verification log file and creates a txt output table - :param str test_name: the name of the test and of its log files - :param str log_file_path: Path to the log files, None if basic one should be used + :param str json_file_path: Path to the json file + :param str log_file_cmd: Path to the command log file + :param str log_file_vrc: Path to the verification log file :param str output_file_path: Path were the output file should be saved - :param str json_file_path: Path to the json file, None if basic one should be used :param str run_id: Output only for specific Run defined by Run ID, None use whole file :param str test_report: The Test Report number as a string, end of the output file name :param str logger: A logger @@ -52,15 +53,15 @@ def save_result_to_file(test_name, log_file_path=None, output_file_path=None, js logger.addHandler(hdlr=console_hdlr) # Get the given file paths or use the basic ones specified in the tst.cfg file - if not log_file_path: - log_file_path = basic_log_file_path - if not output_file_path: - output_file_path = basic_output_file_path - if not json_file_path: - json_file_path = basic_json_file_path + '/' + test_name + '.json' + # if not log_file_path: + # log_file_path = basic_log_file_path + # if not output_file_path: + # output_file_path = basic_output_file_path + # if not json_file_path: + # json_file_path = basic_json_file_path + '/' + test_name + '.json' - cmd_log_file = log_file_path + '/' + test_name + cmd_log_file_end - vrc_log_file = log_file_path + '/' + test_name + vrc_log_file_end + cmd_log_file = log_file_cmd # log_file_path + '/' + test_name + cmd_log_file_end + vrc_log_file = log_file_vrc # log_file_path + '/' + test_name + vrc_log_file_end # Get all the steps and verification steps from the respective log files cmd_steps = analyse_command_log.get_steps_and_commands(cmd_log_file) @@ -87,7 +88,8 @@ def save_result_to_file(test_name, log_file_path=None, output_file_path=None, js general_run_infos, precon_info, postcon_info = analyse_command_log.get_general_run_info(cmd_log_file, run_id=run_id) # Give the output file its name, consits of test name, the specification nbr (version) - name_start = '{}-TS-{}-TR-'.format(test_name, cmd_steps[0]['spec_version']) + spec = json.load(open(json_file_path, 'r')) + name_start = '{}-TS-{}-TR-'.format(spec['_name'], cmd_steps[0]['spec_version']) # Check if output folder exists otherwise make it if not os.path.isdir(output_file_path): @@ -106,7 +108,7 @@ def save_result_to_file(test_name, log_file_path=None, output_file_path=None, js test_report = int(test_report) # Output file name, with the path - output_file_name_path = output_file_path + '/' + name_start + f'{test_report:03d}' + '.txt' + output_file_name_path = os.path.join(output_file_path, '{}{:03d}.csv'.format(name_start, test_report)) with open(output_file_name_path, 'w', encoding='UTF8', newline='') as file: writer = csv.writer(file, delimiter='|') @@ -117,7 +119,7 @@ def save_result_to_file(test_name, log_file_path=None, output_file_path=None, js # write the general info line, if multiple descriptions/versions are found all are written to the output file spec_version, iasw_version = get_version(cmd_steps, logger) description = get_general_run_info_info(general_run_infos, 'descr', logger) - writer.writerow([test_name, description, 'Test Spec. Version: ' + 'IASW-{}TS-{}'.format(iasw_version, spec_version), 'Test Rep. Version: ' + f'{test_report:03d}']) + writer.writerow([spec['_name'], description, 'Test Spec. Version: {} (IASW_v{})'.format(spec_version, iasw_version), 'Test Rep. Version: {:03d}'.format(test_report)]) # write date line, first Date (Specification Date) is the last time the json file was changed or None if no json file was given # second Date (Execution Date), Is the execution Date of the first step @@ -249,6 +251,7 @@ def show_basic_results(test_name, log_file_path=None): print('\n--------------------------------------------------') return + if __name__ == '__main__': - #save_result_to_file(test_name, run_id=run_id) - show_basic_results(test_name) + # save_result_to_file(test_name, run_id=run_id) + show_basic_results(sys.argv[1]) diff --git a/Tst/tst/app_menu.xml b/Tst/tst/app_menu.xml index c5c6d64ee193faa83ca1d241f0ce66256ef9ec43..65f278b14607c1af719da5d6f99ceaca9ba8850e 100644 --- a/Tst/tst/app_menu.xml +++ b/Tst/tst/app_menu.xml @@ -56,14 +56,14 @@ <attribute name="label" translatable="yes">Poolmanager</attribute> <attribute name="action">app.start_poolmanager</attribute> </item> - <item> - <attribute name="label" translatable="yes">Plotter</attribute> - <attribute name="action">app.start_plotter</attribute> - </item> - <item> - <attribute name="label" translatable="yes">Monitor</attribute> - <attribute name="action">app.start_monitor</attribute> - </item> +<!-- <item>--> +<!-- <attribute name="label" translatable="yes">Plotter</attribute>--> +<!-- <attribute name="action">app.start_plotter</attribute>--> +<!-- </item>--> +<!-- <item>--> +<!-- <attribute name="label" translatable="yes">Monitor</attribute>--> +<!-- <attribute name="action">app.start_monitor</attribute>--> +<!-- </item>--> <item> <attribute name="label" translatable="yes">Configuration Editor</attribute> <attribute name="action">app.start_config_editor</attribute> diff --git a/Tst/tst/style/style.css b/Tst/tst/style/style.css index 94f5ee789c24229bd667c3b4266bf2e075ef36ae..a87bb5a01a535567d69b106903d5bba22c5c1a3a 100644 --- a/Tst/tst/style/style.css +++ b/Tst/tst/style/style.css @@ -134,6 +134,6 @@ .text-view { padding: 3px; } -/*.cond-dialog label{ - font-weight: bold; -}*/ \ No newline at end of file +.cond-dialog box{ + padding: 5px; +} \ No newline at end of file diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py index cba3cb7fef0d624638c1f5b6a91c1a040f5f660d..2b554a0ce92f1b6fc7514830a57186641ac0cdb0 100755 --- a/Tst/tst/tst.py +++ b/Tst/tst/tst.py @@ -53,7 +53,7 @@ file_hdlr = toolbox.create_file_handler(file=log_file) logger.addHandler(hdlr=file_hdlr) -VERSION = '0.10' +VERSION = '0.11' class TstApp(Gtk.Application): @@ -114,13 +114,13 @@ class TstApp(Gtk.Application): action.connect("activate", self._on_start_poolmanager) self.add_action(action) - action = Gio.SimpleAction.new('start_plotter', None) - action.connect("activate", self._on_start_plotter) - self.add_action(action) - - action = Gio.SimpleAction.new('start_monitor', None) - action.connect("activate", self._on_start_monitor) - self.add_action(action) + # action = Gio.SimpleAction.new('start_plotter', None) + # action.connect("activate", self._on_start_plotter) + # self.add_action(action) + # + # action = Gio.SimpleAction.new('start_monitor', None) + # action.connect("activate", self._on_start_monitor) + # self.add_action(action) action = Gio.SimpleAction.new('start_config_editor', None) action.connect("activate", self._on_start_config_editor) @@ -239,6 +239,10 @@ class TstAppWindow(Gtk.ApplicationWindow): action.connect('activate', self.on_about) self.add_action(action) + action = Gio.SimpleAction.new('open-test-spec', GLib.VariantType('s')) + action.connect('activate', self.load_test_spec) + self.add_action(action) + self.create_make_menu() self.set_icon_from_file(path_icon) @@ -616,23 +620,25 @@ class TstAppWindow(Gtk.ApplicationWindow): if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() cfg.save_option_to_file('tst-history', 'last-folder', os.path.dirname(file_selected)) - try: - json_type = True - data_from_file = file_management.open_file(file_name=file_selected) - filename = file_selected - except json.decoder.JSONDecodeError: - # data_from_file = file_management.from_json(spec_to_json.run(specfile=file_selected, gen_cmd=True, save_json=False)) - data_from_file = spec_to_json.run(specfile=file_selected, gen_cmd=True, save_json=False) - filename = file_selected.replace('.' + file_selected.split('.')[-1], '.json') - json_type = False - if os.path.exists(filename): - self.existing_json_warn_dialog(filename) - - if data_from_file is not None: - self.on_open_create_tab(data_from_file, filename, json_type) + + self.load_test_spec(file_selected) dialog.destroy() - return + + def load_test_spec(self, json_path): + try: + json_type = True + data_from_file = file_management.open_file(file_name=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) + filename = json_path.replace('.' + json_path.split('.')[-1], '.json') + json_type = False + if os.path.exists(filename): + self.existing_json_warn_dialog(filename) + + if data_from_file is not None: + self.on_open_create_tab(data_from_file, filename, json_type) def on_open_create_tab(self, data_from_file, filename, json_type): # make a new test instance and notebook page @@ -648,7 +654,6 @@ class TstAppWindow(Gtk.ApplicationWindow): self.update_model_viewer() new_test.view.update_widget_data() self.notebook.set_current_page(new_page_index) - return def on_save(self, *args): # get the data model of the current notebook page @@ -1061,15 +1066,14 @@ class TstAppWindow(Gtk.ApplicationWindow): self.logger.warning('Progress Viewer started without running Test') return '' try: - current_file_name = os.path.basename(current_instance.filename) - path_test_specs = cfg.get(section='tst-paths', option='tst_products') + # current_file_name = os.path.basename(current_instance.filename) + # path_test_specs = cfg.get(section='tst-paths', option='tst_products') path_test_runs = cfg.get(section='tst-logging', option='test_run') - json_file_path = current_instance.filename - paths['json_file_path'] = json_file_path + # json_file_path = current_instance.filename + paths['json_file_path'] = current_instance.filename - name = current_instance.test_meta_data_name.get_text() - name = generator.create_file_name(name) + name = generator.create_file_name(current_instance.test_meta_data_name.get_text().strip()) cmd_log_file_path = os.path.join(path_test_runs, name + testing_logger.cmd_log_auxiliary) paths['cmd_log_file_path'] = cmd_log_file_path