Parent: [0d54f1] (diff)

Child: [7171de] (diff)

Download this file

base.py    63 lines (56 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import sys
import logging
from pkg_resources import iter_entry_points
import pylons
from paste.script import command
from paste.deploy import appconfig
import ming
from allura.config.environment import load_environment
from allura.lib.custom_middleware import MagicalC, environ
from allura.lib import security
class EmptyClass(object): pass
class Command(command.Command):
min_args = 0
max_args = 1
usage = 'NAME [<ini file>]'
group_name = 'Allura'
def basic_setup(self):
global log, M
if self.args:
conf = appconfig('config:%s' % self.args[0],relative_to=os.getcwd())
try:
if self.setup_global_config:
logging.config.fileConfig(self.args[0], disable_existing_loggers=False)
except Exception:
try:
# logging does not understand section#subsection syntax,
# so strip away the #subsection and try again.
logging.config.fileConfig(self.args[0].split('#')[0], disable_existing_loggers=False)
except Exception: # pragma no cover
print >> sys.stderr, (
'Could not configure logging with config file %s' % self.args[0])
from allura import model
M=model
log = logging.getLogger('allura.command')
log.info('Initialize reactor with config %r', self.args[0])
environ.set_environment({
'allura.credentials':security.Credentials()
})
load_environment(conf.global_conf, conf.local_conf)
try:
pylons.c._current_obj()
except TypeError:
pylons.c._push_object(MagicalC(EmptyClass(), environ))
from allura.lib.app_globals import Globals
pylons.g._push_object(Globals())
ming.configure(**conf)
else:
log = logging.getLogger('allura.command')
self.tools = []
for ep in iter_entry_points('allura'):
try:
self.tools.append((ep.name, ep.load()))
except ImportError:
log.warning('Canot load entry point %s', ep)
log.info('Loaded tools')