root/debexpo/websetup.py

Revision da6b71fb607ef9535869ea15d56a1862ee0f64e6, 2.8 kB (checked in by Jonny Lamb <jonnylamb@…>, 7 months ago)

Fixed typo in websetup.py.

Signed-off-by: Jonny Lamb <jonnylamb@…>

  • Property mode set to 100644
Line 
1# -*- coding: utf-8 -*-
2#
3#   websetup.py — Setup the debexpo application
4#
5#   This file is part of debexpo - http://debexpo.workaround.org
6#
7#   Copyright © 2008 Jonny Lamb <jonnylamb@jonnylamb.com
8#
9#   Permission is hereby granted, free of charge, to any person
10#   obtaining a copy of this software and associated documentation
11#   files (the "Software"), to deal in the Software without
12#   restriction, including without limitation the rights to use,
13#   copy, modify, merge, publish, distribute, sublicense, and/or sell
14#   copies of the Software, and to permit persons to whom the
15#   Software is furnished to do so, subject to the following
16#   conditions:
17#
18#   The above copyright notice and this permission notice shall be
19#   included in all copies or substantial portions of the Software.
20#
21#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22#   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23#   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24#   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25#   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26#   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28#   OTHER DEALINGS IN THE SOFTWARE.
29
30"""
31Setup the debexpo application.
32"""
33
34__author__ = 'Jonny Lamb'
35__copyright__ = 'Copyright © 2008 Jonny Lamb'
36__license__ = 'MIT'
37
38import logging
39import os
40
41from paste.deploy import appconfig
42from pylons import config
43
44from debexpo.config.environment import load_environment
45from debexpo.model import import_all_models
46from debexpo.model import meta
47
48log = logging.getLogger(__name__)
49
50def setup_config(command, filename, section, vars):
51    """
52    Run when debexpo is being set up, when ``paster setup-app`` is executed and shouldn't
53    be called directly.
54
55    ``command``
56        Pointer to the setup function.
57
58    ``filename``
59        File used for configuration. E.g. `development.ini`.
60
61    ``section``
62        Section in the config file; usually `app:main`.
63
64    ``vars``
65        Extra variables passed to the setup.
66    """
67
68    conf = appconfig('config:' + filename)
69    load_environment(conf.global_conf, conf.local_conf)
70
71    log.info('Creating database tables')
72    import_all_models()
73    meta.metadata.create_all(bind=meta.engine)
74    log.info('Successfully setup database tables')
75
76    if not os.path.isdir(config['debexpo.upload.incoming']):
77        log.info('Creating incoming directory')
78        os.mkdir(config['debexpo.upload.incoming'])
79    else:
80        log.info('Incoming directory already exists')
81
82    if not os.path.isdir(config['debexpo.repository']):
83        log.info('Creating repository directory')
84        os.mkdir(config['debexpo.repository'])
85    else:
86        log.info('Repository directory already exists')
Note: See TracBrowser for help on using the browser.