-
Notifications
You must be signed in to change notification settings - Fork 0
/
appclient
executable file
·46 lines (36 loc) · 1.17 KB
/
appclient
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
#!/opt/local/bin/python
import sys
import time
from apphost.protocols import app_controller_client
def event_cback(acc, event_name, event_args=[]):
print "(" + ":".join([acc.user_name, acc.file_name, acc.label]) + ")" \
+ "Event: " + event_name
if event_name == "READY":
acc.load(file_name, label)
if event_name == "RUNNING":
#acc.stop()
pass
if event_name == "LOADED":
acc.run("mycommand")
if event_name == "ERROR":
print "ERROR: " + event_args[0]
acc.close()
if event_name == "FINISHED":
print "App complete: " + str(event_args[0])
acc.quit()
acc.close()
if len(sys.argv) != 7:
print "Usage: " + sys.argv[0] + " <username><address><port><file_name><label><command>"
exit(1)
user_name = sys.argv[1]
address = sys.argv[2]
port = int(sys.argv[3])
file_name = sys.argv[4]
label = sys.argv[5]
command = sys.argv[6]
c = app_controller_client.AppControlClient(user_name,
address,
port,
event_cback)
while c.alive is True:
time.sleep(1)