annotate kallithea/lib/paster_commands/ishell.py @ 4212:24c0d584ba86 kallithea-2.2.5-rebrand

General renaming to Kallithea
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:06:01 -0400
parents 1948ede028ef
children 431689d7f37d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 from __future__ import with_statement
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import os
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 import sys
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 import logging
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4175
diff changeset
34 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
35
4175
e9f6b533a8f6 Remove wrong/unnecessary/unfixable comment(s)
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
36 # Add location of top level folder to sys.path
3915
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3663
diff changeset
37 from os.path import dirname as dn
3663
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 rc_path = dn(dn(dn(os.path.realpath(__file__))))
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 sys.path.append(rc_path)
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 log = logging.getLogger(__name__)
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 class Command(BasePasterCommand):
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 max_args = 1
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 min_args = 1
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 usage = "CONFIG_FILE"
4212
24c0d584ba86 General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4211
diff changeset
50 group_name = "Kallithea"
3663
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 takes_config_file = -1
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 parser = BasePasterCommand.standard_parser(verbose=True)
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 summary = "Interactive shell"
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 def command(self):
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 #get SqlAlchemy session
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 self._init_session()
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 # imports, used in ipython shell
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 import os
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 import sys
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 import time
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 import shutil
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 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
65 from kallithea.model.db import *
3663
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 try:
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 from IPython import embed
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 from IPython.config.loader import Config
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 cfg = Config()
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 cfg.InteractiveShellEmbed.confirm_exit = False
4212
24c0d584ba86 General renaming to Kallithea
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4211
diff changeset
72 embed(config=cfg, banner1="Kallithea IShell.")
3663
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 except ImportError:
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 print 'ipython installation required for ishell'
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 sys.exit(-1)
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 def update_parser(self):
44d173a8136f ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 pass