[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: parser.py
File is not writable. Editing disabled.
# 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 # import argparse import json import re from clwizard.modules import get_supported_modules _VERSION_RE = re.compile(r'\A\d+(\.\d+){0,2}\Z') _VERSION_LIST_OPTIONS = {'versions'} _VERSION_STRING_OPTIONS = {'default_version'} _BOOL_OPTIONS = {'enable_selector', 'enable_for_existing_users', 'enable_for_new_users', 'use_beta_for_da'} def _validate_option_value(module_name, key, value): if key in _BOOL_OPTIONS: if not isinstance(value, bool): raise argparse.ArgumentTypeError( f"'{module_name}' module option '{key}' must be a boolean" ) elif key in _VERSION_LIST_OPTIONS: if not isinstance(value, list): raise argparse.ArgumentTypeError( f"'{module_name}' module option '{key}' must be a list" ) for ver in value: if not isinstance(ver, str) or not _VERSION_RE.match(ver): raise argparse.ArgumentTypeError( f"'{module_name}' module option '{key}' " f"contains invalid version: {ver!r}" ) elif key in _VERSION_STRING_OPTIONS: if not isinstance(value, str) or not _VERSION_RE.match(value): raise argparse.ArgumentTypeError( f"'{module_name}' module option '{key}' " f"has invalid version: {value!r}" ) def validate_json_modules(json_string): try: data = json.loads(json_string) except (TypeError, ValueError) as json_error: raise argparse.ArgumentTypeError("Invalid JSON data passed") from json_error supported_modules = get_supported_modules() for name, instructions in data.items(): if name not in supported_modules: raise argparse.ArgumentTypeError( f"'{name}' module is not supported at the moment, " f"available keys: {list(supported_modules.keys())}" ) if "options" in list(instructions.keys()): if not set(instructions["options"].keys()).issubset( supported_modules[name].supported_options() ): raise argparse.ArgumentTypeError( f"'{name}' module has incorrect options: {list(instructions['options'].keys())}" ) for key, value in instructions["options"].items(): _validate_option_value(name, key, value) elif instructions: raise argparse.ArgumentTypeError( f"'{name}' module has incorrect instructions: {list(instructions.keys())}" ) return data def parse_cloudlinux_wizard_opts(argv): """ Arg parser for cloudlinux-wizard utility """ parser = argparse.ArgumentParser( prog="cloudlinux-wizard", description="Utility for installing cloudlinux modules", ) # --json parameter is a convenience for UI calls, we do not process it parser.add_argument("--json", action="store_true", help=argparse.SUPPRESS) subparser = parser.add_subparsers(dest="subparser") install_parser = subparser.add_parser( "install", help="Install a module. The installation is performed in the background by default", ) install_parser.add_argument( "--no-async", help="Install in the foreground", action="store_true" ) install_parser.add_argument( "--force", help="Force the installer to ignore existing installations", action="store_true", ) installer_group = install_parser.add_mutually_exclusive_group(required=True) installer_group.add_argument( "--json-data", help="JSON with modules to be installed", type=validate_json_modules, ) installer_group.add_argument( "--resume", help="Restart the installation process with previously given arguments", action="store_true", ) status_parser = subparser.add_parser( "status", help="Return JSON with statuses of all modules" ) status_parser.add_argument( "--initial", "-i", action="store_true", help="Get the current modules' status" ) finish_parser = subparser.add_parser( "finish", help="Finalize the installation from UI and close the wizard" ) cancel_parser = subparser.add_parser( "cancel", help="Remove a module from the installation queue" ) cancel_parser.add_argument("module", choices=list(get_supported_modules())) opts = parser.parse_args(argv) return opts
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium264.web-hosting.com
Server IP: 69.57.162.13
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium264.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 73.58 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kidscntx
User ID (UID): 1154
Group ID (GID): 1112
Script Owner UID: 1154
Current Dir Owner: N/A