Mercurial > hg
comparison tests/tinyproxy.py @ 29433:33770d2b6cf9
py3: conditionalize SocketServer import
The SocketServer is renamed to socketserver in python 3
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 27 Jun 2016 16:48:54 +0530 |
parents | 80880ad3fccd |
children | 143d21a7343e |
comparison
equal
deleted
inserted
replaced
29432:34b914ac573e | 29433:33770d2b6cf9 |
---|---|
13 """ | 13 """ |
14 | 14 |
15 __version__ = "0.2.1" | 15 __version__ = "0.2.1" |
16 | 16 |
17 import BaseHTTPServer | 17 import BaseHTTPServer |
18 import SocketServer | |
19 import os | 18 import os |
20 import select | 19 import select |
21 import socket | 20 import socket |
22 import sys | 21 import sys |
23 | 22 |
24 from mercurial import util | 23 from mercurial import util |
25 | 24 |
26 urlparse = util.urlparse | 25 urlparse = util.urlparse |
26 socketserver = util.socketserver | |
27 | 27 |
28 class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): | 28 class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): |
29 __base = BaseHTTPServer.BaseHTTPRequestHandler | 29 __base = BaseHTTPServer.BaseHTTPRequestHandler |
30 __base_handle = __base.handle | 30 __base_handle = __base.handle |
31 | 31 |
133 do_HEAD = do_GET | 133 do_HEAD = do_GET |
134 do_POST = do_GET | 134 do_POST = do_GET |
135 do_PUT = do_GET | 135 do_PUT = do_GET |
136 do_DELETE = do_GET | 136 do_DELETE = do_GET |
137 | 137 |
138 class ThreadingHTTPServer (SocketServer.ThreadingMixIn, | 138 class ThreadingHTTPServer (socketserver.ThreadingMixIn, |
139 BaseHTTPServer.HTTPServer): | 139 BaseHTTPServer.HTTPServer): |
140 def __init__(self, *args, **kwargs): | 140 def __init__(self, *args, **kwargs): |
141 BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs) | 141 BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs) |
142 a = open("proxy.pid", "w") | 142 a = open("proxy.pid", "w") |
143 a.write(str(os.getpid()) + "\n") | 143 a.write(str(os.getpid()) + "\n") |