mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-01 19:16:15 -04:00
reveal bad value when job conf validation fails
This commit is contained in:
parent
060adaffd0
commit
597f2b5b33
2 changed files with 11 additions and 4 deletions
|
@ -43,13 +43,20 @@ class JobValidator(cerberus.Validator):
|
|||
return url.scheme in ('http', 'https', 'ftp')
|
||||
|
||||
class InvalidJobConf(Exception):
|
||||
def __init__(self, errors):
|
||||
self.errors = errors
|
||||
def __init__(self, validator):
|
||||
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()):
|
||||
v = JobValidator(schema)
|
||||
if not v.validate(job_conf, normalize=False):
|
||||
raise InvalidJobConf(v.errors)
|
||||
raise InvalidJobConf(v)
|
||||
|
||||
def merge(a, b):
|
||||
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(
|
||||
name='brozzler',
|
||||
version='1.5.16',
|
||||
version='1.5.17',
|
||||
description='Distributed web crawling with browsers',
|
||||
url='https://github.com/internetarchive/brozzler',
|
||||
author='Noah Levitt',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue