-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
65 lines (57 loc) · 1.91 KB
/
commands.py
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
62
63
64
65
# Here you can create play commands that are specific to the module
import os, os.path
import sys
import getopt
import subprocess
try:
from play.utils import package_as_war
PLAY10 = False
except ImportError:
PLAY10 = True
MODULE = 'i18ned'
COMMANDS = ['i18ned:export', 'i18ned:import', 'i18ned:pimport', 'i18ned:sql', 'i18ned:check']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
for arg in args:
print arg
env = kargs.get("env")
print "executing command: " + command
if command == 'i18ned:export':
run(app, args, 'Exporter')
if command == 'i18ned:sql':
run(app, args, 'SqlExporter')
if command == 'i18ned:pimport':
run(app, args, 'PrefixedImporter')
if command == 'i18ned:import':
run(app, args, 'Importer')
if command == 'i18ned:check':
run(app, args, 'Checker')
def run(app, args, class_name):
app.check()
java_cmd = app.java_cmd(['-Xmx64m'], className='play.modules.i18ned.'+class_name, args=args)
subprocess.call(java_cmd, env=os.environ)
print
if PLAY10:
if play_command == 'i18ned:export':
try:
print "~ Generating controller and views from entities"
print "~ "
check_application()
load_modules()
do_classpath()
try:
# This is the new style to get the extra arg
do_java('play.modules.i18ned.Exporter', sys.argv)
except Exception:
# For play! < 1.0.3
do_java('play.modules.i18ned.Exporter')
subprocess.call(java_cmd, env=os.environ)
sys.exit(0)
except getopt.GetoptError, err:
print "~ Failed to generate scaffold properly..."
print "~ %s" % str(err)
print "~ "
sys.exit(-1)
sys.exit(0)