|
a/Allura/allura/command/script.py |
|
b/Allura/allura/command/script.py |
1 |
import sys
|
1 |
import sys
|
2 |
import os.path
|
2 |
import os.path
|
3 |
import cProfile
|
3 |
import cProfile
|
|
|
4 |
|
|
|
5 |
from pylons import c
|
|
|
6 |
import pylons
|
|
|
7 |
import webob
|
|
|
8 |
|
4 |
from ming.orm import session
|
9 |
from ming.orm import session
|
5 |
from pylons import c
|
|
|
6 |
from . import base
|
|
|
7 |
from allura.lib import helpers as h
|
10 |
from allura.lib import helpers as h
|
8 |
from allura.lib import utils
|
11 |
from allura.lib import utils
|
|
|
12 |
from . import base
|
9 |
|
13 |
|
10 |
class ScriptCommand(base.Command):
|
14 |
class ScriptCommand(base.Command):
|
11 |
min_args=2
|
15 |
min_args=2
|
12 |
max_args=None
|
16 |
max_args=None
|
13 |
usage = '<ini file> <script> ...'
|
17 |
usage = '<ini file> <script> ...'
|
|
... |
|
... |
18 |
parser.add_option('--pdb', action='store_true', dest='pdb',
|
22 |
parser.add_option('--pdb', action='store_true', dest='pdb',
|
19 |
help='Drop to a debugger on error')
|
23 |
help='Drop to a debugger on error')
|
20 |
|
24 |
|
21 |
def command(self):
|
25 |
def command(self):
|
22 |
self.basic_setup()
|
26 |
self.basic_setup()
|
|
|
27 |
request = webob.Request.blank('--script--', environ={
|
|
|
28 |
'paste.registry':self.registry})
|
|
|
29 |
self.registry.register(pylons.request, request)
|
23 |
if self.options.pdb:
|
30 |
if self.options.pdb:
|
24 |
base.log.info('Installing exception hook')
|
31 |
base.log.info('Installing exception hook')
|
25 |
sys.excepthook = utils.postmortem_hook
|
32 |
sys.excepthook = utils.postmortem_hook
|
26 |
with open(self.args[1]) as fp:
|
33 |
with open(self.args[1]) as fp:
|
27 |
ns = dict(__name__='__main__')
|
34 |
ns = dict(__name__='__main__')
|