更新 Healthbeat.py
parent
39c73fa3f2
commit
1b36e1f528
|
|
@ -27,13 +27,13 @@ class Camera:
|
||||||
else:
|
else:
|
||||||
logging.warning("摄像头ID: %s, 状态: 离线" % (self.id))
|
logging.warning("摄像头ID: %s, 状态: 离线" % (self.id))
|
||||||
|
|
||||||
if (status == 1 and self.status == 2) or (status == 2 and self.status == 1):
|
#if (status == 1 and self.status == 2) or (status == 2 and self.status == 1):
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
|
|
||||||
with conn:
|
with conn:
|
||||||
with conn.cursor() as cursor:
|
with conn.cursor() as cursor:
|
||||||
cursor.execute("update devices set state = %s, updated_at = %s where id = %s", (status, datetime.datetime.now(), self.id))
|
cursor.execute("update devices set state = %s, updated_at = %s where id = %s", (status, datetime.datetime.now(), self.id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def init_logger():
|
def init_logger():
|
||||||
logging.basicConfig(filename='healthbeat.log', level=logging.INFO, format='[%(asctime)s] %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
logging.basicConfig(filename='healthbeat.log', level=logging.INFO, format='[%(asctime)s] %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue