comparison py/params.py @ 561:54ef7f84487d

actually update values
author Matt Johnston <matt@ucc.asn.au>
date Wed, 10 Jun 2015 00:10:08 +0800
parents c5f8375b12a2
children
comparison
equal deleted inserted replaced
560:18e6e830ca26 561:54ef7f84487d
104 return False 104 return False
105 105
106 dir = os.path.dirname(config.PARAMS_FILE) 106 dir = os.path.dirname(config.PARAMS_FILE)
107 try: 107 try:
108 t = tempfile.NamedTemporaryFile(prefix='config', 108 t = tempfile.NamedTemporaryFile(prefix='config',
109 mode='w+t', 109 mode='w+t', # NamedTemporaryFile is binary by default
110 dir = dir, 110 dir = dir,
111 delete = False) 111 delete = False)
112 112
113 out = json.dumps(params, sort_keys=True, indent=4)+'\n' 113 out = json.dumps(params, sort_keys=True, indent=4)+'\n'
114 t.write(out) 114 t.write(out)
115 name = t.name 115 name = t.name
116 t.close() 116 t.close()
117 117
118 os.rename(name, config.PARAMS_FILE) 118 os.rename(name, config.PARAMS_FILE)
119 return True
120 except Exception as e: 119 except Exception as e:
121 EX("Problem: %s" % e) 120 EX("Problem: %s" % e)
122 return False 121 return False
123 122
123 self.update(params)
124 L("Received parameters")
125 L(self.save_string())
126 return True
127
124 def save_string(self): 128 def save_string(self):
125 return json.dumps(self, sort_keys=True, indent=4) 129 return json.dumps(self, sort_keys=True, indent=4)