-
Notifications
You must be signed in to change notification settings - Fork 4
/
commands.py
46 lines (37 loc) · 1.41 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
import sys
import os
import subprocess
MODULE = 'carbonate'
# Commands that are specific to your module
COMMANDS = ['carbonate', 'carbonate:help', 'carbonate:new']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "carbonate:new":
java_cmd = app.java_cmd(args, None, "play.modules.carbonate.NewMigrationMain")
try:
subprocess.call(java_cmd, env=os.environ)
except OSError:
print "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)
else:
print "~ Carbonate module is used for managing your database changes."
print "~"
print "~ Usage:"
print "~ play carbonate:new - Creates new database migration file, prefilled with changes detected between your database and model."
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass