aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-09-15 22:58:23 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-09-15 22:58:23 +0300
commitee4ca272da5e495117980b31094cf428f37e2388 (patch)
tree5b13413c4108af4d06bbf08cdb3b762839626bff
parentbdc2f489b17319d961336f1a128b35a8c40b6f30 (diff)
downloadServo-ee4ca272da5e495117980b31094cf428f37e2388.tar.gz
Servo-ee4ca272da5e495117980b31094cf428f37e2388.tar.bz2
Servo-ee4ca272da5e495117980b31094cf428f37e2388.zip
Fix local_rules IOError
-rw-r--r--servo/tasks.py12
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