comparison py/params.py @ 148:b32e5a11a4cb

few updates, seems to run
author Matt Johnston <matt@ucc.asn.au>
date Sat, 15 Dec 2012 23:49:08 +0800
parents 6517ddee3187
children d03157c7ad60
comparison
equal deleted inserted replaced
147:ab1e7bf77d69 148:b32e5a11a4cb
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 import collections 2 import collections
3 import json 3 import json
4 import config 4 import config
5 from utils import W,L,E,EX
5 6
6 _FIELD_DEFAULTS = { 7 _FIELD_DEFAULTS = {
7 'fridge_setpoint': 16, 8 'fridge_setpoint': 16,
8 'fridge_difference': 0.2, 9 'fridge_difference': 0.2,
9 'overshoot_delay': 720, # 12 minutes 10 'overshoot_delay': 720, # 12 minutes
25 self[k] 26 self[k]
26 self[k] = v 27 self[k] = v
27 28
28 def load(self, f = None): 29 def load(self, f = None):
29 if not f: 30 if not f:
30 f = file(config.PARAMS_FILE, 'r') 31 try:
32 f = file(config.PARAMS_FILE, 'r')
33 except IOError, e:
34 W("Missing parameter file, using defaults. %s", e)
35 return
31 u = json.load(f) 36 u = json.load(f)
32 for k in u: 37 for k in u:
33 if k not in self: 38 if k not in self:
34 raise self.Error("Unknown parameter %s=%s in file '%s'" % (str(k), str(u[k]), getattr(f, 'name', '???'))) 39 raise self.Error("Unknown parameter %s=%s in file '%s'" % (str(k), str(u[k]), getattr(f, 'name', '???')))
35 self.update(u) 40 self.update(u)