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