Mercurial > kallithea
annotate kallithea/lib/paster_commands/ishell.py @ 5998:037efd94e955
cleanup: get rid of dn as shortcut for os.path.dirname
We keep 'dirname' as shortcut despite having removed the 'join' shortcut:
* the name is less ambiguous than 'join'.
* dirname is often applied multiple times - spelling it out would be too
verbose.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Mon, 13 Jun 2016 21:39:47 +0200 |
parents | 624d57352745 |
children | e0f31c7d0f5e |
rev | line source |
---|---|
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 # (at your option) any later version. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 # |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 # GNU General Public License for more details. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 # |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
14 """ |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4175
diff
changeset
|
15 kallithea.lib.paster_commands.ishell |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
17 |
4212
24c0d584ba86
General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4211
diff
changeset
|
18 interactive shell paster command for Kallithea |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
19 |
4211
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
20 This file was forked by the Kallithea project in July 2014. |
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
21 Original author and date, and relevant copyright and licensing information is below: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
22 :created_on: Apr 4, 2013 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
23 :author: marcink |
4211
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
24 :copyright: (c) 2013 RhodeCode GmbH, and others. |
4208
ad38f9f93b3b
Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
25 :license: GPLv3, see LICENSE.md for more details. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
26 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3915
diff
changeset
|
27 |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 import os |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 import sys |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4175
diff
changeset
|
32 from kallithea.lib.utils import BasePasterCommand |
3915
a42bfe8a9335
moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents:
3663
diff
changeset
|
33 |
4175
e9f6b533a8f6
Remove wrong/unnecessary/unfixable comment(s)
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
34 # Add location of top level folder to sys.path |
5998
037efd94e955
cleanup: get rid of dn as shortcut for os.path.dirname
domruf <dominikruf@gmail.com>
parents:
5597
diff
changeset
|
35 from os.path import dirname |
037efd94e955
cleanup: get rid of dn as shortcut for os.path.dirname
domruf <dominikruf@gmail.com>
parents:
5597
diff
changeset
|
36 rc_path = dirname(dirname(dirname(os.path.realpath(__file__)))) |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 sys.path.append(rc_path) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 class Command(BasePasterCommand): |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 max_args = 1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 min_args = 1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 usage = "CONFIG_FILE" |
4212
24c0d584ba86
General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4211
diff
changeset
|
46 group_name = "Kallithea" |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 takes_config_file = -1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 parser = BasePasterCommand.standard_parser(verbose=True) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 summary = "Interactive shell" |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 def command(self): |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 #get SqlAlchemy session |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 self._init_session() |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
5597
624d57352745
paster: minor changes to paster commands, making them slightly more consistent
Mads Kiilerich <madski@unity3d.com>
parents:
5474
diff
changeset
|
55 # imports, used in IPython shell |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 import os |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 import sys |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 import time |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 import shutil |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 import datetime |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4175
diff
changeset
|
61 from kallithea.model.db import * |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 try: |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 from IPython import embed |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 from IPython.config.loader import Config |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 cfg = Config() |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 cfg.InteractiveShellEmbed.confirm_exit = False |
4212
24c0d584ba86
General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4211
diff
changeset
|
68 embed(config=cfg, banner1="Kallithea IShell.") |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 except ImportError: |
5597
624d57352745
paster: minor changes to paster commands, making them slightly more consistent
Mads Kiilerich <madski@unity3d.com>
parents:
5474
diff
changeset
|
70 print 'IPython installation is required for ishell' |
3663
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 sys.exit(-1) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 def update_parser(self): |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 pass |