~ubuntu-branches/ubuntu/trusty/spyder/trusty-proposed

« back to all changes in this revision

Viewing changes to spyderlib/plugins/externalconsole.py

  • Committer: Package Import Robot
  • Author(s): Picca Frédéric-Emmanuel
  • Date: 2013-10-19 20:28:21 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20131019202821-chk2umz8ybzzvy7b
Tags: 2.2.5+dfsg-1
* fix the copyright file with more upstream information
* Imported Upstream version 2.2.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import sys
28
28
 
29
29
# Local imports
30
 
from spyderlib.baseconfig import _, SCIENTIFIC_STARTUP, SUPPORTED_IPYTHON
 
30
from spyderlib.baseconfig import _, SCIENTIFIC_STARTUP
 
31
from spyderlib.ipythonconfig import SUPPORTED_IPYTHON
31
32
from spyderlib.config import CONF
32
33
from spyderlib.utils import programs
33
34
from spyderlib.utils.misc import (get_error_match, get_python_executable,
53
54
        return False
54
55
 
55
56
 
56
 
def scientific_libs_available(interpreter):
57
 
    """
58
 
    Return True if numpy, scipy and matplotlib are installed in interpreter
59
 
    """
60
 
    mods = ['numpy', 'scipy', 'matplotlib']
61
 
    check_mods = [programs.is_module_installed(m, interpreter=interpreter) \
62
 
                  for m in mods]
63
 
    return all(check_mods)
64
 
 
65
 
 
66
57
class ExternalConsoleConfigPage(PluginConfigPage):
67
58
    def __init__(self, plugin, parent):
68
59
        PluginConfigPage.__init__(self, plugin, parent)
441
432
        vlayout.addWidget(tabs)
442
433
        self.setLayout(vlayout)
443
434
 
444
 
    def _auto_switch_startup_script(self, pyexec):
445
 
        """Switch automatically from the scientific startup to the default 
446
 
        startup script if scientific libs aren't available with selected 
447
 
        Python executable"""
448
 
        if self.cus_startup_radio.isChecked() and\
449
 
           not scientific_libs_available(pyexec):
450
 
            self.def_startup_radio.setChecked(True)
451
 
            self.cus_startup_radio.setChecked(False)
452
 
 
453
435
    def _auto_change_qt_api(self, pyexec):
454
436
        """Change automatically Qt API depending on
455
437
        selected Python executable"""
474
456
        old_pyexec = self.get_option("pythonexecutable",
475
457
                                     get_python_executable())
476
458
        if pyexec != old_pyexec:
477
 
            self._auto_switch_startup_script(pyexec)
478
459
            self._auto_change_qt_api(pyexec)
479
460
 
480
461
    def python_executable_switched(self, custom):
485
466
            cust_pyexec = unicode(cust_pyexec.toUtf8(), 'utf-8')
486
467
        if def_pyexec != cust_pyexec:
487
468
            pyexec = cust_pyexec if custom else def_pyexec
488
 
            self._auto_switch_startup_script(pyexec)
489
469
            self._auto_change_qt_api(pyexec)
490
470
 
491
471
 
520
500
            executable = get_python_executable()
521
501
 
522
502
        # Python startup file selection
523
 
        if self.get_option('pythonstartup/default', None) is None:
524
 
            scientific = scientific_libs_available(executable)
525
 
            self.set_option('pythonstartup/default', not scientific)
526
503
        if not osp.isfile(self.get_option('pythonstartup', '')):
527
 
            scientific = scientific_libs_available(executable)
528
504
            self.set_option('pythonstartup', SCIENTIFIC_STARTUP)
529
 
            self.set_option('pythonstartup/default', not scientific)
530
505
        # default/custom settings are mutually exclusive:
531
506
        self.set_option('pythonstartup/custom',
532
 
                        not self.get_option('pythonstartup/default'))
 
507
                        not self.get_option('pythonstartup/default', False))
533
508
        
534
509
        if not osp.isfile(executable):
535
510
            # This is absolutely necessary, in case the Python interpreter
815
790
                pythonexecutable = get_python_executable()
816
791
            else:
817
792
                pythonexecutable = self.get_option('pythonexecutable')
818
 
            if self.get_option('pythonstartup/default', True):
 
793
            if self.get_option('pythonstartup/default', True) or ipykernel:
819
794
                pythonstartup = None
820
795
            else:
821
796
                pythonstartup = self.get_option('pythonstartup', None)
841
816
            umd_verbose = self.get_option('umd/verbose')
842
817
            ar_timeout = CONF.get('variable_explorer', 'autorefresh/timeout')
843
818
            ar_state = CONF.get('variable_explorer', 'autorefresh')
 
819
 
 
820
            # CRUCIAL NOTE FOR IPYTHON KERNELS:
 
821
            # autorefresh needs to be on so that our monitor
 
822
            # can find __ipythonkernel__ in the globals namespace
 
823
            # *after* the kernel has been started.
 
824
            # Without the ns refresh provided by autorefresh, a
 
825
            # client is *never* started (although the kernel is)
 
826
            # Fix Issue 1595
 
827
            if not ar_state and ipykernel:
 
828
                ar_state = True
 
829
 
844
830
            if self.light_mode:
845
831
                from spyderlib.plugins.variableexplorer import VariableExplorer
846
832
                sa_settings = VariableExplorer.get_settings()