Mercurial > kallithea
annotate rhodecode/lib/paster_commands/ishell.py @ 3774:60335b702a00 beta
invalidation: don't create CacheInvalidation records on startup
Creating the records early gave an advantage before lightweight was introduced.
With lightweight it is no longer necessary.
The records will be created on demand anyway and there is no reason to create and
maintain them before they are used.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 03 Apr 2013 15:56:12 +0200 |
parents | 44d173a8136f |
children | a42bfe8a9335 |
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 """ |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.lib.paster_commands.ishell |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 interactive shell paster command for RhodeCode |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :created_on: Apr 4, 2013 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :author: marcink |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com> |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 :license: GPLv3, see COPYING for more details. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 """ |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # 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
|
15 # 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
|
16 # the Free Software Foundation, either version 3 of the License, or |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # (at your option) any later version. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # 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
|
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # GNU General Public License for more details. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # 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
|
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 from __future__ import with_statement |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 import os |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 import sys |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 import logging |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from os.path import dirname as dn, join as jn |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 #to get the rhodecode import |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 sys.path.append(rc_path) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 from rhodecode.lib.utils import BasePasterCommand |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
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 log = logging.getLogger(__name__) |
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 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 class Command(BasePasterCommand): |
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 max_args = 1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 min_args = 1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 usage = "CONFIG_FILE" |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 group_name = "RhodeCode" |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 takes_config_file = -1 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 parser = BasePasterCommand.standard_parser(verbose=True) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 summary = "Interactive shell" |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 def command(self): |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 #get SqlAlchemy session |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 self._init_session() |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 # imports, used in ipython shell |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 import os |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 import sys |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 import time |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 import shutil |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 import datetime |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 from rhodecode.model.db import * |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 try: |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 from IPython import embed |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 from IPython.config.loader import Config |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 cfg = Config() |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 cfg.InteractiveShellEmbed.confirm_exit = False |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 embed(config=cfg, banner1="RhodeCode IShell.") |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 except ImportError: |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 print 'ipython installation required for ishell' |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 sys.exit(-1) |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 def update_parser(self): |
44d173a8136f
ishell paster command
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 pass |