Commit 1c54c989 authored by wanliofficial's avatar wanliofficial

更新epk打包工具

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