[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.222.91.173: ~ $
# Copyright (c) Cloud Linux Software, Inc
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENCE.TXT

from __future__ import print_function


import logging
import logging.handlers
import os
import sys
import traceback

from . import config
from . import constants


kcarelog = logging.getLogger('kcare')  # mocked: tests/unit


def logdebug(message):
    _printlvl(message, constants.PRINT_DEBUG)
    kcarelog.debug(message)


def loginfo(message, print_msg=True):
    # type: (str, bool) -> None
    if print_msg:
        _printlvl(message, constants.PRINT_INFO)
    kcarelog.info(message)


def logwarn(message, print_msg=True):
    if print_msg:
        _printlvl(message, constants.PRINT_WARN, file=sys.stderr)  # pragma: no cover
    kcarelog.warning(message)


def logerror(message, print_msg=True):
    if print_msg:
        _printlvl(message, constants.PRINT_ERROR, file=sys.stderr)
    kcarelog.error(message)


def logexc(message, print_msg=True):
    if print_msg and constants.PRINT_ERROR >= config.PRINT_LEVEL:
        traceback.print_exc()
    kcarelog.exception(message)


def _printlvl(message, level, file=None):
    if level >= config.PRINT_LEVEL:
        print(message, file=file)


def get_syslog_handler():
    syslog_formatter = logging.Formatter('kcare %(levelname)s: %(message)s')
    syslog_handler = logging.handlers.SysLogHandler(address='/dev/log', facility=logging.handlers.SysLogHandler.LOG_USER)
    syslog_handler.setLevel(logging.INFO)
    syslog_handler.setFormatter(syslog_formatter)
    return syslog_handler


def get_kcare_handler(level):
    kcare_formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
    if os.getuid() == 0:
        kcare_handler = logging.handlers.RotatingFileHandler(
            constants.LOG_FILE, maxBytes=1024**2, backupCount=2
        )  # type: logging.Handler
        # We need at least INFO level logs at all times
        kcare_handler.setLevel(min(level, logging.INFO))
        kcare_handler.setFormatter(kcare_formatter)
        return kcare_handler
    else:
        kcare_handler = logging.StreamHandler()
        kcare_handler.setLevel(level)
        kcare_handler.setFormatter(kcare_formatter)
        return kcare_handler


def initialize_logging(level):
    kcarelog.handlers[:] = []

    try:
        kcare_handler = get_kcare_handler(level)
        kcarelog.addHandler(kcare_handler)
    except Exception as ex:
        kcarelog.exception(ex)

    if os.path.exists('/dev/log'):
        try:
            syslog_handler = get_syslog_handler()
            kcarelog.addHandler(syslog_handler)
        except Exception as ex:
            kcarelog.exception(ex)


def print_cln_http_error(ex, url=None, stdout=True):
    url = url or '<route cannot be logged>'
    logerror('Unable to fetch {0}. Please try again later (error: {1})'.format(url, str(ex)), stdout)

Filemanager

Name Type Size Permission Actions
__init__.py File 69.58 KB 0644
__init__.pyc File 64.25 KB 0644
__init__.pyo File 64.25 KB 0644
__main__.py File 829 B 0644
__main__.pyc File 926 B 0644
__main__.pyo File 926 B 0644
auth.py File 11.87 KB 0644
auth.pyc File 11.82 KB 0644
auth.pyo File 11.82 KB 0644
config.py File 1.71 KB 0644
config.pyc File 2.01 KB 0644
config.pyo File 2.01 KB 0644
config_handlers.py File 7.26 KB 0644
config_handlers.pyc File 8.47 KB 0644
config_handlers.pyo File 8.47 KB 0644
constants.py File 1.27 KB 0644
constants.pyc File 1.34 KB 0644
constants.pyo File 1.34 KB 0644
errors.py File 1.29 KB 0644
errors.pyc File 2.94 KB 0644
errors.pyo File 2.94 KB 0644
fetch.py File 4.88 KB 0644
fetch.pyc File 5.47 KB 0644
fetch.pyo File 5.47 KB 0644
http_utils.py File 4.06 KB 0644
http_utils.pyc File 4.16 KB 0644
http_utils.pyo File 4.16 KB 0644
kcare.py File 8.56 KB 0644
kcare.pyc File 11.09 KB 0644
kcare.pyo File 11.09 KB 0644
libcare.py File 17.24 KB 0644
libcare.pyc File 19.16 KB 0644
libcare.pyo File 19.16 KB 0644
log_utils.py File 2.82 KB 0644
log_utils.pyc File 3.75 KB 0644
log_utils.pyo File 3.75 KB 0644
platform_utils.py File 3.4 KB 0644
platform_utils.pyc File 4.56 KB 0644
platform_utils.pyo File 4.56 KB 0644
process_utils.py File 3.81 KB 0644
process_utils.pyc File 3.67 KB 0644
process_utils.pyo File 3.67 KB 0644
py23.py File 1.74 KB 0644
py23.pyc File 2.15 KB 0644
py23.pyo File 2.15 KB 0644
selinux.py File 1.68 KB 0644
selinux.pyc File 2.43 KB 0644
selinux.pyo File 2.43 KB 0644
server_info.py File 2.99 KB 0644
server_info.pyc File 3.48 KB 0644
server_info.pyo File 3.48 KB 0644
update_utils.py File 923 B 0644
update_utils.pyc File 1.18 KB 0644
update_utils.pyo File 1.18 KB 0644
utils.py File 7.07 KB 0644
utils.pyc File 7.8 KB 0644
utils.pyo File 7.8 KB 0644