Commit 1c54c989 authored by wanliofficial's avatar wanliofficial

更新epk打包工具

parent 806e0d66
......@@ -38,9 +38,9 @@ class AppsManager(object):
if not editor:
return False, "current user is not exists"
result = Apps.get(app_name=data.get("app_name"), is_delete=False)
if result:
return False, "app_name has been exists."
# result = Apps.select(app_name=data.get("app_name"), is_delete=False).count()
# if result < 1:
# return False, "app_name has been exists."
data.update({
'create_by': editor,
......
......@@ -97,21 +97,35 @@ class EpkApp(object):
with open(fpath, "rb") as f:
filecontent = f.read()
print(fpath)
newmd5 = self.md5(filecontent)
print(md5path)
with open(md5path, "wb") as f:
f.write(newmd5)
return newmd5
def sign(self, content):
ret = b""
for i in range(int(len(content) / 2 )):
ret += struct.pack("<B", int("0x%s" % (content[i*2:i*2+2]), 16))
ret = ret + b'EVM is NB ++!'
return ret
def md5(self, filecontent):
md5 = hashlib.md5() #获取一个md5加密算法对象
md5.update(filecontent) #指定需要加密的字符串
newmd5 = md5.hexdigest() #获取加密后的16进制字符串
newmd5 = ''
content = filecontent
for i in range(3):
md5 = hashlib.md5() #获取一个md5加密算法对象
md5.update(content) #指定需要加密的字符串
newmd5 = md5.hexdigest() #获取加密后的16进制字符串
print(newmd5)
content = self.sign(newmd5)
ret = b""
for i in range(int(len(newmd5) / 2 )):
ret += struct.pack("<B", int("0x%s" % (newmd5[i*2:i*2+2]), 16))
return ret
def packFile(self, info, level=9):
......@@ -119,6 +133,7 @@ class EpkApp(object):
fpath = os.sep.join([self._appDir, fname])
fext = info["ext"]
fileBytes = b""
if fext == "md5":
fileBytes += struct.pack("<B", 1)
......@@ -132,9 +147,17 @@ class EpkApp(object):
with open(fpath, "rb") as fc:
fileContentBytes = fc.read()
print(info["name"])
print(len(fileContentBytes))
fileBytes += struct.pack("<L", len(fileContentBytes))
fileCompressBytes = zlib.compress(fileContentBytes, level)
if fext == "md5":
fileCompressBytes = fileContentBytes
else:
fileCompressBytes = zlib.compress(fileContentBytes, level)
print(len(fileCompressBytes))
fileBytes += struct.pack("<L", len(fileCompressBytes))
......@@ -191,7 +214,6 @@ class EpkApp(object):
result = ret
return result
def main(path, appName):
epk = EpkApp(appName, path)
epk.pack()
......
......@@ -111,7 +111,6 @@ def build_app(id):
return response_result(ResponseCode.NOTHING_CHANGE, msg=message)
@apps_api.route("/getBuildApp/<uuid:id>", methods=['POST'])
@validate_schema(LogAddScheme)
@Auth.auth_required
def get_build_app(id):
user = request.current_user.get("id")
......
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