websetup.py
49 lines
| 1.3 KiB
| text/x-python
|
PythonLexer
/ pylons_app / websetup.py
Marcin Kuzminski
|
r0 | """Setup the pylons_app application""" | ||
r327 | ||||
from os.path import dirname as dn, join as jn | ||||
from pylons_app.config.environment import load_environment | ||||
from pylons_app.lib.db_manage import DbManage | ||||
Marcin Kuzminski
|
r0 | import logging | ||
r327 | import os | |||
import sys | ||||
Marcin Kuzminski
|
r0 | log = logging.getLogger(__name__) | ||
r327 | ROOT = dn(dn(os.path.realpath(__file__))) | |||
sys.path.append(ROOT) | ||||
def setup_repository(): | ||||
log.info('Seting up repositories.config') | ||||
fname = 'repositories.config' | ||||
try: | ||||
tmpl = open(jn(ROOT, 'pylons_app', 'config', 'repositories.config_tmpl')).read() | ||||
except IOError: | ||||
raise | ||||
path = raw_input('Specify valid full path to your repositories' | ||||
' you can change this later in repositories.config file:') | ||||
if not os.path.isdir(path): | ||||
log.error('You entered wrong path') | ||||
sys.exit() | ||||
path = jn(path, '*') | ||||
dest_path = jn(ROOT, fname) | ||||
f = open(dest_path, 'wb') | ||||
f.write(tmpl % {'repo_location':path}) | ||||
f.close() | ||||
log.info('created repositories.config in %s', dest_path) | ||||
Marcin Kuzminski
|
r0 | |||
def setup_app(command, conf, vars): | ||||
"""Place any commands to setup pylons_app here""" | ||||
r327 | setup_repository() | |||
dbmanage = DbManage(log_sql=True) | ||||
dbmanage.create_tables(override=True) | ||||
dbmanage.admin_prompt() | ||||
dbmanage.create_permissions() | ||||
Marcin Kuzminski
|
r0 | load_environment(conf.global_conf, conf.local_conf) | ||
r327 | ||||