Commit 99ac4114 authored by wanli's avatar wanli

update

parent 0e595fb3
'''
Author: your name
Date: 2021-06-28 16:56:59
LastEditTime: 2021-06-28 17:20:52
LastEditTime: 2021-06-29 17:38:25
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \ewebengine\tools\evm_monitor\controller.py
'''
from database import session, System, Lvgl, Evm, Image
from database import session, System, Lvgl, Evm, Image, Watch
class SystemResource(object):
def get(self):
......@@ -16,7 +16,6 @@ class SystemResource(object):
return result
def post(self, params):
print("============>", params)
result = System(**params)
session.add(result)
return session.commit()
......@@ -72,9 +71,10 @@ class ImageResource(object):
session.add(result)
return session.commit()
def post_array(self, array):
def post_array(self, array, watch):
t = []
for a in array:
a.update({ "watch": watch })
t.append(Image(**a))
session.add_all(t)
return session.commit()
......@@ -91,19 +91,37 @@ evmResource = EvmResource()
imageResource = ImageResource()
def insert_data(msg):
# 先判断手表imei是否存在,不存在则先注册手表IMEI
watch_id = -1
if msg.get("imei"):
result = session.query(Watch).filter_by(imei=msg.get("imei")).first()
if result:
watch_id = result.id
else:
result = Watch(imei=msg.get("imei"))
session.add(result)
session.flush()
session.commit()
result = session.query(Watch).filter_by(imei=msg.get("imei")).first()
if result:
watch_id = result.id
if msg.get("system"):
print(msg.get("system"))
msg.get("system").update({ "watch": watch_id })
res = systemResource.post(msg.get("system"))
print("!!!!!!", res)
if msg.get("lvgl"):
msg.get("lvgl").update({ "watch": watch_id })
res = lvglResource.post(msg.get("lvgl"))
print("@@@@@@", res)
if msg.get("evm"):
msg.get("evm").update({ "watch": watch_id })
res = evmResource.post(msg.get("evm"))
print("######", res)
if msg.get("image"):
res = imageResource.post_array(msg.get("image"))
res = imageResource.post_array(msg.get("image"), watch_id)
print("$$$$$$", res)
\ No newline at end of file
'''
Author: your name
Date: 2021-06-28 16:43:12
LastEditTime: 2021-06-28 19:08:29
LastEditTime: 2021-06-29 17:06:11
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \ewebengine\tools\evm_monitor\database.py
......@@ -19,10 +19,17 @@ Base = declarative_base()
def get_current_datetime():
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
class Watch(Base):
__tablename__ = 'monitor_watch'
id = Column(Integer, primary_key=True, autoincrement=True)
imei = Column(String)
create_at = Column(String, default=get_current_datetime)
class System(Base):
__tablename__ = 'monitor_system'
id = Column(Integer, primary_key=True, autoincrement=True)
watch = Column(Integer) # 手表ID
free_size = Column(Integer) # 单位:字节
timestamp = Column(String(50), default=get_current_datetime)
......@@ -30,6 +37,7 @@ class Lvgl(Base):
__tablename__ = 'monitor_lvgl'
id = Column(Integer, primary_key=True, autoincrement=True)
watch = Column(Integer) # 手表ID
total_size = Column(Integer) # 单位:字节
free_cnt = Column(Integer)
free_size = Column(Integer)
......@@ -43,6 +51,7 @@ class Evm(Base):
__tablename__ = 'monitor_evm'
id = Column(Integer, primary_key=True, autoincrement=True)
watch = Column(Integer) # 手表ID
total_size = Column(Integer) # 单位:字节
free_size = Column(Integer)
gc_usage = Column(Integer)
......@@ -56,6 +65,7 @@ class Image(Base):
__tablename__ = 'monitor_image'
id = Column(Integer, primary_key=True, autoincrement=True)
watch = Column(Integer) # 手表ID
uri = Column(String(50))
length = Column(Integer)
png_uncompressed_size = Column(Integer)
......
'''
Author: your name
Date: 2021-06-28 14:39:58
LastEditTime: 2021-06-28 21:12:41
LastEditTime: 2021-06-29 17:33:43
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \ewebengine\tools\evm_monitor\running_monitor.py
......@@ -71,8 +71,8 @@ def pushmessage(func):
self.write_message(msg, binary)
else:
self.write_message(repr(msg), binary)
except WebSocketClosedError as e:
logger.error(e)
self.on_close()
return send
......@@ -138,7 +138,7 @@ class MainHandler(BaseHandler):
self.write(json.dumps({ 'code': 100, 'message': 'success' }))
message = {'system': {'free_size': 0}, 'lvgl': {'total_size': 5242880, 'free_cnt': 31, 'free_size': 1279664, 'free_biggest_size': 1205448, 'used_cnt': 832, 'used_pct': 76, 'frag_pct': 6}, 'evm': {'total_size': 2097152, 'free_size': 0, 'gc_usage': 50}, 'image': [{'uri': 'evue_launcher', 'length': 1043, 'png_total_count': 0, 'png_uncompressed_size': 0, 'png_file_size': 0}, {'uri': 'kdgs_1_storyList', 'length': 9608, 'png_total_count': 193, 'png_uncompressed_size': 370884, 'png_file_size': 209807}]}
message = {'imei': '12345678900005', 'system': {'free_size': 0}, 'lvgl': {'total_size': 5242880, 'free_cnt': 31, 'free_size': 1279664, 'free_biggest_size': 1205448, 'used_cnt': 832, 'used_pct': 76, 'frag_pct': 6}, 'evm': {'total_size': 2097152, 'free_size': 0, 'gc_usage': 50}, 'image': [{'uri': 'evue_launcher', 'length': 1043, 'png_total_count': 0, 'png_uncompressed_size': 0, 'png_file_size': 0}, {'uri': 'kdgs_1_storyList', 'length': 9608, 'png_total_count': 193, 'png_uncompressed_size': 370884, 'png_file_size': 209807}]}
insert_data(message)
NotifyHandler.broadcastMessage(message)
......
......@@ -58,13 +58,13 @@
label="used_cnt"
min-width="180"
>
<template slot-scope="scope">{{ scope.row.used_cnt }}(KB)</template>
<template slot-scope="scope">{{ scope.row.used_cnt }}</template>
</el-table-column>
<el-table-column
label="used_pct"
min-width="180"
>
<template slot-scope="scope">{{ scope.row.used_pct }}(KB)</template>
<template slot-scope="scope">{{ scope.row.used_pct }}(%)</template>
</el-table-column>
<el-table-column
prop="frag_pct"
......@@ -210,10 +210,10 @@ export default {
methods: {
initWebSocket() {
if ("WebSocket" in window) {
this.socket = new WebSocket("ws://127.0.0.1:5001/ws/v1/notify");
// this.socket = new WebSocket(`ws://${window.location.host}/ws/v1/notify`);
this.socket = new WebSocket("ws://localhost:5001/ws/v1/notify");
this.socket.onopen = () => {
console.log("连接成功");
this.sendMsg();
};
this.socket.onmessage = (evt) => {
......
'''
Author: your name
Date: 2021-06-21 14:52:24
LastEditTime: 2021-06-28 09:56:10
LastEditTime: 2021-06-29 16:33:06
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \evm-store\tools\modules\file-manager\main.py
......@@ -10,7 +10,7 @@ FilePath: \evm-store\tools\modules\file-manager\main.py
import os
import shutil
import pprint
from pathlib import PurePosixPath, PureWindowsPath
from pathlib import Path, PurePosixPath, PureWindowsPath
import platform
import json
from fs.osfs import OSFS
......@@ -176,13 +176,6 @@ class FileManager(object):
}
'''
# for root, dirs, files in os.walk(os.getcwd(), topdown=False):
# for name in dirs:
# print(os.path.join(root, name), name)
# for name in files:
# print(os.path.join(root, name), name)
if not target_path.startswith("/"):
target_path = "/" + target_path
......@@ -197,10 +190,15 @@ class FileManager(object):
os.chdir(disk_path)
home_fs = OSFS(os.getcwd())
rp = Path(disk_root)
print("%%%%", rp)
p = Path(disk_path)
for child in p.iterdir():
print("//////////", child.is_dir(), child.resolve(), child.name, child.parent, child.root, child.drive, child.relative_to(rp))
print("------------------->", p)
# 获取当前目录下所有目录、文件、子目录以及子文件的信息。递归获取
for step in home_fs.walk():
print("================>")
result.append({
"basename": os.path.basename(step.path),
"dirname": os.path.dirname(step.path),
......@@ -212,8 +210,6 @@ class FileManager(object):
"type": "dir"
})
print("<================")
home_fs.close()
pprint.pprint(result)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment