##// END OF EJS Templates
core: expose pshell as ipython with RhodeCode imports....
marcink -
r2006:f730a999 default
parent child Browse files
Show More
@@ -0,0 +1,67 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 """
22 interactive shell for pyramid
23 """
24
25 import os
26 import sys
27 import logging
28
29 # fix rhodecode import
30 from os.path import dirname as dn
31 rc_path = dn(dn(dn(os.path.realpath(__file__))))
32 sys.path.append(rc_path)
33
34 log = logging.getLogger(__name__)
35
36 welcome_banner = """Welcome to RhodeCode iShell.\n
37 Type `exit` to exit the shell.
38 iShell is interactive shell to interact directly with the
39 internal RhodeCode APIs. You can rescue your lost password,
40 or reset some user/system settings.
41 """
42
43
44 def ipython_shell_runner(env, help):
45
46 # imports, used in ipython shell
47 import os
48 import sys
49 import time
50 import shutil
51 import datetime
52 from rhodecode.model import user, user_group, repo, repo_group
53 from rhodecode.model.db import *
54
55 try:
56 import IPython
57 from traitlets.config import Config
58
59 cfg = Config()
60 cfg.InteractiveShellEmbed.confirm_exit = False
61 cfg.TerminalInteractiveShell.banner2 = \
62 welcome_banner + '\n' + help + '\n'
63 IPython.start_ipython(argv=[], user_ns=env, config=cfg)
64
65 except ImportError:
66 print('ipython installation required for ishell')
67 sys.exit(-1)
@@ -240,6 +240,9 b' setup('
240 240 'upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb',
241 241 'celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand',
242 242 ],
243 'pyramid.pshell_runner': [
244 'ipython = rhodecode.lib.pyramid_shell:ipython_shell_runner',
245 ],
243 246 'pytest11': [
244 247 'pylons=rhodecode.tests.pylons_plugin',
245 248 'enterprise=rhodecode.tests.plugin',
General Comments 0
You need to be logged in to leave comments. Login now