From ee4ca272da5e495117980b31094cf428f37e2388 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 15 Sep 2015 22:58:23 +0300 Subject: Fix local_rules IOError --- servo/tasks.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3