-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi-doc-refresh
executable file
·78 lines (60 loc) · 1.84 KB
/
api-doc-refresh
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
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python2.7
import subprocess
import sys
import vagrant
from cStringIO import StringIO
from fabric.api import env, execute, task, run
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def run_vagrant_task(defined_task):
failed_msg = ""
stdout_backup = sys.stdout
stderr_backup = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
try:
execute(defined_task)
except SystemExit as e:
failed_msg = e.message
out = sys.stdout.getvalue()
err = sys.stderr.getvalue()
sys.stdout.close()
sys.stderr.close()
sys.stdout = stdout_backup
sys.stderr = stderr_backup
if failed_msg:
print bcolors.FAIL + failed_msg + bcolors.ENDC
print bcolors.OKGREEN + "Output: \n" + bcolors.ENDC + out.rstrip() + "\n"
if not failed_msg:
print bcolors.OKGREEN + "No errors" + bcolors.ENDC
return out
def main():
@task
def compile_task():
run('cd /sources/everest/mgmt/controller/server && make apidocs')
vagrant_instance_name = 'default'
initial_state_vagrant_running = False
v = vagrant.Vagrant()
statuses = v.status()
for status in statuses:
if status.state == 'running':
initial_state_vagrant_running = True
vagrant_instance_name = status.name
if not initial_state_vagrant_running:
v.up()
env.hosts = [v.user_hostname_port(vm_name=vagrant_instance_name)]
env.key_filename = v.keyfile(vm_name=vagrant_instance_name)
env.disable_known_hosts = True
out = run_vagrant_task(compile_task)
print out
done = subprocess.check_output(["api-doc-move", sys.argv[1]])
print done
if __name__ == '__main__':
main()