예제 #1
0
 def init(cls, parent=None):
     '''
     初始化配置实例
     :param cls:
     :param parent:
     '''
     if not cls.instance:
         cls.instance = QSettings(__config_path__, QSettings.IniFormat, parent)
         cls.instance.setIniCodec(QTextCodec.codecForName('utf-8'))
예제 #2
0
    def finished(self):
        """
        Called when the unit test process has finished.

        This function reads the results and emits `sig_finished`.
        """
        qbytearray = self.process.readAllStandardOutput()
        locale_codec = QTextCodec.codecForLocale()
        output = to_text_string(locale_codec.toUnicode(qbytearray.data()))
        testresults = self.load_data()
        self.sig_finished.emit(testresults, output)
예제 #3
0
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import (create_toolbutton, get_item_user_text,
                                    set_item_user_text)
from spyder.utils.programs import shell_split
from spyder.widgets.comboboxes import PythonModulesComboBox
from spyder.utils.misc import add_pathlist_to_PYTHONPATH, getcwd_or_home
from spyder.widgets.variableexplorer.texteditor import TextEditor

# This is needed for testing this module as a stand alone script
try:
    _ = get_translation("profiler", "spyder_profiler")
except KeyError as error:
    import gettext
    _ = gettext.gettext

locale_codec = QTextCodec.codecForLocale()


def is_profiler_installed():
    from spyder.utils.programs import is_module_installed
    return is_module_installed('cProfile') and is_module_installed('pstats')


class ProfilerWidget(QWidget):
    """
    Profiler widget
    """
    DATAPATH = get_conf_path('profiler.results')
    VERSION = '0.0.1'
    redirect_stdio = Signal(bool)
예제 #4
0
from spyder.utils.encoding import to_unicode_from_fs
from spyder.utils.qthelpers import create_toolbutton
from spyder.widgets.comboboxes import (is_module_or_package,
                                       PythonModulesComboBox)
from spyder.widgets.onecolumntree import OneColumnTree
from spyder.widgets.variableexplorer.texteditor import TextEditor


# This is needed for testing this module as a stand alone script
try:
    _ = get_translation("pylint", "spyder_pylint")
except KeyError as error:
    import gettext
    _ = gettext.gettext

locale_codec = QTextCodec.codecForLocale()
PYLINT_REQVER = '>=0.25'
PYLINT_VER = pylint.__version__
dependencies.add("pylint", _("Static code analysis"),
                 required_version=PYLINT_REQVER, installed_version=PYLINT_VER)


#TODO: display results on 3 columns instead of 1: msg_id, lineno, message
class ResultsTree(OneColumnTree):
    sig_edit_goto = Signal(str, int, str)

    def __init__(self, parent):
        OneColumnTree.__init__(self, parent)
        self.filename = None
        self.results = None
        self.data = None
예제 #5
0
# Third party imports
from qtpy.QtCore import (QByteArray, QProcess, Qt, QTextCodec, QTimer,
                         Signal, Slot)
from qtpy.QtWidgets import (QHBoxLayout, QInputDialog, QLabel, QLineEdit,
                            QMenu, QToolButton, QVBoxLayout, QWidget)

# Local imports
from spyderlib.config.base import _, get_conf_path
from spyderlib.py3compat import is_text_string, to_text_string
from spyderlib.utils import icon_manager as ima
from spyderlib.utils.qthelpers import (add_actions, create_action,
                                       create_toolbutton)


LOCALE_CODEC = QTextCodec.codecForLocale()


def add_pathlist_to_PYTHONPATH(env, pathlist, drop_env=False):
    # PyQt API 1/2 compatibility-related tests:
    assert isinstance(env, list)
    assert all([is_text_string(path) for path in env])
    
    pypath = "PYTHONPATH"
    pathstr = os.pathsep.join(pathlist)
    if os.environ.get(pypath) is not None and not drop_env:
        for index, var in enumerate(env[:]):
            if var.startswith(pypath+'='):
                env[index] = var.replace(pypath+'=',
                                         pypath+'='+pathstr+os.pathsep)
        env.append('OLD_PYTHONPATH='+os.environ[pypath])
예제 #6
0
 def read_all_process_output(self):
     """Read and return all output from `self.process` as unicode."""
     qbytearray = self.process.readAllStandardOutput()
     locale_codec = QTextCodec.codecForLocale()
     return to_text_string(locale_codec.toUnicode(qbytearray.data()))
예제 #7
0
# Third party imports
from qtpy.QtCore import QProcess, QProcessEnvironment, QTextCodec, Signal
from qtpy.QtWidgets import QMessageBox

# Local imports
from spyderlib.config.base import _
from spyderlib.py3compat import is_text_string, to_text_string
from spyderlib.utils import icon_manager as ima
from spyderlib.utils.programs import shell_split
from spyderlib.widgets.externalshell.baseshell import (add_pathlist_to_PYTHONPATH,
                                                       ExternalShellBase)
from spyderlib.widgets.shell import TerminalWidget


LOCALE_CODEC = QTextCodec.codecForLocale()
CP850_CODEC = QTextCodec.codecForName('cp850')


class ExternalSystemShell(ExternalShellBase):
    """External Shell widget: execute Python script in a separate process"""
    SHELL_CLASS = TerminalWidget
    started = Signal()
    
    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,
예제 #8
0
import sys

# Third party imports
from qtpy.QtCore import QProcess, QProcessEnvironment, QTextCodec, Signal
from qtpy.QtWidgets import QMessageBox

# Local imports
from spyder.config.base import _
from spyder.py3compat import is_text_string, to_text_string
from spyder.utils import icon_manager as ima
from spyder.utils.programs import shell_split
from spyder.widgets.externalshell.baseshell import (add_pathlist_to_PYTHONPATH,
                                                    ExternalShellBase)
from spyder.widgets.shell import TerminalWidget

LOCALE_CODEC = QTextCodec.codecForLocale()
CP850_CODEC = QTextCodec.codecForName('cp850')


class ExternalSystemShell(ExternalShellBase):
    """External Shell widget: execute Python script in a separate process"""
    SHELL_CLASS = TerminalWidget
    started = Signal()

    def __init__(self,
                 parent=None,
                 wdir=None,
                 path=[],
                 light_background=True,
                 menu_actions=None,
                 show_buttons_inside=True,
예제 #9
0
 def read_all_process_output(self):
     """Read and return all output from `self.process` as unicode."""
     qbytearray = self.process.readAllStandardOutput()
     locale_codec = QTextCodec.codecForLocale()
     return to_text_string(locale_codec.toUnicode(qbytearray.data()))