Example #1
0
    def __init__(self,
                 parent=None,
                 wdir=None,
                 path=[],
                 light_background=True,
                 menu_actions=None,
                 show_buttons_inside=True,
                 show_elapsed_time=True):
        ExternalShellBase.__init__(self,
                                   parent=parent,
                                   fname=None,
                                   wdir=wdir,
                                   history_filename='.history',
                                   light_background=light_background,
                                   menu_actions=menu_actions,
                                   show_buttons_inside=show_buttons_inside,
                                   show_elapsed_time=show_elapsed_time)

        # Additional python path list
        self.path = path

        # For compatibility with the other shells that can live in the external
        # console
        self.is_ipykernel = False
        self.connection_file = None
Example #2
0
 def finished(self, exit_code, exit_status):
     """Reimplement ExternalShellBase method"""
     if self.is_ipykernel and exit_code == 1:
         self.ipython_kernel_start_error.emit(
             self.shell.get_text_with_eol())
     ExternalShellBase.finished(self, exit_code, exit_status)
     self.introspection_socket = None
Example #3
0
 def get_options_menu(self):
     ExternalShellBase.get_options_menu(self)
     self.interact_action = create_action(self, _("Interact"))
     self.interact_action.setCheckable(True)
     self.debug_action = create_action(self, _("Debug"))
     self.debug_action.setCheckable(True)
     self.args_action = create_action(self, _("Arguments..."),
                                      triggered=self.get_arguments)
     self.post_mortem_action = create_action(self, _("Post Mortem Debug"))
     self.post_mortem_action.setCheckable(True)
     run_settings_menu = QMenu(_("Run settings"), self)
     add_actions(run_settings_menu,
                 (self.interact_action, self.debug_action, self.args_action,
                  self.post_mortem_action))
     self.cwd_button = create_action(self, _("Working directory"),
                             icon=ima.icon('DirOpenIcon'),
                             tip=_("Set current working directory"),
                             triggered=self.set_current_working_directory)
     self.env_button = create_action(self, _("Environment variables"),
                                     icon=ima.icon('environ'),
                                     triggered=self.show_env)
     self.syspath_button = create_action(self,
                                         _("Show sys.path contents"),
                                         icon=ima.icon('syspath'),
                                         triggered=self.show_syspath)
     actions = [run_settings_menu, self.show_time_action, None,
                self.cwd_button, self.env_button, self.syspath_button]
     if self.menu_actions is not None:
         actions += [None]+self.menu_actions
     return actions
Example #4
0
 def get_options_menu(self):
     ExternalShellBase.get_options_menu(self)
     self.interact_action = create_action(self, _("Interact"))
     self.interact_action.setCheckable(True)
     self.debug_action = create_action(self, _("Debug"))
     self.debug_action.setCheckable(True)
     self.args_action = create_action(self, _("Arguments..."),
                                      triggered=self.get_arguments)
     self.post_mortem_action = create_action(self, _("Post Mortem Debug"))
     self.post_mortem_action.setCheckable(True)
     run_settings_menu = QMenu(_("Run settings"), self)
     add_actions(run_settings_menu,
                 (self.interact_action, self.debug_action, self.args_action,
                  self.post_mortem_action))
     self.cwd_button = create_action(self, _("Working directory"),
                             icon=ima.icon('DirOpenIcon'),
                             tip=_("Set current working directory"),
                             triggered=self.set_current_working_directory)
     self.env_button = create_action(self, _("Environment variables"),
                                     icon=ima.icon('environ'),
                                     triggered=self.show_env)
     self.syspath_button = create_action(self,
                                         _("Show sys.path contents"),
                                         icon=ima.icon('syspath'),
                                         triggered=self.show_syspath)
     actions = [run_settings_menu, self.show_time_action, None,
                self.cwd_button, self.env_button, self.syspath_button]
     if self.menu_actions is not None:
         actions += [None]+self.menu_actions
     return actions
