feat: 密码计划邮件提醒

This commit is contained in:
feng626
2021-12-03 15:50:04 +08:00
committed by Jiangjie.Bai
parent e0d4ad8570
commit adb9f01231
10 changed files with 197 additions and 71 deletions

19
apps/common/utils/file.py Normal file
View File

@@ -0,0 +1,19 @@
import os
import csv
import pyzipper
def create_csv_file(filename, headers, rows, ):
with open(filename, 'w', encoding='utf-8-sig')as f:
w = csv.writer(f)
w.writerow(headers)
w.writerows(rows)
def encrypt_and_compress_zip_file(filename, secret_password, encrypted_filename):
with pyzipper.AESZipFile(
filename, 'w', compression=pyzipper.ZIP_LZMA, encryption=pyzipper.WZ_AES
) as zf:
zf.setpassword(secret_password)
with open(encrypted_filename, 'rb') as f:
zf.writestr(os.path.basename(encrypted_filename), f.read())