Index: roundup/scripts/roundup_server.py =================================================================== --- roundup/scripts/roundup_server.py (revision 11) +++ roundup/scripts/roundup_server.py (revision 14) @@ -71,6 +71,7 @@ TRACKERS = None LOG_IPADDRESS = 1 DEBUG_MODE = False + CONFIG = None def get_tracker(self, name): """Return a tracker instance for given tracker name""" @@ -167,11 +168,39 @@ ''' rest = self.path + # file-like object for the favicon.ico file information + favicon_fileobj = None + if rest == '/favicon.ico': + # check to see if a custom favicon was specified, and set + # favicon_fileobj to the input file + if self.CONFIG is not None: + favicon_filepath = os.path.abspath(self.CONFIG['FAVICON']) + + if os.access(favicon_filepath, os.R_OK): + favicon_fileobj = open(favicon_filepath, 'rb') + + + if favicon_fileobj is None: + favicon_fileobj = StringIO.StringIO(favico) + self.send_response(200) self.send_header('Content-Type', 'image/x-icon') self.end_headers() - self.wfile.write(favico) + + # this bufsize is completely arbitrary, I picked 4K because it sounded good. + # if someone knows of a better buffer size, feel free to plug it in. + bufsize = 4 * 1024 + Processing = True + while Processing: + data = favicon_fileobj.read(bufsize) + if len(data) > 0: + self.wfile.write(data) + else: + Processing = False + + favicon_fileobj.close() + return i = rest.rfind('?') @@ -328,6 +357,9 @@ "If empty, listen on all network interfaces."), (configuration.IntegerNumberOption, "port", DEFAULT_PORT, "Port to listen on."), + (configuration.NullableFilePathOption, "favicon", "favicon.ico", + "Path to favicon.ico image file. If unset, built-in\n" + "favicon.ico is used."), (configuration.NullableOption, "user", "", "User ID as which the server will answer requests.\n" "In order to use this option, " @@ -432,6 +464,11 @@ TRACKERS = trackers DEBUG_MODE = self["MULTIPROCESS"] == "debug" + # the config file (-C file) doesn't seem to be available + # after it's initially read in? maybe I'm just missing it, + # this makes it explicitly available to the http handler. + CONFIG = self + # obtain request server class if self["MULTIPROCESS"] not in MULTIPROCESS_TYPES: print _("Multiprocess mode \"%s\" is not available, "