e3bc93c2eb
Don't start the http server on 0.0.0.0, listen on host ip (end of tap interface) only. Also use the timeout option (default is 300s for ssh commands) for all the commands run in this module (mostly because smart update timeouts on mips). (From OE-Core rev: 8c272641ef3e8410f331ca4133d28dea8f36e4f4) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
34 lines
919 B
Python
34 lines
919 B
Python
import SimpleHTTPServer
|
|
import multiprocessing
|
|
import os
|
|
|
|
class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer):
|
|
|
|
def server_start(self, root_dir):
|
|
os.chdir(root_dir)
|
|
self.serve_forever()
|
|
|
|
class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|
|
|
def log_message(self, format_str, *args):
|
|
pass
|
|
|
|
class HTTPService(object):
|
|
|
|
def __init__(self, root_dir, host=''):
|
|
self.root_dir = root_dir
|
|
self.host = host
|
|
self.port = 0
|
|
|
|
def start(self):
|
|
self.server = HTTPServer((self.host, self.port), HTTPRequestHandler)
|
|
if self.port == 0:
|
|
self.port = self.server.server_port
|
|
self.process = multiprocessing.Process(target=self.server.server_start, args=[self.root_dir])
|
|
self.process.start()
|
|
|
|
def stop(self):
|
|
self.server.server_close()
|
|
self.process.terminate()
|
|
self.process.join()
|