Beispiel #1
0
 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()
Beispiel #2
0
 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():
             self.editor.save_tab_to_file(tab)
         logger.debug(tab.text())
         self.set_buttons(modes=False)
         envars = self.editor.envars
         cwd = os.path.dirname(tab.path)
         self.runner = self.view.add_python3_runner(tab.path,
                                                    cwd,
                                                    debugger=True,
                                                    envars=envars)
         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()