This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
RequestCounter/bin/utils/packing_logs.py
T

29 lines
603 B
Python
Raw Normal View History

2022-02-18 19:30:54 +08:00
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/18
2022-02-23 22:03:39 +08:00
# @File Name: packing_logs.py
2022-02-18 19:35:28 +08:00
import os
import time
import tarfile
def make_targz():
"""
打包为tar.gz
压缩文件
:return:
"""
output_dir = f'./static/cache/{time.strftime("%Y-%m-%d %H")}.tar.gz'
tar = tarfile.open(output_dir, 'w:gz')
for root, dir, files in os.walk('./bin/log'):
for file in files:
pathfile = os.path.join(root, file)
tar.add(pathfile)
tar.close()
__all__ = ['make_targz']