diff --git a/.gitignore b/.gitignore index c20725c6..c5a53f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ data/committee_mms_videos /node_modules notebooks/ npm-debug.log +*.egg-info diff --git a/committees/management/commands/scrape_committee_meetings.py b/committees/management/commands/scrape_committee_meetings.py index b945bacd..3aa84b5e 100644 --- a/committees/management/commands/scrape_committee_meetings.py +++ b/committees/management/commands/scrape_committee_meetings.py @@ -10,8 +10,9 @@ from mks.utils import get_all_mk_names from simple.scrapers import hebrew_strftime from simple.scrapers.management import BaseKnessetDataserviceCommand -from knesset.utils import send_chat_notification +from knesset.utils import send_chat_notification, send_chat_exception_notification import traceback +from knesset_data.dataservice.exceptions import KnessetDataServiceRequestException ERR_MSG = 'failed to get meetings for committee {}' @@ -88,17 +89,17 @@ def _get_meetings(self, committee_id, from_date, to_date): try: meetings = DataserviceCommitteeMeeting.get(committee_id, from_date, to_date) return meetings - except Exception as e: + except KnessetDataServiceRequestException as e: err_msg = ERR_MSG.format(committee_id) err_msg_report = ERR_MSG_REPORT.format(committee_id, str(e)) DataserviceCommitteeMeeting.error_report(err_msg, err_msg_report) self._log_error(err_msg) - send_chat_notification(__name__, - "Received unexpected exception from DataServiceCommitteeMeeting.get()", - {'exception': traceback.format_exc(), - 'committee_id': committee_id, + send_chat_exception_notification(__name__, + "Failed to fetch from committee meetings knesset dataservice", + {'committee_id': committee_id, 'from_date': from_date, - 'to_date': to_date}) + 'to_date': to_date, + 'url': e.url}, e) return [] @staticmethod diff --git a/knesset/utils.py b/knesset/utils.py index f3cd3126..899d37fa 100644 --- a/knesset/utils.py +++ b/knesset/utils.py @@ -178,10 +178,8 @@ def reverse_with_query(viewname, args=None, kwargs=None, query_kwargs=None): def send_chat_notification(file, text, data): from django_slack import slack_message + text = ("{text}\n{data}\n-- {file}").format(file=file, text=text, data=data) if getattr(settings, 'SLACK_BACKEND', None) in (None, 'django_slack.backends.DisabledBackend'): - text = ("{text}\n" - "{data}\n" - "-- {file}").format(file=file, text=text, data=data) print "-- SLACK MESSAGE" print text print "----" diff --git a/requirements.txt b/requirements.txt index 220fa5f8..89f63833 100644 --- a/requirements.txt +++ b/requirements.txt @@ -54,7 +54,7 @@ pyjwt django-sslserver python-hebrew-numbers==0.1.0 git+https://github.com/turnkeylinux/octohub.git -knesset-data==1.0.0 +knesset-data==1.2.0 django-waffle==0.11 django-import-export==0.4.2