##// 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)
@@ -1,255 +1,258 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 # Import early to make sure things are patched up properly
22 22 from setuptools import setup, find_packages
23 23
24 24 import os
25 25 import sys
26 26 import pkgutil
27 27 import platform
28 28
29 29 from pip.download import PipSession
30 30 from pip.req import parse_requirements
31 31
32 32 from codecs import open
33 33
34 34
35 35 if sys.version_info < (2, 7):
36 36 raise Exception('RhodeCode requires Python 2.7 or later')
37 37
38 38 here = os.path.abspath(os.path.dirname(__file__))
39 39
40 40 # defines current platform
41 41 __platform__ = platform.system()
42 42 __license__ = 'AGPLv3, and Commercial License'
43 43 __author__ = 'RhodeCode GmbH'
44 44 __url__ = 'https://code.rhodecode.com'
45 45 is_windows = __platform__ in ('Windows',)
46 46
47 47
48 48 def _get_requirements(req_filename, exclude=None, extras=None):
49 49 extras = extras or []
50 50 exclude = exclude or []
51 51
52 52 try:
53 53 parsed = parse_requirements(
54 54 os.path.join(here, req_filename), session=PipSession())
55 55 except TypeError:
56 56 # try pip < 6.0.0, that doesn't support session
57 57 parsed = parse_requirements(os.path.join(here, req_filename))
58 58
59 59 requirements = []
60 60 for ir in parsed:
61 61 if ir.req and ir.name not in exclude:
62 62 requirements.append(str(ir.req))
63 63 return requirements + extras
64 64
65 65
66 66 # requirements extract
67 67 setup_requirements = ['PasteScript', 'pytest-runner']
68 68 install_requirements = _get_requirements(
69 69 'requirements.txt', exclude=['setuptools'])
70 70 test_requirements = _get_requirements(
71 71 'requirements_test.txt', extras=['configobj'])
72 72
73 73 install_requirements = [
74 74 'Babel',
75 75 'Beaker',
76 76 'FormEncode',
77 77 'Mako',
78 78 'Markdown',
79 79 'MarkupSafe',
80 80 'MySQL-python',
81 81 'Paste',
82 82 'PasteDeploy',
83 83 'PasteScript',
84 84 'Pygments',
85 85 'pygments-markdown-lexer',
86 86 'Pylons',
87 87 'Routes',
88 88 'SQLAlchemy',
89 89 'Tempita',
90 90 'URLObject',
91 91 'WebError',
92 92 'WebHelpers',
93 93 'WebHelpers2',
94 94 'WebOb',
95 95 'WebTest',
96 96 'Whoosh',
97 97 'alembic',
98 98 'amqplib',
99 99 'anyjson',
100 100 'appenlight-client',
101 101 'authomatic',
102 102 'cssselect',
103 103 'celery',
104 104 'channelstream',
105 105 'colander',
106 106 'decorator',
107 107 'deform',
108 108 'docutils',
109 109 'gevent',
110 110 'gunicorn',
111 111 'infrae.cache',
112 112 'ipython',
113 113 'iso8601',
114 114 'kombu',
115 115 'lxml',
116 116 'msgpack-python',
117 117 'nbconvert',
118 118 'packaging',
119 119 'psycopg2',
120 120 'py-gfm',
121 121 'pycrypto',
122 122 'pycurl',
123 123 'pyparsing',
124 124 'pyramid',
125 125 'pyramid-debugtoolbar',
126 126 'pyramid-mako',
127 127 'pyramid-beaker',
128 128 'pysqlite',
129 129 'python-dateutil',
130 130 'python-ldap',
131 131 'python-memcached',
132 132 'python-pam',
133 133 'recaptcha-client',
134 134 'repoze.lru',
135 135 'requests',
136 136 'simplejson',
137 137 'sshpubkeys',
138 138 'subprocess32',
139 139 'waitress',
140 140 'zope.cachedescriptors',
141 141 'dogpile.cache',
142 142 'dogpile.core',
143 143 'psutil',
144 144 'py-bcrypt',
145 145 ]
146 146
147 147
148 148 def get_version():
149 149 version = pkgutil.get_data('rhodecode', 'VERSION')
150 150 return version.strip()
151 151
152 152
153 153 # additional files that goes into package itself
154 154 package_data = {
155 155 '': ['*.txt', '*.rst'],
156 156 'configs': ['*.ini'],
157 157 'rhodecode': ['VERSION', 'i18n/*/LC_MESSAGES/*.mo', ],
158 158 }
159 159
160 160 description = 'Source Code Management Platform'
161 161 keywords = ' '.join([
162 162 'rhodecode', 'mercurial', 'git', 'svn',
163 163 'code review',
164 164 'repo groups', 'ldap', 'repository management', 'hgweb',
165 165 'hgwebdir', 'gitweb', 'serving hgweb',
166 166 ])
167 167
168 168
169 169 # README/DESCRIPTION generation
170 170 readme_file = 'README.rst'
171 171 changelog_file = 'CHANGES.rst'
172 172 try:
173 173 long_description = open(readme_file).read() + '\n\n' + \
174 174 open(changelog_file).read()
175 175 except IOError as err:
176 176 sys.stderr.write(
177 177 "[WARNING] Cannot find file specified as long_description (%s)\n "
178 178 "or changelog (%s) skipping that file" % (readme_file, changelog_file))
179 179 long_description = description
180 180
181 181
182 182 setup(
183 183 name='rhodecode-enterprise-ce',
184 184 version=get_version(),
185 185 description=description,
186 186 long_description=long_description,
187 187 keywords=keywords,
188 188 license=__license__,
189 189 author=__author__,
190 190 author_email='marcin@rhodecode.com',
191 191 url=__url__,
192 192 setup_requires=setup_requirements,
193 193 install_requires=install_requirements,
194 194 tests_require=test_requirements,
195 195 zip_safe=False,
196 196 packages=find_packages(exclude=["docs", "tests*"]),
197 197 package_data=package_data,
198 198 include_package_data=True,
199 199 classifiers=[
200 200 'Development Status :: 6 - Mature',
201 201 'Environment :: Web Environment',
202 202 'Intended Audience :: Developers',
203 203 'Operating System :: OS Independent',
204 204 'Topic :: Software Development :: Version Control',
205 205 'License :: OSI Approved :: Affero GNU General Public License v3 or later (AGPLv3+)',
206 206 'Programming Language :: Python :: 2.7',
207 207 ],
208 208 message_extractors={
209 209 'rhodecode': [
210 210 ('**.py', 'python', None),
211 211 ('**.js', 'javascript', None),
212 212 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
213 213 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
214 214 ('public/**', 'ignore', None),
215 215 ]
216 216 },
217 217 paster_plugins=['PasteScript', 'Pylons'],
218 218 entry_points={
219 219 'enterprise.plugins1': [
220 220 'crowd=rhodecode.authentication.plugins.auth_crowd:plugin_factory',
221 221 'headers=rhodecode.authentication.plugins.auth_headers:plugin_factory',
222 222 'jasig_cas=rhodecode.authentication.plugins.auth_jasig_cas:plugin_factory',
223 223 'ldap=rhodecode.authentication.plugins.auth_ldap:plugin_factory',
224 224 'pam=rhodecode.authentication.plugins.auth_pam:plugin_factory',
225 225 'rhodecode=rhodecode.authentication.plugins.auth_rhodecode:plugin_factory',
226 226 'token=rhodecode.authentication.plugins.auth_token:plugin_factory',
227 227 ],
228 228 'paste.app_factory': [
229 229 'main=rhodecode.config.middleware:make_pyramid_app',
230 230 'pylons=rhodecode.config.middleware:make_app',
231 231 ],
232 232 'paste.app_install': [
233 233 'main=pylons.util:PylonsInstaller',
234 234 'pylons=pylons.util:PylonsInstaller',
235 235 ],
236 236 'paste.global_paster_command': [
237 237 'make-config=rhodecode.lib.paster_commands.make_config:Command',
238 238 'setup-rhodecode=rhodecode.lib.paster_commands.setup_rhodecode:Command',
239 239 'ishell=rhodecode.lib.paster_commands.ishell:Command',
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',
246 249 ],
247 250 'console_scripts': [
248 251 'rcserver=rhodecode.rcserver:main',
249 252 ],
250 253 'beaker.backends': [
251 254 'memorylru_base=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerBase',
252 255 'memorylru_debug=rhodecode.lib.memory_lru_debug:MemoryLRUNamespaceManagerDebug'
253 256 ]
254 257 },
255 258 )
General Comments 0
You need to be logged in to leave comments. Login now