From 00e3521c7cb1844b693ecf68dc2b0a1a87932fcc Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Fri, 18 Feb 2022 19:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=89=93=E5=8C=85=E4=B8=BAtar.gz=E5=8E=8B=E7=BC=A9=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/utils/packlog.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bin/utils/packlog.py b/bin/utils/packlog.py index 7979712..b502c07 100644 --- a/bin/utils/packlog.py +++ b/bin/utils/packlog.py @@ -3,4 +3,27 @@ # @Author: markushammered@gmail.com # @Development Tool: PyCharm # @Create Time: 2022/2/18 -# @File Name: packlog.py \ No newline at end of file +# @File Name: packlog.py + + +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'] \ No newline at end of file