3 Star 0 Fork 0

张利利 / diningPos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
getLicenseFile.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
zll 提交于 2021-10-21 16:00 . 增加授权业务逻辑
import base64, json, pickle
def get_license(src_fileName, dest_fileName):
src_contents = ''
try:
with open(src_fileName, encoding='utf-8') as f:
src_contents = f.read()
src_contents = json.loads(src_contents)
if len(src_contents) < 2:
print(f'原始授权文件异常, path={src_fileName}')
return
src_contents = bytes('{}'.format(src_contents), 'utf-8')
dest_contents = base64.encodebytes(src_contents)
dest_str = pickle.dumps(dest_contents).decode('latin1')
with open(dest_fileName, 'w', encoding='utf-8') as f:
f.write(dest_str)
print(f'已生成授权文件{dest_fileName}')
except FileNotFoundError:
msg = f'授权原始文件{src_fileName}不存在...'
print('synlog=', msg)
except PermissionError:
msg = f'授权原始文件{src_fileName}存在但没有权限访问...'
print('synlog=', msg)
except Exception as e:
msg = f'异常{str(e)}...'
print('synlog=', msg)
if __name__ == '__main__':
get_license('./diningpos_license', './diningpos_licensees')
Python
1
https://gitee.com/ll.zhangll/dining-pos.git
git@gitee.com:ll.zhangll/dining-pos.git
ll.zhangll
dining-pos
diningPos
master

搜索帮助