diff --git a/ckan/config/middleware/__init__.py b/ckan/config/middleware/__init__.py index 433a9bc4505..92fc6e3d2a6 100644 --- a/ckan/config/middleware/__init__.py +++ b/ckan/config/middleware/__init__.py @@ -192,8 +192,8 @@ def __call__(self, environ, start_response): if app_name == 'flask_app': # This request will be served by Flask, but we still need the # Pylons URL builder (Routes) to work - parts = urlparse(config.get('ckan.site_url', - 'http://0.0.0.0:5000')) + parts = urlparse( + config.get('ckan.site_url', 'http://0.0.0.0:5000')) request_config = routes_request_config() request_config.host = str(parts.netloc + parts.path) request_config.protocol = str(parts.scheme) diff --git a/ckan/lib/captcha.py b/ckan/lib/captcha.py index 7a34d6ba212..aff2df033ac 100644 --- a/ckan/lib/captcha.py +++ b/ckan/lib/captcha.py @@ -13,7 +13,8 @@ def check_recaptcha(request): # Recaptcha not enabled return - client_ip_address = request.environ.get('REMOTE_ADDR', 'Unknown IP Address') + client_ip_address = request.environ.get( + 'REMOTE_ADDR', 'Unknown IP Address') # reCAPTCHA v2 recaptcha_response_field = request.form.get('g-recaptcha-response', '') @@ -37,5 +38,6 @@ def check_recaptcha(request): # Something weird with recaptcha response raise CaptchaError() + class CaptchaError(ValueError): pass diff --git a/ckan/lib/search/__init__.py b/ckan/lib/search/__init__.py index 2520410bcc4..09967501573 100644 --- a/ckan/lib/search/__init__.py +++ b/ckan/lib/search/__init__.py @@ -315,8 +315,10 @@ def check_solr_schema_version(schema_file=None): version = tree.documentElement.getAttribute('version') if not len(version): - raise SearchError('Could not extract version info from the SOLR' - ' schema, using file: \n%s' % url) + msg = 'Could not extract version info from the SOLR schema' + if schema_file: + msg =+ ', using file {}'.format(schema_file) + raise SearchError(msg) if not version in SUPPORTED_SCHEMA_VERSIONS: raise SearchError('SOLR schema version not supported: %s. Supported' diff --git a/ckanext/datapusher/logic/action.py b/ckanext/datapusher/logic/action.py index 81545e67d4a..ce93fd24d28 100644 --- a/ckanext/datapusher/logic/action.py +++ b/ckanext/datapusher/logic/action.py @@ -65,7 +65,7 @@ def datapusher_submit(context, data_dict): callback_url_base = config.get('ckan.datapusher.callback_url_base') if callback_url_base: - callback_url = urlparse.urljoin( + callback_url = urljoin( callback_url_base.rstrip('/'), '/api/3/action/datapusher_hook') else: callback_url = h.url_for( @@ -123,7 +123,7 @@ def datapusher_submit(context, data_dict): try: r = requests.post( - urlparse.urljoin(datapusher_url, 'job'), + urljoin(datapusher_url, 'job'), headers={ 'Content-Type': 'application/json' }, @@ -289,7 +289,7 @@ def datapusher_status(context, data_dict): job_detail = None if job_id: - url = urlparse.urljoin(datapusher_url, 'job' + '/' + job_id) + url = urljoin(datapusher_url, 'job' + '/' + job_id) try: r = requests.get(url, headers={'Content-Type': 'application/json', 'Authorization': job_key})