forked from lmcalpin/Play--Scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
58 lines (49 loc) · 1.33 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
# 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 = 'scaffold'
COMMANDS = ['scaffold:gen']
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 == 'scaffold:gen':
run(app, args)
def run(app, args):
app.check()
java_cmd = app.java_cmd(['-Xmx64m'], className='play.modules.scaffold.Generate', args=args)
subprocess.call(java_cmd, env=os.environ)
print
if PLAY10:
if play_command == 'scaffold:gen':
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.scaffold.Generate', sys.argv)
except Exception:
# For play! < 1.0.3
do_java('play.modules.scaffold.Generate')
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)