Commit 7de8312a authored by litaolemo's avatar litaolemo

update

parent 03a926fd
...@@ -9,7 +9,7 @@ from email.mime.multipart import MIMEMultipart ...@@ -9,7 +9,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication from email.mime.application import MIMEApplication
from email.utils import formataddr from email.utils import formataddr
from maintenance.func_send_email_with_file import send_file_email from maintenance.func_send_email_with_file import send_file_email
import zipfile
es = Elasticsearch([ es = Elasticsearch([
{ {
'host': '172.16.31.17', 'host': '172.16.31.17',
...@@ -19,6 +19,22 @@ es = Elasticsearch([ ...@@ -19,6 +19,22 @@ es = Elasticsearch([
'port': 9200, 'port': 9200,
}]) }])
# def zipDir(dirpath,outFullName):
# """
# 压缩指定文件夹
# :param dirpath: 目标文件夹路径
# :param outFullName: 压缩文件保存路径+xxxx.zip
# :return: 无
# """
# import zipfile
# zip = zipfile.ZipFile(outFullName,"w",zipfile.ZIP_DEFLATED)
# for path,dirnames,filenames in os.walk(dirpath):
# # 去掉目标跟路径,只对目标文件夹下边的文件及文件夹进行压缩
# fpath = path.replace(dirpath,'')
#
# for filename in filenames:
# zip.write(os.path.join(path,filename),os.path.join(fpath,filename))
# zip.close()
def send_email_tome(): def send_email_tome():
try: try:
...@@ -28,7 +44,7 @@ def send_email_tome(): ...@@ -28,7 +44,7 @@ def send_email_tome():
# toaddrs = "lixiaofang@igengmei.com" # toaddrs = "lixiaofang@igengmei.com"
# toaddrs1 = "duanyingrong@igengmei.com" # toaddrs1 = "duanyingrong@igengmei.com"
# toaddrs2 = "dengguangyu@igengmei.com" # toaddrs2 = "dengguangyu@igengmei.com"
# toaddrs3 = "wangxin@igengmei.com" # toaddrs3 = "wangxin@igengmei.com"`
# toaddrs4 ="hezijun@igengmei.com" # toaddrs4 ="hezijun@igengmei.com"
# toaddrs5 = "malinxi@igengmei.com" # toaddrs5 = "malinxi@igengmei.com"
toaddrs6 = "litao@igengmei.com" toaddrs6 = "litao@igengmei.com"
...@@ -36,8 +52,12 @@ def send_email_tome(): ...@@ -36,8 +52,12 @@ def send_email_tome():
content = 'hi all:附件为' + str(date) + '的搜索词数据统计结果以及近一周的数据统计结果,请查收!' content = 'hi all:附件为' + str(date) + '的搜索词数据统计结果以及近一周的数据统计结果,请查收!'
zipFile = str(date)+".xls" zipFile = str(date)+".xls"
f = zipfile.ZipFile(zipFile, 'w', zipfile.ZIP_DEFLATED)
f.write(date,zipFile)
f.close()
#zipFile = '昨日数据统计结果.xls' #zipFile = '昨日数据统计结果.xls'
send_file_email(zipFile,email_group=["litao@igengmei.com"],title_str=content send_file_email(date+".zip",email_group=["litao@igengmei.com"],title_str=content
,data_str=content) ,data_str=content)
except Exception as e: except Exception as e:
print(e) print(e)
......
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