Commit 2a306825 authored by wanli's avatar wanli

feat: 更新utils/epk.py

parent ee4278d4
......@@ -343,6 +343,6 @@ class AppsManager(object):
with open(os.sep.join([target_dir, "epk.json"]), "w") as f:
json.dump(app.to_dict(exclude=["uuid", "create_at", "update_at", "delete_at"]), f)
return { 'app_name': app.app_name, 'app_file': "{}.epk".format(app.app_name), 'app_url': parse.urljoin(config['UPLOAD_SERVER'], epk_path) }, "application build {}.".format("success" if app_info else "fail")
return { 'app_name': app.app_name, 'app_file': "{}.epk".format(app.app_name), 'file_length': app_info.get("fileLength", 0), 'app_url': parse.urljoin(config['UPLOAD_SERVER'], epk_path) }, "application build {}.".format("success" if app_info else "fail")
appsManager = AppsManager()
......@@ -65,6 +65,7 @@ class EpkApp(object):
self._appName = appName
self._appDir = os.path.abspath(appDir)
self.algorithm = algorithm
self.fileLength = 0
eprint(sys.argv)
eprint(appName)
eprint(appDir)
......@@ -106,7 +107,7 @@ class EpkApp(object):
fsize = jspath.info.size
fbasename, fext = os.path.splitext(jspath.info.name)
if fext in ["", ".exe", ".dll", ".nv", ".conf"]:
if fext in [".exe", ".dll", ".nv", ".conf"]:
continue
finfo = {
......@@ -122,6 +123,7 @@ class EpkApp(object):
files.insert(0, finfo)
else:
files.append(finfo)
if fext == ".evue":
self.fileMD5(finfo)
......@@ -143,9 +145,9 @@ class EpkApp(object):
filecontent = f.read()
newmd5 = self.md5(filecontent)
with open(md5path, "wb") as f:
f.write(newmd5)
return newmd5
def sign(self, content):
......@@ -187,10 +189,12 @@ class EpkApp(object):
fileBytes += struct.pack("<B", len(_name))
fileBytes += struct.pack("<%ds" % len(_name), fname.encode("utf-8"))
with open(fpath, "rb") as fc:
fileContentBytes = fc.read()
eprint(info["name"])
eprint(len(fileContentBytes))
self.fileLength += len(fileContentBytes)
fileBytes += struct.pack("<L", len(fileContentBytes))
if fext == "md5":
......@@ -250,7 +254,8 @@ class EpkApp(object):
"md5": epkmd5Bytes,
"raw_crc": hex(crcBytes),
"compress_level": level,
"buff_length": len(epkFileBytes)
"buff_length": len(epkFileBytes),
"fileLength": self.fileLength
}
pprint.pprint(ret)
......
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