diff --git a/pywb/views.py b/pywb/views.py index a12753af..75356f8e 100644 --- a/pywb/views.py +++ b/pywb/views.py @@ -44,7 +44,8 @@ class J2TemplateView: def render_response(self, **kwargs): template_result = self.render_to_string(**kwargs) - return wbrequestresponse.WbResponse.text_response(str(template_result), content_type = 'text/html; charset=utf-8') + status = kwargs.get('status', '200 OK') + return wbrequestresponse.WbResponse.text_response(str(template_result), status = status, content_type = 'text/html; charset=utf-8') # Filters @@ -74,7 +75,12 @@ class J2HtmlCapturesView(J2TemplateView): #================================================================= class TextCapturesView: def render_response(self, wbrequest, cdx_lines): - cdx_lines = imap(lambda x: str(x) + '\n', cdx_lines) + def to_str(cdx): + cdx = str(cdx) + if not cdx.endswith('\n'): + cdx += '\n' + return cdx + cdx_lines = imap(to_str, cdx_lines) return wbrequestresponse.WbResponse.text_stream(cdx_lines) diff --git a/pywb/wbapp.py b/pywb/wbapp.py index 3dc5ecee..0558cf72 100644 --- a/pywb/wbapp.py +++ b/pywb/wbapp.py @@ -59,7 +59,7 @@ def handle_exception(env, errorpage, exc, print_trace): if errorpage: import traceback - return errorpage.render_response(err_msg = str(exc), err_details = err_details) + return errorpage.render_response(err_msg = str(exc), err_details = err_details, status = status) else: return WbResponse.text_response(status + ' Error: ' + str(exc), status = status) @@ -69,12 +69,13 @@ DEFAULT_CONFIG_FILE = 'config.yaml' def main(): try: - # Attempt to load real settings from globalwb module logging.basicConfig(format = '%(asctime)s: [%(levelname)s]: %(message)s', level = logging.DEBUG) + # see if there's a custom init module config_name = os.environ.get('PYWB_CONFIG_MODULE') if not config_name: + # use default module config_name = 'pywb.pywb_init' logging.info('Loading from default config module "{0}"'.format(config_name)) logging.info('') @@ -87,7 +88,6 @@ def main(): return app except Exception as e: - # Otherwise, start with the sample settings logging.exception('*** pywb could not init with settings from {0}.pywb_config()!\n'.format(config_name)) raise e