From a125548f093d6dc3c99f5d1ba91bfa2b3d3fe24b Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 14 Dec 2010 11:01:23 -0800 Subject: Don't hardcode the "log" prefix all over the place. --- TinyHTTPProxy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TinyHTTPProxy.py b/TinyHTTPProxy.py index 824703e..08e51fe 100755 --- a/TinyHTTPProxy.py +++ b/TinyHTTPProxy.py @@ -18,6 +18,8 @@ replay = False import BaseHTTPServer, select, socket, SocketServer, urlparse, urllib import os +prefix = "log" + class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): __base = BaseHTTPServer.BaseHTTPRequestHandler __base_handle = __base.handle @@ -92,13 +94,13 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): current_file_name = substitute(current_file_name) if replay: - result = open("log/" + current_file_name, "r") + result = open(prefix + "/" + current_file_name, "r") print urllib.quote(self.path, "") self.connection.send(result.read()) self.connection.close() self.log_request() return - self.current_file = open("log/" + current_file_name, "w+") + self.current_file = open(prefix + "/" + current_file_name, "w+") if scm != 'http' or fragment or not netloc: self.send_error(400, "bad url %s" % self.path) return @@ -158,7 +160,7 @@ class ThreadingHTTPServer (SocketServer.ThreadingMixIn, if __name__ == '__main__': from sys import argv try: - os.mkdir('log') + os.mkdir(prefix) except: pass -- cgit v1.2.3