Show More
@@ -1,73 +1,80 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2013-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2013-2016 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 | """ |
|
21 | """ | |
22 | interactive shell paster command for RhodeCode |
|
22 | interactive shell paster command for RhodeCode | |
23 | """ |
|
23 | """ | |
24 |
|
24 | |||
25 | import os |
|
25 | import os | |
26 | import sys |
|
26 | import sys | |
27 | import logging |
|
27 | import logging | |
28 |
|
28 | |||
29 | from rhodecode.lib.utils import BasePasterCommand |
|
29 | from rhodecode.lib.utils import BasePasterCommand | |
30 |
|
30 | |||
31 | # fix rhodecode import |
|
31 | # fix rhodecode import | |
32 | from os.path import dirname as dn |
|
32 | from os.path import dirname as dn | |
33 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
33 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
34 | sys.path.append(rc_path) |
|
34 | sys.path.append(rc_path) | |
35 |
|
35 | |||
36 | log = logging.getLogger(__name__) |
|
36 | log = logging.getLogger(__name__) | |
37 |
|
37 | |||
|
38 | welcome_banner = """Welcome to RhodeCode iShell. | |||
|
39 | Type `exit` to exit the shell. | |||
|
40 | iShell is interactive shell to interact directly with the | |||
|
41 | internal RhodeCode APIs. You can rescue your lost password, | |||
|
42 | or reset some user/system settings. | |||
|
43 | """ | |||
|
44 | ||||
38 |
|
45 | |||
39 | class Command(BasePasterCommand): |
|
46 | class Command(BasePasterCommand): | |
40 |
|
47 | |||
41 | max_args = 1 |
|
48 | max_args = 1 | |
42 | min_args = 1 |
|
49 | min_args = 1 | |
43 |
|
50 | |||
44 | usage = "CONFIG_FILE" |
|
51 | usage = "CONFIG_FILE" | |
45 | group_name = "RhodeCode" |
|
52 | group_name = "RhodeCode" | |
46 | takes_config_file = -1 |
|
53 | takes_config_file = -1 | |
47 | parser = BasePasterCommand.standard_parser(verbose=True) |
|
54 | parser = BasePasterCommand.standard_parser(verbose=True) | |
48 | summary = "Interactive shell" |
|
55 | summary = "Interactive shell" | |
49 |
|
56 | |||
50 | def command(self): |
|
57 | def command(self): | |
51 | #get SqlAlchemy session |
|
58 | #get SqlAlchemy session | |
52 | self._init_session() |
|
59 | self._init_session() | |
53 |
|
60 | |||
54 | # imports, used in ipython shell |
|
61 | # imports, used in ipython shell | |
55 | import os |
|
62 | import os | |
56 | import sys |
|
63 | import sys | |
57 | import time |
|
64 | import time | |
58 | import shutil |
|
65 | import shutil | |
59 | import datetime |
|
66 | import datetime | |
60 | from rhodecode.model.db import * |
|
67 | from rhodecode.model.db import * | |
61 |
|
68 | |||
62 | try: |
|
69 | try: | |
63 | from IPython import embed |
|
70 | from IPython import embed | |
64 |
from |
|
71 | from traitlets.config import Config | |
65 | cfg = Config() |
|
72 | cfg = Config() | |
66 | cfg.InteractiveShellEmbed.confirm_exit = False |
|
73 | cfg.InteractiveShellEmbed.confirm_exit = False | |
67 |
embed(config=cfg, banner1= |
|
74 | embed(config=cfg, banner1=welcome_banner) | |
68 | except ImportError: |
|
75 | except ImportError: | |
69 |
print |
|
76 | print('ipython installation required for ishell') | |
70 | sys.exit(-1) |
|
77 | sys.exit(-1) | |
71 |
|
78 | |||
72 | def update_parser(self): |
|
79 | def update_parser(self): | |
73 | pass |
|
80 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now