def start_server(self):
if self.webserverStarted == False and self.CONTROLLER_SERVER_PATH != '':
"""Changing dir to the schedules dir."""
web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules'))
os.chdir(web_dir)
PORT = int(self.CONTROLLER_SERVER_PORT)
class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
return
global httpd
try:
#print "Starting webserver at port: ", PORT
# create the httpd handler for the simplehttpserver
# we set the allow_reuse_address incase something hangs can still bind to port
class ReusableTCPServer(SocketServer.TCPServer): allow_reuse_address=True
# specify the httpd service on 0.0.0.0 (all interfaces) on port 80
httpd = ReusableTCPServer(("0.0.0.0", PORT),MyHandler)
# thread this mofo
thread.start_new_thread(httpd.serve_forever,())
# handle keyboard interrupts
except KeyboardInterrupt:
core.print_info("Exiting the SET web server...")
httpd.socket.close()
except socket.error, exc:
print "Caught exception socket.error : %s" % exc
# handle the rest
#except Exception:
# print "[*] Exiting the SET web server...\n"
# httpd.socket.close()
self.webserverStarted = True
PseudoDailyScheduleController.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录