Example #5
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None \
        and self.stand_alone is not None:
         self.namespacebrowser_button = create_toolbutton(
             self,
             text=_("Variables"),
             icon=ima.icon('dictedit'),
             tip=_("Show/hide global variables explorer"),
             toggled=self.toggle_globals_explorer,
             text_beside_icon=True)
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(
             self,
             text=_("Terminate"),
             icon=ima.icon('stop'),
             tip=_("Attempts to stop the process. The process\n"
                   "may not exit as a result of clicking this\n"
                   "button (it is given the chance to prompt\n"
                   "the user for any unsaved files, etc)."))
     buttons = []
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [
         self.run_button, self.terminate_button, self.kill_button,
         self.options_button
     ]
     return buttons
Example #6
0
    def __init__(self, parent=None, wdir=None, path=[], light_background=True,
                 menu_actions=None, show_buttons_inside=True,
                 show_elapsed_time=True):
        ExternalShellBase.__init__(self, parent=parent, fname=None, wdir=wdir,
                                   history_filename='.history',
                                   light_background=light_background,
                                   menu_actions=menu_actions,
                                   show_buttons_inside=show_buttons_inside,
                                   show_elapsed_time=show_elapsed_time)

        # Additional python path list
        self.path = path

        # For compatibility with the other shells that can live in the external
        # console
        self.connection_file = None
Example #7
0
 def set_buttons_runnning_state(self, state):
     ExternalShellBase.set_buttons_runnning_state(self, state)
     self.interact_action.setEnabled(not state and not self.is_interpreter)
     self.debug_action.setEnabled(not state and not self.is_interpreter)
     self.args_action.setEnabled(not state and not self.is_interpreter)
     self.post_mortem_action.setEnabled(not state and not self.is_interpreter)
     if state:
         if self.arguments:
             argstr = _("Arguments: %s") % self.arguments
         else:
             argstr = _("No argument")
     else:
         argstr = _("Arguments...")
     self.args_action.setText(argstr)
     self.terminate_button.setVisible(not self.is_interpreter and state)
     if not state:
         self.toggle_globals_explorer(False)
     for btn in (self.cwd_button, self.env_button, self.syspath_button):
         btn.setEnabled(state and self.monitor_enabled)
     if self.namespacebrowser_button is not None:
         self.namespacebrowser_button.setEnabled(state)
Example #8
0
 def get_toolbar_buttons(self):
     ExternalShellBase.get_toolbar_buttons(self)
     if self.namespacebrowser_button is None \
        and self.stand_alone is not None:
         self.namespacebrowser_button = create_toolbutton(self,
               text=_("Variables"), icon=ima.icon('dictedit'),
               tip=_("Show/hide global variables explorer"),
               toggled=self.toggle_globals_explorer, text_beside_icon=True)
     if self.terminate_button is None:
         self.terminate_button = create_toolbutton(self,
               text=_("Terminate"), icon=ima.icon('stop'),
               tip=_("Attempts to stop the process. The process\n"
                     "may not exit as a result of clicking this\n"
                     "button (it is given the chance to prompt\n"
                     "the user for any unsaved files, etc)."))
     buttons = []
     if self.namespacebrowser_button is not None:
         buttons.append(self.namespacebrowser_button)
     buttons += [self.run_button, self.terminate_button, self.kill_button,
                 self.options_button]
     return buttons
Example #9
0
 def set_buttons_runnning_state(self, state):
     ExternalShellBase.set_buttons_runnning_state(self, state)
     self.interact_action.setEnabled(not state and not self.is_interpreter)
     self.debug_action.setEnabled(not state and not self.is_interpreter)
     self.args_action.setEnabled(not state and not self.is_interpreter)
     self.post_mortem_action.setEnabled(not state and not self.is_interpreter)
     if state:
         if self.arguments:
             argstr = _("Arguments: %s") % self.arguments
         else:
             argstr = _("No argument")
     else:
         argstr = _("Arguments...")
     self.args_action.setText(argstr)
     self.terminate_button.setVisible(not self.is_interpreter and state)
     if not state:
         self.toggle_globals_explorer(False)
     for btn in (self.cwd_button, self.env_button, self.syspath_button):
         btn.setEnabled(state and self.monitor_enabled)
     if self.namespacebrowser_button is not None:
         self.namespacebrowser_button.setEnabled(state)
