Mercurial > kallithea
annotate rhodecode/config/setup_rhodecode.py @ 3201:663f4f26776a beta
html: don't hardcode uppercase texts
_If_ we want uppercase then it should be done in css.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 22 Jan 2013 23:44:38 +0100 |
parents | 29630805893d |
children |
rev | line source |
---|---|
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import os |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 from paste.script.appinstall import AbstractInstallCommand |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 from paste.script.command import BadCommand |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from paste.deploy import appconfig |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 class SetupCommand(AbstractInstallCommand): |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 default_verbosity = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 max_args = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 min_args = 1 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 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
|
13 usage = "CONFIG_FILE" |
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 description = """\ |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 Note: this is an experimental command, and it will probably change |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 in several ways by the next release. |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 Setup an application according to its configuration file. This is |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 the second part of a two-phase web application installation |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 process (the first phase is prepare-app). The setup process may |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 consist of things like creating directories and setting up |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 databases. |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 """ |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 parser = AbstractInstallCommand.standard_parser( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 simulate=True, quiet=True, interactive=True) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 parser.add_option('--user', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 dest='username', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 help='Admin Username') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 parser.add_option('--email', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 dest='email', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 help='Admin Email') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 parser.add_option('--password', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 dest='password', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 help='Admin password min 6 chars') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 parser.add_option('--repos', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 dest='repos_location', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 help='Absolute path to repositories location') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 parser.add_option('--name', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 action='store', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 dest='section_name', |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 default=None, |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 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
|
53 parser.add_option('--force-yes', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
54 action='store_true', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
55 dest='force_ask', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
56 default=None, |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
57 help='Force yes to every question') |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
58 parser.add_option('--force-no', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
59 action='store_false', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
60 dest='force_ask', |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
61 default=None, |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
62 help='Force no to every question') |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 def command(self): |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 config_spec = self.args[0] |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 section = self.options.section_name |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 if section is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 if '#' in config_spec: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 config_spec, section = config_spec.split('#', 1) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 else: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 section = 'main' |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 if not ':' in section: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 plain_section = section |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2289
diff
changeset
|
74 section = 'app:' + section |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 else: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 plain_section = section.split(':', 1)[0] |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 if not config_spec.startswith('config:'): |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 config_spec = 'config:' + config_spec |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 if plain_section != 'main': |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 config_spec += '#' + plain_section |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 self.logging_file_config(config_file) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 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
|
85 ep_name = conf.context.entry_point_name |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 ep_group = conf.context.protocol |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 dist = conf.context.distribution |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
88 if dist is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 raise BadCommand( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 "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
|
91 "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
|
92 "section that configures your application" % plain_section) |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 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
|
94 installer.setup_config( |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 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
|
96 self.call_sysconfig_functions( |
2289
5893414dea91
renamed setup module into a setup_rhodecode.
Marcin Kuzminski <marcin@python-works.com>
parents:
2284
diff
changeset
|
97 'post_setup_hook', installer, config_file) |