diff options
author | Mihai Lindner <mihaix.lindner@linux.intel.com> | 2013-08-14 17:21:38 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-26 11:42:14 +0100 |
commit | e38e18d6923cc3db50b56fa3fc64081fe4aa8669 (patch) | |
tree | b574cb35569f3b7d9662370bc35e884542600f1f /meta/lib/oeqa | |
parent | a2d2f2b7b111863d3c50dedded37aab813d9634f (diff) | |
download | openembedded-core-e38e18d6923cc3db50b56fa3fc64081fe4aa8669.tar.gz openembedded-core-e38e18d6923cc3db50b56fa3fc64081fe4aa8669.tar.bz2 openembedded-core-e38e18d6923cc3db50b56fa3fc64081fe4aa8669.zip |
lib/oeqa/utils: new file: httpserver.py useful for serving files over HTTP to the target
It can be used by smart repo/channel tests to serve deploy_dir.
Signed-off-by: Mihai Lindner <mihaix.lindner@linux.intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/utils/httpserver.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py new file mode 100644 index 0000000000..d4b61547e8 --- /dev/null +++ b/meta/lib/oeqa/utils/httpserver.py @@ -0,0 +1,32 @@ +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): + self.root_dir = root_dir + self.port = 0 + + def start(self): + self.server = HTTPServer(('', 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() |