Commit 2a306825 authored by wanli's avatar wanli

feat: 更新utils/epk.py

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