diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-09-15 22:58:23 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-09-15 22:58:23 +0300 |
commit | ee4ca272da5e495117980b31094cf428f37e2388 (patch) | |
tree | 5b13413c4108af4d06bbf08cdb3b762839626bff /servo | |
parent | bdc2f489b17319d961336f1a128b35a8c40b6f30 (diff) | |
download | Servo-ee4ca272da5e495117980b31094cf428f37e2388.tar.gz Servo-ee4ca272da5e495117980b31094cf428f37e2388.tar.bz2 Servo-ee4ca272da5e495117980b31094cf428f37e2388.zip |
Fix local_rules IOError
Diffstat (limited to 'servo')
-rw-r--r-- | servo/tasks.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/servo/tasks.py b/servo/tasks.py index f788530..276f5ae 100644 --- a/servo/tasks.py +++ b/servo/tasks.py @@ -4,14 +4,24 @@ from __future__ import absolute_import from celery import shared_task +from django.conf import settings from django.core.cache import cache from servo.models import Order, Note def get_rules(): + """ + Get the rules from the JSON file and cache them. + Fail silently if not configured. + """ import json - fh = open("local_rules.json", "r") + + try: + fh = open("local_rules.json", "r") + except IOError: + return [] + rules = json.load(fh) cache.set('rules', rules) return rules |