##// END OF EJS Templates
core: use common bootstrap for pyramid app
marcink -
r2189:bf1dfb34 default
parent child Browse files
Show More
@@ -1,61 +1,59 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
3 # Copyright (C) 2016-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 click
21 import click
22
22
23 from pyramid.paster import bootstrap
23 from rhodecode.lib.pyramid_utils import bootstrap
24 from pyramid.request import Request
25 import pyramid.paster
24 import pyramid.paster
26
25
27 # imports, used in ipython shell
26 # imports, used in ipython shell
28 import os
27 import os
29 import sys
28 import sys
30 import time
29 import time
31 import shutil
30 import shutil
32 import datetime
31 import datetime
33 from rhodecode.model.db import *
32 from rhodecode.model.db import *
34
33
35 welcome_banner = """Welcome to RhodeCode iShell.
34 welcome_banner = """Welcome to RhodeCode iShell.
36 Type `exit` to exit the shell.
35 Type `exit` to exit the shell.
37 iShell is interactive shell to interact directly with the
36 iShell is interactive shell to interact directly with the
38 internal RhodeCode APIs. You can rescue your lost password,
37 internal RhodeCode APIs. You can rescue your lost password,
39 or reset some user/system settings.
38 or reset some user/system settings.
40 """
39 """
41
40
42
41
43 @click.command()
42 @click.command()
44 @click.argument('ini_path', type=click.Path(exists=True))
43 @click.argument('ini_path', type=click.Path(exists=True))
45 def main(ini_path):
44 def main(ini_path):
46 pyramid.paster.setup_logging(ini_path)
45 pyramid.paster.setup_logging(ini_path)
47
46
48 request = Request.blank('/', base_url='https://rhodecode-app.com/')
47 with bootstrap(ini_path) as env:
49 with bootstrap(ini_path, request=request) as env:
50
48
51 try:
49 try:
52 from IPython import embed
50 from IPython import embed
53 from traitlets.config import Config
51 from traitlets.config import Config
54 cfg = Config()
52 cfg = Config()
55 cfg.InteractiveShellEmbed.confirm_exit = False
53 cfg.InteractiveShellEmbed.confirm_exit = False
56 embed(config=cfg, banner1=welcome_banner)
54 embed(config=cfg, banner1=welcome_banner)
57 except ImportError:
55 except ImportError:
58 print('ipython installation required for ishell')
56 print('ipython installation required for ishell')
59 sys.exit(-1)
57 sys.exit(-1)
60
58
61
59
@@ -1,35 +1,33 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
3 # Copyright (C) 2016-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 click
21 import click
22
22
23 from pyramid.paster import bootstrap
23 from rhodecode.lib.pyramid_utils import bootstrap
24 from pyramid.request import Request
25 import pyramid.paster
24 import pyramid.paster
26
25
27
26
28 @click.command()
27 @click.command()
29 @click.argument('ini_path', type=click.Path(exists=True))
28 @click.argument('ini_path', type=click.Path(exists=True))
30 def main(ini_path):
29 def main(ini_path):
31 pyramid.paster.setup_logging(ini_path)
30 pyramid.paster.setup_logging(ini_path)
32
31
33 request = Request.blank('/', base_url='https://rhodecode-app.com/')
32 with bootstrap(ini_path) as env:
34 with bootstrap(ini_path, request=request) as env:
35 print(env['request'].application_url) No newline at end of file
33 print(env['request'].application_url)
@@ -1,37 +1,35 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
3 # Copyright (C) 2016-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 click
21 import click
22
22
23 from pyramid.paster import bootstrap
23 from rhodecode.lib.pyramid_utils import bootstrap
24 from pyramid.request import Request
25 import pyramid.paster
24 import pyramid.paster
26
25
27
26
28 @click.command()
27 @click.command()
29 @click.argument('ini_path', type=click.Path(exists=True))
28 @click.argument('ini_path', type=click.Path(exists=True))
30 def main(ini_path):
29 def main(ini_path):
31 pyramid.paster.setup_logging(ini_path)
30 pyramid.paster.setup_logging(ini_path)
32
31
33 request = Request.blank('/', base_url='https://rhodecode-app.com/')
32 with bootstrap(ini_path) as env:
34 with bootstrap(ini_path, request=request) as env:
35 print(env['request'].application_url)
33 print(env['request'].application_url)
36
34
37
35
General Comments 0
You need to be logged in to leave comments. Login now