public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: tests/
Date: Sun, 15 Sep 2013 22:38:22 +0000 (UTC)	[thread overview]
Message-ID: <1379284686.fe0840ffb8a3991164bb9aa68bf0a370e1b1e132.jauhien@gentoo> (raw)

commit:     fe0840ffb8a3991164bb9aa68bf0a370e1b1e132
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Sep 15 22:38:06 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Sep 15 22:38:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=fe0840ff

tests/server: serve files from a given directory

---
 tests/server.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/server.py b/tests/server.py
index 41767fc..6cb16e6 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -11,6 +11,7 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
+import os
 import threading
 
 from g_sorcery.compatibility import py2k
@@ -22,12 +23,26 @@ else:
     from http.server import HTTPServer
     from http.server import SimpleHTTPRequestHandler
 
+def HTTPRequestHandlerGenerator(direct):
+
+    class HTTPRequestHandler(SimpleHTTPRequestHandler):
+        directory = direct
+
+        def __init__(self, request, client_address, server):
+            super(HTTPRequestHandler, self).__init__(request, client_address, server)
+
+        def translate_path(self, path):
+            return os.path.join(self.directory, path[1:])
+
+    return HTTPRequestHandler
+
+    
 class Server(threading.Thread):
-    def __init__(self):
+    def __init__(self, directory):
         super(Server, self).__init__()
         HTTPServer.allow_reuse_address = True
         server_address = ('127.0.0.1', 8080)
-        self.httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)
+        self.httpd = HTTPServer(server_address, HTTPRequestHandlerGenerator(directory))
     
     def run(self):
         self.httpd.serve_forever()


             reply	other threads:[~2013-09-15 22:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-15 22:38 Jauhien Piatlicki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-04 15:50 [gentoo-commits] proj/g-sorcery:master commit in: tests/ Ulrich Müller
2021-05-04 15:50 Ulrich Müller
2021-05-04 15:50 Ulrich Müller
2013-09-18 22:52 Jauhien Piatlicki
2013-09-18 22:52 Jauhien Piatlicki
2013-09-18 22:09 Jauhien Piatlicki
2013-09-18 22:09 Jauhien Piatlicki
2013-09-18  0:57 Jauhien Piatlicki
2013-09-16 14:33 Jauhien Piatlicki
2013-09-16  0:19 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-07-17 15:41 Jauhien Piatlicki
2013-07-14 23:39 Jauhien Piatlicki
2013-07-08 23:53 Jauhien Piatlicki
2013-07-02 14:48 Jauhien Piatlicki
2013-07-02 10:21 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379284686.fe0840ffb8a3991164bb9aa68bf0a370e1b1e132.jauhien@gentoo \
    --to=piatlicki@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox