D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
im360
/
subsys
/
panels
/
directadmin
/
Filename :
custombuild.py
back
Copy
import logging import functools import os from defence360agent.subsys.panels.base import PanelException from defence360agent.subsys.panels.directadmin.config import ConfigOptions from defence360agent.utils import check_run, CheckRunError logger = logging.getLogger(__name__) BASEDIR = "/usr/local/directadmin/custombuild" BUILD = os.path.join(BASEDIR, "build") class CustomBuildOptions(ConfigOptions): DEFAULT_FILENAME = os.path.join(BASEDIR, "options.conf") async def build(option): return await check_run([BUILD, option], cwd=BASEDIR) def custombuild2_only(fun): @functools.wraps(fun) async def wrapper(*args, **kwargs): try: out = await build("version") except (CheckRunError, FileNotFoundError, PermissionError): pass else: if out.startswith(b"2."): return await fun(*args, **kwargs) raise PanelException( "{} is only supported on installations " "with Custombuild 2.0".format(fun.__name__) ) return wrapper