view kallithea/lib/paster_commands/ishell.py @ 7369:cc2f0cfd7867

ishell: specify ipython minimum version 4 `gearbox ishell` has an "optional" dependency on ipython as it fails with: Kallithea ishell requires the IPython Python package Before the previous change, after installing ipython < 4, it would however still fail the same way. With the previous change, it would fail in a slightly more helpful way with: ImportError: No module named traitlets.config.loader With ipython < 4, after installing the missing traitlets (4.3.2) as hinted, ishell still failed with: TraitError: The 'config' trait of an InteractiveShellEmbed instance must be a Config or None, but a value of class 'traitlets.config.loader.Config' (i.e. {'InteractiveShellEmbed': {'confirm_exit': False}}) was specified. With ipython >= 4, traitlets is installed as dependency, and ishell works. Tested with both ipython 4.0 and current latest version 5.8 . Thus, just clarify that we only support ipython >= 4 .
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 01 Sep 2018 02:08:15 +0200
parents e44954828c9a
children
line wrap: on
line source

# -*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
kallithea.lib.paster_commands.ishell
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

interactive shell gearbox command for Kallithea

This file was forked by the Kallithea project in July 2014.
Original author and date, and relevant copyright and licensing information is below:
:created_on: Apr 4, 2013
:author: marcink
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""


import sys

# imports, used in IPython shell
import time
import shutil
import datetime
from kallithea.model.db import *

from kallithea.lib.paster_commands.common import BasePasterCommand


class Command(BasePasterCommand):
    "Kallithea: Interactive Python shell"

    def take_action(self, args):
        try:
            from IPython import embed
        except ImportError:
            print 'Kallithea ishell requires the Python package IPython 4 or later'
            sys.exit(-1)
        from traitlets.config.loader import Config
        cfg = Config()
        cfg.InteractiveShellEmbed.confirm_exit = False
        embed(config=cfg, banner1="Kallithea IShell.")