-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLaunchDashboard.py
56 lines (43 loc) · 1.74 KB
/
LaunchDashboard.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
#!/usr/bin/env python
import os
import sys
import SimpleHTTPServer
import SocketServer
from optparse import OptionParser
from optparse import OptionGroup
from glob import glob
import thread
import webbrowser
def get_free_port():
import socket
sock = socket.socket()
sock.bind(('', 0))
return sock.getsockname()[1]
def create_server(port, *args):
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
SocketServer.TCPServer.allow_reuse_address=True
httpd = SocketServer.TCPServer(("", port), Handler)
print( "\n\nAPPIAN Dashboard: http://localhost:"+str(port))
httpd.serve_forever()
def LaunchDashboard(outDir):
if not os.path.exists(outDir) :
print("Error: could not find APPIAN output directory", outDir)
exit(1)
print( "APPAIN output directory :"+ outDir)
indexDir = outDir+os.sep+"preproc"+os.sep+"dashboard"
if not os.path.exists(indexDir) :
print("Error: could not find dashboard directory in APPIAN output: ",indexDir)
print("Did you run APPIAN with the <--dashboard> option?")
exit(1)
os.chdir(indexDir)
port=get_free_port()
thread.start_new_thread(create_server, (port , 1))
webbrowser.open("http://localhost:"+str(port),new=2)
raw_input("Press any key to exit. Can relaunch dashboard with APPIAN/LaunchDashboard.py") #needs to be changed to <input> for python3
if __name__ == "__main__":
usage = "usage: "
parser = OptionParser(usage=usage)
group= OptionGroup(parser,"File options (mandatory)")
group.add_option("-o","--output_appain","--output_appain",dest="outDir", help="Absolute path for APPAIN directory where output data will were saved in")
(opts, args) = parser.parse_args()
LaunchDashboard(opts.outDir)