comparison runXena.py @ 34:a3fbe077a14c

replace wget with python method
author jingchunzhu <jingchunzhu@gmail.com>
date Thu, 23 Jul 2015 01:02:24 -0700
parents 7ceb967147c3
children
comparison
equal deleted inserted replaced
33:7ceb967147c3 34:a3fbe077a14c
67 formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") 67 formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
68 handler = logging.FileHandler(xena.baseDir() + "/xena-daemon.log") 68 handler = logging.FileHandler(xena.baseDir() + "/xena-daemon.log")
69 handler.setFormatter(formatter) 69 handler.setFormatter(formatter)
70 logger.addHandler(handler) 70 logger.addHandler(handler)
71 71
72 hostname = subprocess.check_output("hostname -f", shell=True).rstrip() 72 hostname = xena.hostname() #subprocess.check_output("hostname -f", shell=True).rstrip()
73 73
74 # 74 #
75 # Check if there has been a Xena running on this system, and 75 # Check if there has been a Xena running on this system, and
76 # what its port number is or was. 76 # what its port number is or was.
77 # 77 #
78 xenaPort = xena.port() 78 xenaPort = xena.port()
79
79 if xenaPort == None: 80 if xenaPort == None:
80 # In this case, no Xena has been running on this sytem. 81 # In this case, no Xena has been running on this sytem.
81 xenaIsRunning = False 82 xenaIsRunning = False
82 else: 83 else:
83 xenaIsRunning = xena.isRunning(xenaPort) 84 xenaIsRunning = xena.isRunning(xenaPort)
89 # When checking status, if Xena is running, then report that it's running 90 # When checking status, if Xena is running, then report that it's running
90 # with hostname and port. If it's not running, then report as such. 91 # with hostname and port. If it's not running, then report as such.
91 # 92 #
92 if xenaIsRunning: 93 if xenaIsRunning:
93 fp.write("Xena VM currently running on http://%s:%s\n" % (hostname, xenaPort)) 94 fp.write("Xena VM currently running on http://%s:%s\n" % (hostname, xenaPort))
95 fp.write("\n")
94 fp.write("You can add http://%s:%s to Xena Data Hub\n" % (hostname, xenaPort)) 96 fp.write("You can add http://%s:%s to Xena Data Hub\n" % (hostname, xenaPort))
95 else: 97 else:
96 fp.write("Xena VM is not currently running on %s\n" % (hostname)) 98 fp.write("Xena VM is not currently running on %s\n" % (hostname))
97 99
98 elif sys.argv[1] == "start": 100 elif sys.argv[1] == "start":
103 # process goes into daemon mode. 105 # process goes into daemon mode.
104 # 106 #
105 if not xenaIsRunning: 107 if not xenaIsRunning:
106 xenaPort = xena.port(testIfAvailable=True, findNewPort=True) 108 xenaPort = xena.port(testIfAvailable=True, findNewPort=True)
107 fp.write("Starting Xena VM on http://%s:%s\n" % (hostname, xenaPort)) 109 fp.write("Starting Xena VM on http://%s:%s\n" % (hostname, xenaPort))
108 fp.write("You can add http://%s:%s to Xena Data Hub\n" % (hostname, xenaPort)) 110 fp.write("\n")
111 fp.write("Use Xena Administration -> Check Status tool to review status.\n")
109 else: 112 else:
110 fp.write("Xena VM already running on http://%s:%s\n" % (hostname, xenaPort)) 113 fp.write("Xena VM already running on http://%s:%s\n" % (hostname, xenaPort))
114 fp.write("\n")
111 fp.write("You can add http://%s:%s to Xena Data Hub\n" % (hostname, xenaPort)) 115 fp.write("You can add http://%s:%s to Xena Data Hub\n" % (hostname, xenaPort))
112 fp.close() 116 fp.close()
113 117
114 elif sys.argv[1] == "stop": 118 elif sys.argv[1] == "stop":
115 # 119 #