def run_game(self): """ Run the current game. """ # Grab the Python file. tab = self.view.current_tab if tab is None: logger.debug('There is no active text editor.') self.stop_game() return if tab.path is None: # Unsaved file. self.editor.save() if tab.path: # If needed, save the script. if tab.isModified(): with open(tab.path, 'w', newline='') as f: logger.info('Saving script to: {}'.format(tab.path)) logger.debug(tab.text()) write_and_flush(f, tab.text()) tab.setModified(False) logger.debug(tab.text()) self.runner = self.view.add_python3_runner(tab.path, self.workspace_dir(), interactive=False, runner='pgzrun') self.runner.process.waitForStarted()
def run_script(self): """ Run the current script. """ # Grab the Python file. tab = self.view.current_tab if tab is None: logger.debug('There is no active text editor.') self.stop_script() return if tab.path is None: # Unsaved file. self.editor.save() if tab.path: # If needed, save the script. if tab.isModified(): with open(tab.path, 'w', newline='') as f: logger.info('Saving script to: {}'.format(tab.path)) logger.debug(tab.text()) write_and_flush(f, tab.text()) tab.setModified(False) logger.debug(tab.text()) envars = self.editor.envars self.runner = self.view.add_python3_runner(tab.path, self.workspace_dir(), interactive=True, envars=envars) self.runner.process.waitForStarted() if self.kernel_runner: self.set_buttons(plotter=False) elif self.plotter: self.set_buttons(repl=False)
def run_script(self): """ Run the current script. """ # Grab the Python file. tab = self.view.current_tab if tab is None: logger.debug('There is no active text editor.') self.stop_script() return if tab.path is None: # Unsaved file. self.editor.save() if tab.path: # If needed, save the script. if tab.isModified(): with open(tab.path, 'w', newline='') as f: logger.info('Saving script to: {}'.format(tab.path)) logger.debug(tab.text()) write_and_flush(f, tab.text()) tab.setModified(False) logger.debug(tab.text()) envars = self.editor.envars self.runner = self.view.add_python3_runner(tab.path, self.workspace_dir(), interactive=True, envars=envars) self.runner.process.waitForStarted() if self.kernel_runner: self.set_buttons(plotter=False) elif self.plotter: self.set_buttons(repl=False)
def start(self): """ Start running/debugging the current script. """ # Grab the Python file. tab = self.view.current_tab if tab is None: logger.debug('There is no active text editor.') self.stop() return if tab.path is None: # Unsaved file. self.editor.save() if tab.path: logger.debug('Running / debugging script.') # If needed, save the script. if tab.isModified(): with open(tab.path, 'w', newline='') as f: logger.info('Saving script to: {}'.format(tab.path)) logger.debug(tab.text()) write_and_flush(f, tab.text()) tab.setModified(False) logger.debug('Python script: {}'.format(tab.path)) logger.debug('Working directory: {}'.format(self.workspace_dir())) logger.debug(tab.text()) self.editor.show_status_message( _("Running script {}").format(tab.path)) self.runner = self.view.add_python3_runner(tab.path, self.workspace_dir()) self.runner.process.waitForStarted() self.runner.process.finished.connect(self.finished) self.view.add_debug_inspector() self.view.set_read_only(True) self.debugger = Debugger('localhost', DEBUGGER_PORT, proc=self.runner.process) self.debugger.view = self self.debugger.start() else: logger.debug('Current script has not been saved. Aborting debug.') self.stop()
def start(self): """ Start debugging the current script. """ # Grab the Python file. tab = self.view.current_tab if tab is None: logger.debug('There is no active text editor.') self.stop() return if tab.path is None: # Unsaved file. self.editor.save() if tab.path: # If needed, save the script. if tab.isModified(): with open(tab.path, 'w', newline='') as f: logger.info('Saving script to: {}'.format(tab.path)) logger.debug(tab.text()) write_and_flush(f, tab.text()) tab.setModified(False) logger.debug(tab.text()) self.runner = self.view.add_python3_runner(tab.path, self.workspace_dir(), debugger=True) self.runner.process.waitForStarted() self.runner.process.finished.connect(self.finished) self.view.add_debug_inspector() self.view.set_read_only(True) self.debugger = Debugger('localhost', DEBUGGER_PORT, proc=self.runner.process) self.debugger.view = self self.debugger.start() else: logger.debug('Current script has not been saved. Aborting debug.') self.stop()