kopia lustrzana https://github.com/jbruce12000/kiln-controller
less print(), more logging
rodzic
6ae5d7ce95
commit
cd14933a04
2
oven.py
2
oven.py
|
@ -221,7 +221,7 @@ class TempSensorSimulate(TempSensor):
|
|||
|
||||
#temperature change of oven by cooling to env
|
||||
t -= p_env *self.time_step / c_oven
|
||||
print "-> %dW heater: %.0f -> %dW oven: %.0f -> %dW env"%(int(p_heat * self.oven.heat),t_h,int(p_ho),t,int(p_env))
|
||||
log.debug("energy sim: -> %dW heater: %.0f -> %dW oven: %.0f -> %dW env"%(int(p_heat * self.oven.heat),t_h,int(p_ho),t,int(p_env)))
|
||||
self.temperature = t
|
||||
|
||||
time.sleep(self.sleep_time)
|
||||
|
|
|
@ -34,8 +34,6 @@ def send_static(filename):
|
|||
def get_websocket_from_request():
|
||||
env = bottle.request.environ;
|
||||
wsock = env.get('wsgi.websocket')
|
||||
print wsock.path
|
||||
print wsock.origin
|
||||
if not wsock:
|
||||
abort(400, 'Expected WebSocket request.')
|
||||
return wsock
|
||||
|
@ -84,7 +82,7 @@ def handle_storage():
|
|||
message = wsock.receive()
|
||||
if not message:
|
||||
break
|
||||
print message
|
||||
log.debug("websocket (storage) received: %s"%message)
|
||||
|
||||
try:
|
||||
msgdict = json.loads(message)
|
||||
|
@ -104,7 +102,8 @@ def handle_storage():
|
|||
msgdict["resp"]="OK"
|
||||
else:
|
||||
msgdict["resp"]="FAIL"
|
||||
print "sending:" +str(msgdict)
|
||||
log.debug("websocket (storage) sent: %s"%message)
|
||||
|
||||
wsock.send(json.dumps(msgdict))
|
||||
wsock.send(get_profiles())
|
||||
except WebSocketError:
|
||||
|
@ -143,13 +142,12 @@ def save_profile(profile, force=False):
|
|||
filename = profile['name']+".json"
|
||||
filepath = os.path.join(profile_path,filename)
|
||||
if not force and os.path.exists(filepath):
|
||||
print "Didnt write"
|
||||
log.error("Could not write, %s already exists"%filepath)
|
||||
return False
|
||||
with open(filepath, 'w+') as f:
|
||||
print filepath
|
||||
f.write(profile_json)
|
||||
f.close()
|
||||
print "Did write"
|
||||
log.info("Wrote %s"%filepath)
|
||||
return True
|
||||
|
||||
def main():
|
||||
|
|
Ładowanie…
Reference in New Issue