コード例 #1
0
ファイル: Main_Window.py プロジェクト: bvbohnen/X4_Customizer
    def Action_Reset(self):
        '''
        The Reset button was pressed.
        This will reset the file system, live editor, and refresh all tabs.
        '''
        # Verify no threads are active; if they are, ignore the button press.
        # This should normally be impossible if the action was disabled
        # properly.
        if self.worker_thread.thread_active:
            return

        # Kick off a general save for all tabs.
        # This saves settings, enabled extensions, maybe some others.
        # After reset some tabs will reload from disk, so this ensures
        # those changes are preserved.
        self.Send_Signal('save')

        # Reset the file system to flush out old contents.
        File_System.Reset()

        # Reset the live editor, to make it do a fresh pull of data
        # from the file system.
        # Note: this is designed to remember its patches across a reset,
        # so they don't need to be saved.
        Live_Editor.Reset()

        # Signal all tabs to reset, but only if the settings paths
        # are set up properly.
        if Settings.Paths_Are_Valid():
            self.Send_Signal('file_system_reset')
        return
コード例 #2
0
    def Test_Thread(self, extension_name_list):
        '''
        Threaded tester. This will block access by other tabs to
        the file system while running.
        Emits 'test_result' signals as extension tests complete.
        '''
        # Reset the file system completely.
        # TODO: do this only if the extensions enabled are changed.
        # TODO: can alternately set up the file system to track all
        #  extensions, locally skipping those disabled or ignored,
        #  and just change that behavior during test loads, such that
        #  prior state is preserved (though a reset may be needed if
        #  actual enabled extensions are changed).
        File_System.Reset()

        # Temporary overrides of Settings so that all enabled
        #  extensions are loaded.
        # Include the current output extension in the check.
        old_ignore_extensions = Settings.ignore_extensions
        old_ignore_output_extension = Settings.ignore_output_extension
        Settings.ignore_extensions = False
        Settings.ignore_output_extension = False

        # Run the tests, collecting the logged messages.
        #ext_log_lines_dict = {}
        for extension_name in extension_name_list:
            log_lines = Check_Extension(extension_name,
                                        return_log_messages=True)

            # Make the gui more responsive during testing by
            # using a signal emitted to a function that catches results
            # and updates state as each extension finishes.
            self.test_result.emit(extension_name, '\n'.join(log_lines))

        # Restore the Settings.
        Settings.ignore_extensions = old_ignore_extensions
        Settings.ignore_output_extension = old_ignore_output_extension

        # Reset the file system again, so it can restore old extension
        # finding logic.
        File_System.Reset()

        return  #ext_log_lines_dict
コード例 #3
0
 def Script_Prelaunch(self):
     '''
     Code to run just prior to a script being launched.
     Resets the file system, saves live editor patches, etc.
     '''
     # Clear out the file system from any prior run changes.
     File_System.Reset()
     # Save the Live_Editor patches, since they may get loaded
     #  by a plugin for xml application.
     Live_Editor.Save_Patches()
     self.window.Print('Saved Live Editor patches')
     # Send a signal so Config is updated properly.
     self.window.Send_Signal('script_starting')
     return