Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more feedback for invalid url_data. #39

Merged
merged 2 commits into from
Jan 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions barking_owl/scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ def __init__(self, file_header_size=1024, max_bandwidth=-1,
self._error_callback = None

def set_url_data(self, url_data):
if (not 'target_url' in url_data) or \
(not 'doc_types' in url_data) or \
(not 'title' in url_data) or \
(not 'description' in url_data) or \
(not 'max_link_level' in url_data) or \
(not 'creation_datetime' in url_data) or \
(not 'allowed_domains' in url_data):
raise Exception("Invalid url_data payload.")
required = [
'target_url',
'doc_types',
'title',
'description',
'max_link_level',
'creation_datetime',
'allowed_domains',
]
for key in required:
if key not in url_data:
raise Exception("Invalid url_data. %r is required." % key)

self._data['url_data'] = url_data
self._data_loaded = True

Expand Down
10 changes: 7 additions & 3 deletions barking_owl/scraper/scraperwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ def log(text, DEBUG=False):

class ScraperWrapper(threading.Thread):

def __init__(self,address='localhost',exchange='barkingowl',
broadcast_interval=5,url_parameters=None, uid=str(uuid.uuid4()), \
,DEBUG=False):
def __init__(self,
address='localhost',
exchange='barkingowl',
broadcast_interval=5,
url_parameters=None,
uid=str(uuid.uuid4()),
DEBUG=False):

threading.Thread.__init__(self)

Expand Down