Example #10
0
 def closeEvent(self, event):
     self.quit_monitor()
     ExternalShellBase.closeEvent(self, event)
Example #11
0
    def __init__(self,
                 parent=None,
                 fname=None,
                 wdir=None,
                 interact=False,
                 debug=False,
                 post_mortem=False,
                 path=[],
                 python_args='',
                 arguments='',
                 stand_alone=None,
                 umr_enabled=True,
                 umr_namelist=[],
                 umr_verbose=True,
                 pythonstartup=None,
                 pythonexecutable=None,
                 external_interpreter=False,
                 monitor_enabled=True,
                 mpl_backend=None,
                 ets_backend='qt4',
                 qt_api=None,
                 merge_output_channels=False,
                 colorize_sys_stderr=False,
                 autorefresh_timeout=3000,
                 autorefresh_state=True,
                 light_background=True,
                 menu_actions=None,
                 show_buttons_inside=True,
                 show_elapsed_time=True):

        assert qt_api in (None, 'pyqt', 'pyside', 'pyqt5')

        self.namespacebrowser = None  # namespace browser widget!
        self.dialog_manager = DialogManager()

        self.stand_alone = stand_alone  # stand alone settings (None: plugin)
        self.interact = interact
        self.pythonstartup = pythonstartup
        self.pythonexecutable = pythonexecutable
        self.external_interpreter = external_interpreter
        self.monitor_enabled = monitor_enabled
        self.mpl_backend = mpl_backend
        self.ets_backend = ets_backend
        self.qt_api = qt_api
        self.merge_output_channels = merge_output_channels
        self.colorize_sys_stderr = colorize_sys_stderr
        self.umr_enabled = umr_enabled
        self.umr_namelist = umr_namelist
        self.umr_verbose = umr_verbose
        self.autorefresh_timeout = autorefresh_timeout
        self.autorefresh_state = autorefresh_state

        self.namespacebrowser_button = None
        self.cwd_button = None
        self.env_button = None
        self.syspath_button = None
        self.terminate_button = None

        self.notification_thread = None

        ExternalShellBase.__init__(self,
                                   parent=parent,
                                   fname=fname,
                                   wdir=wdir,
                                   history_filename='history.py',
                                   light_background=light_background,
                                   menu_actions=menu_actions,
                                   show_buttons_inside=show_buttons_inside,
                                   show_elapsed_time=show_elapsed_time)

        if self.pythonexecutable is None:
            self.pythonexecutable = get_python_executable()

        self.python_args = None
        if python_args:
            assert is_text_string(python_args)
            self.python_args = python_args

        assert is_text_string(arguments)
        self.arguments = arguments

        self.connection_file = None
        self.shell.set_externalshell(self)

        self.toggle_globals_explorer(False)
        self.interact_action.setChecked(self.interact)
        self.debug_action.setChecked(debug)

        self.introspection_socket = None
        self.is_interpreter = fname is None

        if self.is_interpreter:
            self.terminate_button.hide()

        self.post_mortem_action.setChecked(post_mortem
                                           and not self.is_interpreter)

        # Additional python path list
        self.path = path
        self.shell.path = path
Example #12
0
 def transcode(self, qba):
     if os.name == 'nt':
         return to_text_string(CP850_CODEC.toUnicode(qba.data()))
     else:
         return ExternalShellBase.transcode(self, qba)
Example #13
0
 def transcode(self, qba):
     if os.name == 'nt':
         return to_text_string( CP850_CODEC.toUnicode(qba.data()) )
     else:
         return ExternalShellBase.transcode(self, qba)
Example #14
0
 def closeEvent(self, event):
     self.quit_monitor()
     ExternalShellBase.closeEvent(self, event)
