Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
upgrade knesset-data to v1.2.0 with support for better exception hand…
Browse files Browse the repository at this point in the history
…ling + minor improvements to slack notifications
  • Loading branch information
OriHoch committed Jun 24, 2016
1 parent e4b095e commit e2a5d2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ data/committee_mms_videos
/node_modules
notebooks/
npm-debug.log
*.egg-info
15 changes: 8 additions & 7 deletions committees/management/commands/scrape_committee_meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}'

Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions knesset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "----"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e2a5d2e

Please sign in to comment.