Mercurial > kallithea
annotate pylons_app/websetup.py @ 327:0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 01 Jul 2010 00:57:45 +0200 |
parents | 564e40829f80 |
children | 1ef52a70f3b7 |
rev | line source |
---|---|
0 | 1 """Setup the pylons_app application""" |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
2 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
3 from os.path import dirname as dn, join as jn |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
4 from pylons_app.config.environment import load_environment |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
5 from pylons_app.lib.db_manage import DbManage |
0 | 6 import logging |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
7 import os |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
8 import sys |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
9 |
0 | 10 log = logging.getLogger(__name__) |
11 | |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
12 ROOT = dn(dn(os.path.realpath(__file__))) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
13 sys.path.append(ROOT) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
14 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
15 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
16 def setup_repository(): |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
17 log.info('Seting up repositories.config') |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
18 fname = 'repositories.config' |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
19 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
20 try: |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
21 tmpl = open(jn(ROOT, 'pylons_app', 'config', 'repositories.config_tmpl')).read() |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
22 except IOError: |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
23 raise |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
24 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
25 path = raw_input('Specify valid full path to your repositories' |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
26 ' you can change this later in repositories.config file:') |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
27 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
28 if not os.path.isdir(path): |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
29 log.error('You entered wrong path') |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
30 sys.exit() |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
31 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
32 |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
33 path = jn(path, '*') |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
34 dest_path = jn(ROOT, fname) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
35 f = open(dest_path, 'wb') |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
36 f.write(tmpl % {'repo_location':path}) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
37 f.close() |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
38 log.info('created repositories.config in %s', dest_path) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
39 |
0 | 40 |
41 def setup_app(command, conf, vars): | |
42 """Place any commands to setup pylons_app here""" | |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
43 setup_repository() |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
44 dbmanage = DbManage(log_sql=True) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
45 dbmanage.create_tables(override=True) |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
46 dbmanage.admin_prompt() |
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
47 dbmanage.create_permissions() |
0 | 48 load_environment(conf.global_conf, conf.local_conf) |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
0
diff
changeset
|
49 |