def __regist_test_func_script(self): try: self.__main_window.is_running = True # Show File Select Dialog file_path = filedialog.askopenfilename( filetypes=[('Python File', '*.py')], title=TEST_FUNC_WIZARD_TITLE) if file_path: # show env select wizard env_setup_wizard = EnvSetupWizard(master=self.master, size=12) show_wizard(wizard=env_setup_wizard, title=ENV_SET_WIZARD_TITLE) env_id = env_setup_wizard.env_setup_id if len(env_id) == 0: return # Check if it is already registed test_func = TestFuncInfo.get_data_with_path(path=file_path) if test_func is None: # Add Test Function test_func = TestFunc(path=file_path, env_id=env_id) TestFuncInfo.add_data(test_func) # Update CONF try: save_config() self.__main_window.c_println(ADD_NEW_SCRIPT_MSG % test_func.abs_path, mode=INFO) except Exception as e: self.__main_window.c_println(os.linesep + str(e), ERROR) return else: self.__main_window.c_println(ALREADY_SCRIPT_MSG % (TEST_FUNC, test_func.id), mode=INFO) # Update MainWindow self.__test_select_frame.update_list_items() finally: self.__main_window.is_running = False
def __show_env_wizard(self): try: self.__main_window.is_running = True self.__menu_file.entryconfig(0, state=DISABLED) self.__menu_file.entryconfig(7, state=DISABLED) env_setup_wizard = EnvSetupWizard(master=self.master, select_mode=BROWSE, view_mode=True, size=12) show_wizard(wizard=env_setup_wizard, title=SHOW_ENV_SETUP_WIZARD_TITLE, modal=False) finally: self.__menu_file.entryconfig(0, state=NORMAL) self.__menu_file.entryconfig(7, state=NORMAL) self.__main_window.is_running = False
def __view_conf(self): try: with open(self.conf_path, encoding=UTF8) as rs: j_data = json.load(rs) except json.JSONDecodeError: return msg_wizard = Toplevel(master=self.master) w, h, x, y = get_geometry(msg_wizard, 0.5, 0.35) msg_wizard.geometry('%dx%d+%d+%d' % (w, h, x, y)) msg_wizard.minsize(int(w), int(h)) viewer = ScrolledText(msg_wizard, font=(FONT_NAME, 15), height=1) viewer.insert(END, json.dumps(j_data, indent=2)) viewer.configure(state=DISABLED) viewer.pack(fill=BOTH, anchor=NW, expand=YES, padx=5, pady=5) self.__viewing = True show_wizard(msg_wizard, 'Configuration(%s)' % self.conf_path) self.__viewing = False
def test_func_run(self): # Check anaconda if ANACONDA_DIR is None: self.c_println(NOT_SELECTED_ANACONDA_MSG, ERROR) return select_test_func_list = self.__test_select_frame.get_select_test_func() select_model_list = self.__test_select_frame.get_select_model() select_data_list = self.__test_select_frame.get_select_data() if len(select_test_func_list) > 0 and len(select_model_list) > 0: # Treeview selectmode is BROWSE test_func = select_test_func_list[0] self.c_println('%s : %s' % (TEST_FUNC_LABEL, test_func.abs_path), mode=INFO) if select_data_list: data_script = select_data_list[0] self.c_println('%s : %s' % (DATA_SCRIPT_LABEL, data_script.abs_path), mode=INFO) else: data_script = None model_script = select_model_list[0] self.c_println('%s : %s' % (MODEL_SCRIPT_LABEL, model_script.abs_path), mode=INFO) # select confing conf_select_wizard = ConfSelectWizard( master=self.master, conf_path=test_func.conf_path) show_wizard(title=SELECT_USE_CONF_LABEL, wizard=conf_select_wizard) if not conf_select_wizard.is_run: self.c_println(CANCEL_MSG, mode=INFO) return test_func.conf_path = conf_select_wizard.conf_path # Save config save_config() if test_func.conf_path: self.c_println('Configuration : %s' % test_func.conf_path, mode=INFO) else: self.c_println('Not used configuration file', mode=INFO) # Create Execute Environment if data_script: env_id = min(set(test_func.env_id) & set(model_script.env_id) & set(data_script.env_id)) else: env_id = min(set(test_func.env_id) & set(model_script.env_id)) env_setup = EnvSetupInfo.get_data(env_id) env_python_dir = self.__create_env(script_path=env_setup.abs_path) if not env_python_dir: self.c_println(CANCEL_MSG, mode=INFO) return self.c_println('Execute Env : %s' % env_python_dir, mode=INFO) # template python file replace keyword # Created file is deleted after execution exec_path = create_test_exec_script( test_func=test_func, data=data_script, model=model_script, print_func=self.c_println) if exec_path: # Run Test Execute Function try: self.__call_test_func( test_func=test_func, env_python_dir=env_python_dir, test_func_script_path=exec_path) finally: os.remove(exec_path)