-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
35 lines (29 loc) · 1.19 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
import os
import subprocess
MODULE = 'c5migration'
COMMANDS = ['c5migration:migrate', 'c5migration:new', 'c5migration:check']
HELP = {
'c5migration:migrate': ' Apply all pending migrations',
'c5migration:new': ' Create a new, empty migration script',
'c5migration:check': ' Check for pending migrations, fail the build if the db is not up to date'
}
def callJava(app, args, command):
java_args = []
java_args.append(command);
configuration = os.path.join(app.path, 'conf/application.conf')
java_args.append(configuration)
java_cmd = app.java_cmd(args, None, 'play.modules.c5migration.MigrationMain', java_args)
try:
subprocess.call(java_cmd, env=os.environ)
except OSError:
print "~ ERROR: Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
sys.exit(-1)
print "~ "
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command.startswith("c5migration:"):
command = command.split(":");
callJava(app, args, command[1])