From cc068f8ee887f2d6f2a1313418ad4890663b82c2 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Sun, 22 Mar 2015 17:52:07 -0700 Subject: [PATCH] init/import path: move DEFAULT_CONFIG to __init__ for faster shared import proxy: move certauth/openssl init to only happen in enable_https_proxy is set to make slow openssl import run only when used --- pywb/__init__.py | 6 +++++- pywb/framework/proxy.py | 4 ++-- pywb/webapp/pywb_init.py | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pywb/__init__.py b/pywb/__init__.py index ef7c1d7f..e96a5b1d 100644 --- a/pywb/__init__.py +++ b/pywb/__init__.py @@ -1,4 +1,8 @@ import os +DEFAULT_CONFIG = 'pywb/default_config.yaml' + def get_test_dir(): - return os.path.dirname(os.path.realpath(__file__)) + '/../sample_archive/' + return os.path.join(os.path.dirname(os.path.realpath(__file__)), + '..', + 'sample_archive') + os.path.sep diff --git a/pywb/framework/proxy.py b/pywb/framework/proxy.py index f8bab933..6d557dee 100644 --- a/pywb/framework/proxy.py +++ b/pywb/framework/proxy.py @@ -12,8 +12,6 @@ from pywb.utils.wbexception import BadRequestException from pywb.utils.bufferedreaders import BufferedReader -from certauth import CertificateAuthority, openssl_avail - from proxy_resolvers import ProxyAuthResolver, CookieResolver @@ -92,6 +90,8 @@ class ProxyRouter(object): self.ca = None return + from certauth import CertificateAuthority, openssl_avail + if not openssl_avail: # pragma: no cover print('HTTPS proxy not available as pyopenssl is not installed') print('Please install via "pip install pyopenssl" ' + diff --git a/pywb/webapp/pywb_init.py b/pywb/webapp/pywb_init.py index 4f39c1d9..7cbea633 100644 --- a/pywb/webapp/pywb_init.py +++ b/pywb/webapp/pywb_init.py @@ -17,14 +17,12 @@ from handlers import StaticHandler from handlers import DebugEchoHandler, DebugEchoEnvHandler from cdx_api_handler import CDXAPIHandler +from pywb import DEFAULT_CONFIG import os import logging -#================================================================= -DEFAULT_CONFIG = 'pywb/default_config.yaml' - #================================================================= class DictChain: def __init__(self, *dicts):