Example #15
0
    def __init__(self, parent=None, fname=None, wdir=None,
                 interact=False, debug=False, post_mortem=False,
                 path=[], python_args='',
                 ipykernel=False, arguments='', stand_alone=None,
                 umr_enabled=True, umr_namelist=[], umr_verbose=True,
                 pythonstartup=None, pythonexecutable=None,
                 external_interpreter=False,
                 monitor_enabled=True, mpl_backend=None, ets_backend='qt4',
                 qt_api=None, merge_output_channels=False,
                 colorize_sys_stderr=False, autorefresh_timeout=3000,
                 autorefresh_state=True, light_background=True,
                 menu_actions=None, show_buttons_inside=True,
                 show_elapsed_time=True):

        assert qt_api in (None, 'pyqt', 'pyside', 'pyqt5')

        self.namespacebrowser = None # namespace browser widget!
        self.dialog_manager = DialogManager()

        self.stand_alone = stand_alone # stand alone settings (None: plugin)
        self.interact = interact
        self.is_ipykernel = ipykernel
        self.pythonstartup = pythonstartup
        self.pythonexecutable = pythonexecutable
        self.external_interpreter = external_interpreter
        self.monitor_enabled = monitor_enabled
        self.mpl_backend = mpl_backend
        self.ets_backend = ets_backend
        self.qt_api = qt_api
        self.merge_output_channels = merge_output_channels
        self.colorize_sys_stderr = colorize_sys_stderr
        self.umr_enabled = umr_enabled
        self.umr_namelist = umr_namelist
        self.umr_verbose = umr_verbose
        self.autorefresh_timeout = autorefresh_timeout
        self.autorefresh_state = autorefresh_state
                
        self.namespacebrowser_button = None
        self.cwd_button = None
        self.env_button = None
        self.syspath_button = None
        self.terminate_button = None

        self.notification_thread = None
        
        ExternalShellBase.__init__(self, parent=parent, fname=fname, wdir=wdir,
                                   history_filename='history.py',
                                   light_background=light_background,
                                   menu_actions=menu_actions,
                                   show_buttons_inside=show_buttons_inside,
                                   show_elapsed_time=show_elapsed_time)

        if self.pythonexecutable is None:
            self.pythonexecutable = get_python_executable()

        self.python_args = None
        if python_args:
            assert is_text_string(python_args)
            self.python_args = python_args
        
        assert is_text_string(arguments)
        self.arguments = arguments
        
        self.connection_file = None

        if self.is_ipykernel:
            self.interact = False
            # Running our custom startup script for IPython kernels:
            # (see spyder/widgets/externalshell/start_ipython_kernel.py)
            self.fname = get_module_source_path(
                'spyder.widgets.externalshell', 'start_ipython_kernel.py')
        
        self.shell.set_externalshell(self)

        self.toggle_globals_explorer(False)
        self.interact_action.setChecked(self.interact)
        self.debug_action.setChecked(debug)
        
        
        self.introspection_socket = None
        self.is_interpreter = fname is None
        
        if self.is_interpreter:
            self.terminate_button.hide()
            
        self.post_mortem_action.setChecked(post_mortem and not self.is_interpreter)
        
        # Additional python path list
        self.path = path
        self.shell.path = path
Example #16
0
 def finished(self, exit_code, exit_status):
     """Reimplement ExternalShellBase method"""
     if self.is_ipykernel and exit_code == 1:
         self.ipython_kernel_start_error.emit(self.shell.get_text_with_eol())
     ExternalShellBase.finished(self, exit_code, exit_status)
     self.introspection_socket = None
Example #17
0
 def finished(self, exit_code, exit_status):
     """Reimplement ExternalShellBase method"""
     ExternalShellBase.finished(self, exit_code, exit_status)
     self.introspection_socket = None
Example #18
0
 def finished(self, exit_code, exit_status):
     """Reimplement ExternalShellBase method"""
     ExternalShellBase.finished(self, exit_code, exit_status)
     self.introspection_socket = None