aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
Diffstat (limited to 'servo')
-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