feat: 支持对开启SSL/TLS的MongoDb数据库改密

pull/8856/head
jiangweidong 2022-09-09 19:05:36 +08:00 committed by Jiangjie.Bai
parent 6bbbe312a2
commit 556bd3682e
1 changed files with 19 additions and 0 deletions

View File

@ -4,6 +4,10 @@ import csv
import pyzipper
import requests
from hashlib import md5
from django.conf import settings
def create_csv_file(filename, headers, rows, ):
with open(filename, 'w', encoding='utf-8-sig')as f:
@ -28,3 +32,18 @@ def download_file(src, path):
with open(path, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
def save_content_to_temp_path(content, file_mode=0o400):
if not content:
return
project_dir = settings.PROJECT_DIR
tmp_dir = os.path.join(project_dir, 'tmp')
filename = '.' + md5(content.encode('utf-8')).hexdigest()
filepath = os.path.join(tmp_dir, filename)
if not os.path.exists(filepath):
with open(filepath, 'w') as f:
f.write(content)
os.chmod(filepath, file_mode)
return filepath