mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 00:29:53 -05:00
reveal bad value when job conf validation fails
This commit is contained in:
parent
060adaffd0
commit
597f2b5b33
@ -43,13 +43,20 @@ class JobValidator(cerberus.Validator):
|
|||||||
return url.scheme in ('http', 'https', 'ftp')
|
return url.scheme in ('http', 'https', 'ftp')
|
||||||
|
|
||||||
class InvalidJobConf(Exception):
|
class InvalidJobConf(Exception):
|
||||||
def __init__(self, errors):
|
def __init__(self, validator):
|
||||||
self.errors = errors
|
self.errors = validator.errors
|
||||||
|
try:
|
||||||
|
# Cerberus does a nice job hiding the bad value. In the case I
|
||||||
|
# debugged, I found it here. Maybe there's a better way to see it.
|
||||||
|
value = validator._errors[0].info[0][0].info[0][0].value
|
||||||
|
self.errors['bad value'] = value
|
||||||
|
except:
|
||||||
|
value = None
|
||||||
|
|
||||||
def validate_conf(job_conf, schema=load_schema()):
|
def validate_conf(job_conf, schema=load_schema()):
|
||||||
v = JobValidator(schema)
|
v = JobValidator(schema)
|
||||||
if not v.validate(job_conf, normalize=False):
|
if not v.validate(job_conf, normalize=False):
|
||||||
raise InvalidJobConf(v.errors)
|
raise InvalidJobConf(v)
|
||||||
|
|
||||||
def merge(a, b):
|
def merge(a, b):
|
||||||
if isinstance(a, dict) and isinstance(b, dict):
|
if isinstance(a, dict) and isinstance(b, dict):
|
||||||
|
2
setup.py
2
setup.py
@ -32,7 +32,7 @@ def find_package_data(package):
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='brozzler',
|
name='brozzler',
|
||||||
version='1.5.16',
|
version='1.5.17',
|
||||||
description='Distributed web crawling with browsers',
|
description='Distributed web crawling with browsers',
|
||||||
url='https://github.com/internetarchive/brozzler',
|
url='https://github.com/internetarchive/brozzler',
|
||||||
author='Noah Levitt',
|
author='Noah Levitt',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user