|
a/Allura/allura/command/script.py |
|
b/Allura/allura/command/script.py |
1 |
import sys
|
1 |
import sys
|
|
|
2 |
from ming.orm import session
|
|
|
3 |
from pylons import c
|
2 |
from . import base
|
4 |
from . import base
|
|
|
5 |
from allura.lib import helpers as h
|
3 |
|
6 |
|
4 |
class ScriptCommand(base.Command):
|
7 |
class ScriptCommand(base.Command):
|
5 |
min_args=2
|
8 |
min_args=2
|
6 |
max_args=None
|
9 |
max_args=None
|
7 |
usage = 'NAME <ini file> <script> ...'
|
10 |
usage = 'NAME <ini file> <script> ...'
|
|
... |
|
... |
12 |
self.basic_setup()
|
15 |
self.basic_setup()
|
13 |
with open(self.args[1]) as fp:
|
16 |
with open(self.args[1]) as fp:
|
14 |
ns = dict(__name__='__main__')
|
17 |
ns = dict(__name__='__main__')
|
15 |
sys.argv = self.args[1:]
|
18 |
sys.argv = self.args[1:]
|
16 |
exec fp in ns
|
19 |
exec fp in ns
|
|
|
20 |
|
|
|
21 |
class SetToolAccessCommand(base.Command):
|
|
|
22 |
min_args=3
|
|
|
23 |
max_args=None
|
|
|
24 |
usage = 'NAME <ini file> <project_shortname> <access_level>...'
|
|
|
25 |
summary = ('Set the tool statuses that are permitted to be installed on a'
|
|
|
26 |
' given project')
|
|
|
27 |
parser = base.Command.standard_parser(verbose=True)
|
|
|
28 |
|
|
|
29 |
def command(self):
|
|
|
30 |
self.basic_setup()
|
|
|
31 |
h.set_context(self.args[1])
|
|
|
32 |
extra_status = []
|
|
|
33 |
for s in self.args[2:]:
|
|
|
34 |
s = s.lower()
|
|
|
35 |
if s=='production':
|
|
|
36 |
print ('All projects always have access to prodcution tools,'
|
|
|
37 |
' so removing from list.')
|
|
|
38 |
continue
|
|
|
39 |
if s not in ('alpha', 'beta'):
|
|
|
40 |
print 'Unknown tool status %s' % s
|
|
|
41 |
sys.exit(1)
|
|
|
42 |
extra_status.append(s)
|
|
|
43 |
print 'Setting project "%s" tool access to production + %r' % (
|
|
|
44 |
self.args[1], extra_status)
|
|
|
45 |
c.project._extra_tool_status = extra_status
|
|
|
46 |
session(c.project).flush()
|