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:47:21 +0100 |
commit | f16cc25bbc4649f3a21042c6de1aa27a18278770 (patch) | |
tree | d2878965ece76a46e019969bc6662ed1e2a53545 /meta/lib/oeqa | |
parent | db7e4849c3999ed73c6349405e9680d466642598 (diff) | |
download | poky-f16cc25bbc4649f3a21042c6de1aa27a18278770.tar.gz |
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.
(From OE-Core rev: e38e18d6923cc3db50b56fa3fc64081fe4aa8669)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 @@ | |||
1 | import SimpleHTTPServer | ||
2 | import multiprocessing | ||
3 | import os | ||
4 | |||
5 | class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer): | ||
6 | |||
7 | def server_start(self, root_dir): | ||
8 | os.chdir(root_dir) | ||
9 | self.serve_forever() | ||
10 | |||
11 | class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | ||
12 | |||
13 | def log_message(self, format_str, *args): | ||
14 | pass | ||
15 | |||
16 | class HTTPService(object): | ||
17 | |||
18 | def __init__(self, root_dir): | ||
19 | self.root_dir = root_dir | ||
20 | self.port = 0 | ||
21 | |||
22 | def start(self): | ||
23 | self.server = HTTPServer(('', self.port), HTTPRequestHandler) | ||
24 | if self.port == 0: | ||
25 | self.port = self.server.server_port | ||
26 | self.process = multiprocessing.Process(target=self.server.server_start, args=[self.root_dir]) | ||
27 | self.process.start() | ||
28 | |||
29 | def stop(self): | ||
30 | self.server.server_close() | ||
31 | self.process.terminate() | ||
32 | self.process.join() | ||