Slight code cleanup. Remove unused code

This commit is contained in:
Darshit Shah 2013-09-07 11:35:34 +05:30
parent 886ac1a89b
commit cb94e52d0f
3 changed files with 7 additions and 67 deletions

View File

@ -1,3 +1,8 @@
2013-09-07 Darshit Shah <darnir@gmail.com>
* HTTPServer.py: Remove bunch of old code artefacts
* WgetTest.py: Same
2013-09-07 Darshit Shah <darnir@gmail.com>
* HTTPServer.py (StoppableHTTPServer.server_conf): Change global

View File

@ -1,4 +1,3 @@
from multiprocessing import Process, Queue
from http.server import HTTPServer, BaseHTTPRequestHandler
from base64 import b64encode
from random import random
@ -11,7 +10,7 @@ import re
class InvalidRangeHeader (Exception):
""" Create an Exception for handling of invalid Range Headers. """
# Maybe: This exception should be generalized to handle other issues too.
# TODO: Eliminate this exception and use only ServerError
def __init__ (self, err_message):
self.err_message = err_message
@ -26,12 +25,7 @@ class StoppableHTTPServer (HTTPServer):
""" Define methods for configuring the Server. """
def server_conf (self, filelist, conf_dict):
""" Set Server Rules and File System for this instance.
This method should be called before the Server is forked into a new
process. This is because of how the system-level fork() call works.
"""
""" Set Server Rules and File System for this instance. """
self.server_configs = conf_dict
self.fileSys = filelist
@ -41,48 +35,15 @@ class StoppableHTTPServer (HTTPServer):
self.handle_request ()
""" def serve_forever (self, q):
# Override method allowing for programmatical shutdown process.
global queue
queue = q
self.stop = False
while not self.stop:
self.handle_request ()
"""
class WgetHTTPRequestHandler (BaseHTTPRequestHandler):
""" Define methods for handling Test Checks. """
# List of Checks that are run on the Server-side.
tests = [
"expect_headers",
"reject_headers",
"is_authorized",
"custom_response",
"test_cookies"
]
def test_cookies (self):
pass
"""
cookie_recd = self.headers.get ('Cookie')
cookies = self.get_rule_list ('Cookie')
cookie_exp = cookies.cookie_value if cookies else None
if cookie_exp == cookie_recd:
return True
else:
self.send_response (400, "Cookie Mismatch")
self.finish_headers ()
return False
"""
def get_rule_list (self, name):
r_list = self.rules.get (name) if name in self.rules else None
return r_list
def do_QUIT (self):
#queue.put (self.server.fileSys)
self.send_response (200)
self.end_headers ()
self.server.stop = True
@ -395,14 +356,6 @@ class _Handler (WgetHTTPRequestHandler):
print (se.__str__())
return (None, None)
testPassed = True
for check in self.tests:
if testPassed is True:
assert hasattr (self, check)
testPassed = getattr (self, check) ()
else:
return (None, None)
content = self.server.fileSys.get (path)
content_length = len (content)
try:
@ -450,17 +403,4 @@ class HTTPd (threading.Thread):
def server_conf (self, file_list, server_rules):
self.server.server_conf (file_list, server_rules)
def create_server ():
server = HTTPd ()
return server
def spawn_server (server):
#global q
#q = Queue()
#server_process = Process (target=server.serve_forever, args=(q,))
#server_process.start ()
server.start ()
# vim: set ts=8 sts=4 sw=3 tw=0 et :

View File

@ -238,7 +238,6 @@ class HTTPTest (CommonMethods):
getattr (self, test_func) (test_params[test_func])
#HTTPServer.spawn_server (self.server)
self.act_retcode = self.exec_wget (self.options, self.urls, self.domain)
self.stop_HTTP_Server ()
@ -250,8 +249,6 @@ class HTTPTest (CommonMethods):
getattr (self, post_hook_func) (post_hook[post_hook_func])
def init_HTTP_Server (self):
#server = HTTPServer.create_server ()
#return server
server = HTTPServer.HTTPd ()
server.start ()
return server
@ -259,9 +256,7 @@ class HTTPTest (CommonMethods):
def stop_HTTP_Server (self):
conn = http.client.HTTPConnection (self.domain.strip ('/'))
conn.request ("QUIT", "/")
#self.fileSys = HTTPServer.ret_fileSys ()
conn.getresponse ()
#server.stop ()
""" WgetFile is a File Data Container object """