Commit 37574987 authored by wanli's avatar wanli

update

parent 9e94ef6b
...@@ -86,6 +86,9 @@ class AppsManager(object): ...@@ -86,6 +86,9 @@ class AppsManager(object):
epk_filename = os.sep.join([target_dir.replace(config.get("UPLOAD_PATH"), ""), "{}.epk".format(app.app_name)]).replace('\\', '/') epk_filename = os.sep.join([target_dir.replace(config.get("UPLOAD_PATH"), ""), "{}.epk".format(app.app_name)]).replace('\\', '/')
app_info['md5'] = str(app_info['md5']) app_info['md5'] = str(app_info['md5'])
app_info.update({ "epk_size": os.path.getsize(os.sep.join([config.get("UPLOAD_PATH"), epk_filename])) })
result = BuildLogs(app=app, app_path=epk_filename, app_info=app_info, create_by=editor, create_at=datetime.now(), update_by=editor, update_at=datetime.now()) result = BuildLogs(app=app, app_path=epk_filename, app_info=app_info, create_by=editor, create_at=datetime.now(), update_by=editor, update_at=datetime.now())
commit() commit()
...@@ -137,8 +140,9 @@ class AppsManager(object): ...@@ -137,8 +140,9 @@ class AppsManager(object):
if result and len(result): if result and len(result):
temp = [] temp = []
for item in result: for item in result:
t = item.to_dict(with_collections=True, related_objects=True, exclude=["app_annex", "app_download", "app_icon", "app_build_log", "is_delete", "delete_by", "delete_at"]) t = item.to_dict(with_collections=True, related_objects=True, exclude=["app_annex", "app_download", "app_icon", "is_delete", "delete_by", "delete_at"])
t.update({ t.update({
"app_build_log": item.app_build_log.to_dict(exclude=["is_delete", "delete_by", "delete_at", "create_by", "update_by"]),
"create_by": item.create_by.to_dict(only=["uuid", "username"]), "create_by": item.create_by.to_dict(only=["uuid", "username"]),
"update_by": item.update_by.to_dict(only=["uuid", "username"]), "update_by": item.update_by.to_dict(only=["uuid", "username"]),
"create_at": item.create_at.strftime("%Y-%m-%d %H:%M:%S") if item.create_at else None, "create_at": item.create_at.strftime("%Y-%m-%d %H:%M:%S") if item.create_at else None,
......
...@@ -101,10 +101,8 @@ class DownloadManager(object): ...@@ -101,10 +101,8 @@ class DownloadManager(object):
return False, "app not found" return False, "app not found"
tmp = app.to_dict(with_collections=True, related_objects=True) tmp = app.to_dict(with_collections=True, related_objects=True)
if tmp.get("app_build_log"): if tmp.get("app_build_log"):
epk_path = convert_url_to_local_path(tmp.get("app_build_log")[0].app_path) epk_path = convert_url_to_local_path(tmp.get("app_build_log")[0].app_path)
if not os.path.exists(epk_path): if not os.path.exists(epk_path):
return False, "epk file not found" return False, "epk file not found"
......
...@@ -25,7 +25,7 @@ class Apps(db.Entity): ...@@ -25,7 +25,7 @@ class Apps(db.Entity):
app_desc = Optional(str, default="") app_desc = Optional(str, default="")
app_annex = Set("Annex", reverse="app", cascade_delete=True) app_annex = Set("Annex", reverse="app", cascade_delete=True)
app_user = Optional("AppUser", reverse="app", cascade_delete=True) app_user = Optional("AppUser", reverse="app", cascade_delete=True)
app_build_log = Set("BuildLogs", reverse="app", cascade_delete=True) app_build_log = Optional("BuildLogs", reverse="app", cascade_delete=True)
app_download = Set("AppDownload", reverse="app", cascade_delete=True) app_download = Set("AppDownload", reverse="app", cascade_delete=True)
create_at = Required(datetime, default=datetime.now) create_at = Required(datetime, default=datetime.now)
create_by = Required("User", reverse='apps_creator') # BuildLogs与User一对一关系 create_by = Required("User", reverse='apps_creator') # BuildLogs与User一对一关系
......
...@@ -13,7 +13,7 @@ class BuildLogs(db.Entity): ...@@ -13,7 +13,7 @@ class BuildLogs(db.Entity):
_table_ = "{}".format(config['TABLE_PREFIX']) + "build_logs" _table_ = "{}".format(config['TABLE_PREFIX']) + "build_logs"
id = PrimaryKey(int, auto=True) id = PrimaryKey(int, auto=True)
uuid = Required(uuid.UUID, unique=True, default=uuid.uuid1, index=True) uuid = Required(uuid.UUID, unique=True, default=uuid.uuid1, index=True)
app = Optional("Apps", reverse="app_build_log") app = Required("Apps", reverse="app_build_log")
app_path = Optional(str, default="") app_path = Optional(str, default="")
app_info = Optional(Json, default={}) app_info = Optional(Json, default={})
create_at = Required(datetime, default=datetime.now) create_at = Required(datetime, default=datetime.now)
......
...@@ -56,11 +56,11 @@ def get(): ...@@ -56,11 +56,11 @@ def get():
print(message) print(message)
# 读取epk文件,按照格式返回相应结构体数据 # 读取epk文件,按照格式返回相应结构体数据
ret = "" ret = ""
if os.path.exists(result): if isinstance(result, str) and os.path.exists(result):
with open(result, "rb") as f: with open(result, "rb") as f:
ret = f.read() ret = f.read()
return ret return ret
return response_result(ResponseCode.SERVER_ERROR, msg="file not found: %s" % "") return response_result(ResponseCode.SERVER_ERROR, msg="file not found")
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
logger.error(str(e)) logger.error(str(e))
......
...@@ -39,6 +39,11 @@ ...@@ -39,6 +39,11 @@
label="应用路径" label="应用路径"
width="120" width="120"
></el-table-column> ></el-table-column>
<el-table-column
prop="epk_size"
label="应用大小"
width="120"
></el-table-column>
<el-table-column <el-table-column
prop="app_desc" prop="app_desc"
label="应用描述" label="应用描述"
...@@ -307,7 +312,13 @@ export default { ...@@ -307,7 +312,13 @@ export default {
getAppsList(params) getAppsList(params)
.then((res) => { .then((res) => {
this.total = res.count; this.total = res.count;
this.list = res.data; this.list = res.data.map((item) => {
if (item.app_build_log && item.app_build_log.app_info)
item.epk_size =
(item.app_build_log.app_info.epk_size / 1024).toFixed(2) + "KB";
else item.epk_size = "";
return item;
});
}) })
.catch((err) => { .catch((err) => {
// this.$message.error(err.message) // this.$message.error(err.message)
......
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