ok
Direktori : /proc/self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/php/ |
Current File : //proc/self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/php/alt_php.py |
from __future__ import absolute_import import os import re from typing import List from clwpos.php.base import PHP def create_generic_php(alt_php_identifier: str, root_path=None): if root_path is None: # create alt versions by default php_root_dir = f'/opt/{alt_php_identifier.replace("-", "/")}/' else: php_root_dir = root_path return PHP( identifier=alt_php_identifier, version=f'{alt_php_identifier[-2]}.{alt_php_identifier[-1]}', modules_dir=os.path.join(php_root_dir, 'usr/lib64/php/modules/'), dir=php_root_dir, bin=os.path.join(php_root_dir, 'usr/bin/php'), ini=os.path.join(php_root_dir, 'link/conf/default.ini'), ) def get_alt_php_versions() -> List[PHP]: """ Get list of installed alt-php versions. """ alt_dir = '/opt/alt' pattern = re.compile(r'^php\d{2}$') alt_php_versions = [ create_generic_php(f'alt-{dirname}') for dirname in os.listdir(alt_dir) if pattern.match(dirname) ] return alt_php_versions