Mercurial > kallithea
annotate rhodecode/lib/paster_commands/setup_rhodecode.py @ 3834:2ad55d8ba11d beta
remove +x from README.rst
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 09 May 2013 22:51:53 +0200 |
parents | f1491bad8339 |
children | a42bfe8a9335 |
rev | line source |
---|---|
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import os |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
2 import sys |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 from paste.script.appinstall import AbstractInstallCommand |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from paste.script.command import BadCommand |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 from paste.deploy import appconfig |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
7 from os.path import dirname as dn, join as jn |
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
8 #to get the rhodecode import |
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
9 rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
10 sys.path.append(rc_path) |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
12 |
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
13 class Command(AbstractInstallCommand): |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 default_verbosity = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 max_args = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 min_args = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 summary = "Setup an application, given a config file" |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 usage = "CONFIG_FILE" |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
20 group_name = "RhodeCode" |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 description = """\ |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
24 Setup RhodeCode according to its configuration file. This is |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 the second part of a two-phase web application installation |
3340
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
26 process (the first phase is prepare-app). The setup process |
f1491bad8339
unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents:
2919
diff
changeset
|
27 consist of things like setting up databases, creating super user |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 """ |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 parser = AbstractInstallCommand.standard_parser( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 simulate=True, quiet=True, interactive=True) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 parser.add_option('--user', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 dest='username', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 help='Admin Username') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 parser.add_option('--email', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 dest='email', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 help='Admin Email') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 parser.add_option('--password', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 dest='password', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 help='Admin password min 6 chars') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 parser.add_option('--repos', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 dest='repos_location', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 help='Absolute path to repositories location') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 parser.add_option('--name', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 dest='section_name', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 help='The name of the section to set up (default: app:main)') |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
57 parser.add_option('--force-yes', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
58 action='store_true', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
59 dest='force_ask', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
60 default=None, |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
61 help='Force yes to every question') |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
62 parser.add_option('--force-no', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
63 action='store_false', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
64 dest='force_ask', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
65 default=None, |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
66 help='Force no to every question') |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 def command(self): |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 config_spec = self.args[0] |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 section = self.options.section_name |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 if section is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 if '#' in config_spec: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 config_spec, section = config_spec.split('#', 1) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 else: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 section = 'main' |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 if not ':' in section: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 plain_section = section |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
78 section = 'app:' + section |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 else: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 plain_section = section.split(':', 1)[0] |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 if not config_spec.startswith('config:'): |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 config_spec = 'config:' + config_spec |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 if plain_section != 'main': |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 config_spec += '#' + plain_section |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 config_file = config_spec[len('config:'):].split('#', 1)[0] |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 config_file = os.path.join(os.getcwd(), config_file) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 self.logging_file_config(config_file) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
88 conf = appconfig(config_spec, relative_to=os.getcwd()) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 ep_name = conf.context.entry_point_name |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 ep_group = conf.context.protocol |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 dist = conf.context.distribution |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
92 if dist is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 raise BadCommand( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
94 "The section %r is not the application (probably a filter). " |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 "You should add #section_name, where section_name is the " |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 "section that configures your application" % plain_section) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 installer = self.get_installer(dist, ep_group, ep_name) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 installer.setup_config( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 self, config_file, section, self.sysconfig_install_vars(installer)) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 self.call_sysconfig_functions( |
2289
5893414dea91
renamed setup module into a setup_rhodecode.
Marcin Kuzminski <marcin@python-works.com>
parents:
2284
diff
changeset
|
101 'post_setup_hook', installer, config_file) |