Mini Shell

Direktori : /proc/self/root/opt/imh-python/lib/python3.9/site-packages/rads/
Upload File :
Current File : //proc/self/root/opt/imh-python/lib/python3.9/site-packages/rads/common.py

"""Backwards compat for rads.common"""
from collections import defaultdict
import sys
import logging
import rads
from .compat import deprecated


@deprecated('rads.is_cpuser')
def is_cpanel_user(name):
    """deprecated"""
    return rads.is_cpuser(name)


@deprecated()
def errprint(*errmsgs, **kwargs):
    """deprecated"""
    errmsgs = [strcolor('red', x) for x in errmsgs]
    try:
        fatal = kwargs.pop('fatal')
    except KeyError:
        fatal = False
    print(*errmsgs, file=sys.stderr, **kwargs)
    if fatal is True:
        sys.exit(1)
    elif fatal is False:
        return
    else:
        sys.exit(fatal)


@deprecated('rads.get_login')
def getlogin(*_, **__):
    """deprecated"""
    return rads.get_login()


@deprecated('rads.send_email')
def send_email(*args, **kwargs):
    """deprecated"""
    return rads.send_email(*args, **kwargs)


@deprecated('rads.color')
def colors(style=None):
    """deprecated"""
    if style == 'html':
        return {
            'red': '<span style="font-weight: bold; color: red">',
            'green': '<span style="font-weight: bold; color: green">',
            # yellow is illegible in pdesk. Use orange
            'yellow': '<span style="font-weight: bold; color: orange">',
            'blue': '<span style="font-weight: bold; color: blue">',
            'bold': '<span style="font-weight: bold">',
            'purple': '<span style="font-weight: bold; color: #880088">',
            'none': '</span>',
        }
    if style == 'bleach':
        return defaultdict(str)
    return {
        'red': '\33[91;1m',
        'green': '\033[92;1m',
        'yellow': '\033[93;1m',
        'blue': '\033[94;1m',
        'bold': '\033[1m',
        'purple': '\033[95m',
        'invert': '\033[7m',
        'none': '\033[0m',
    }


@deprecated('rads.color')
def strcolor(color, string):
    """deprecated"""
    col = colors()
    return '%s%s%s' % (col[color], string, col['none'])


@deprecated('rads.get_keypress')
def get_key(*_, **__):
    """deprecated"""
    return rads.get_keypress()


@deprecated('rads.prompt_y_n')
def yes_or_no(question):
    """deprecated"""
    return rads.prompt_y_n(question)


@deprecated('rads.setup_logging')
def setup_logging(
    logfile='/var/log/messages',
    fmt='%(asctime)s %(name)s %(levelname)s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
    loglevel=logging.DEBUG,
    print_out=False,
    **__,
):
    """deprecated"""
    return rads.setup_logging(
        path=logfile,
        fmt=fmt,
        datefmt=datefmt,
        multiline=False,
        loglevel=loglevel,
        print_out=print_out,
    )

Zerion Mini Shell 1.0