Continue Flask migration.
This commit is contained in:
parent
13394334e9
commit
453ef0f53c
@ -270,30 +270,27 @@ def thermostat_loop():
|
|||||||
# dbconn.close()
|
# dbconn.close()
|
||||||
# break
|
# break
|
||||||
|
|
||||||
xprint(new_forced_mode)
|
|
||||||
if new_forced_mode is not None:
|
if new_forced_mode is not None:
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
data = Set_mode(value=new_forced_mode)
|
data = Set_mode(value=new_forced_mode)
|
||||||
|
try:
|
||||||
db.session.add(data)
|
db.session.add(data)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# try:
|
return "OK", 201
|
||||||
# db.session.add(data)
|
except sqlalchemy.exc.IntegrityError as e:
|
||||||
# db.session.commit()
|
try:
|
||||||
# return "OK", 201
|
db.session.rollback()
|
||||||
# except sqlalchemy.exc.IntegrityError as e:
|
cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
||||||
# try:
|
cur_mode = data
|
||||||
# db.session.rollback()
|
db.session.commit()
|
||||||
# cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
except Exception as e:
|
||||||
# cur_mode = data
|
db.session.rollback()
|
||||||
# db.session.commit()
|
logging.error(e)
|
||||||
# except Exception as e:
|
return "K0", 400
|
||||||
# db.session.rollback()
|
except Exception as e:
|
||||||
# logging.error(e)
|
db.session.rollback()
|
||||||
# return "K0", 400
|
logging.error(e)
|
||||||
# except Exception as e:
|
return "K0", 400
|
||||||
# db.session.rollback()
|
|
||||||
# logging.error(e)
|
|
||||||
# return "K0", 400
|
|
||||||
|
|
||||||
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
||||||
#dbconn.commit()
|
#dbconn.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user