jzddlmZddlmZddlmZddlZddlmZddlmZm Z m Z m Z m Z m Z Gdd eZdS) )print_function)division)absolute_importN)BasePkgManager)scan_python_versionsis_major_version CONFIG_DIRcreate_config_dirs ALT_NAMESALT_PYTHON_PREFIXc^eZdZdZdZeZeZdZ dZ dZ dZ dZ dZd Zed Zd S) PkgManagerz Class responsible for all interactions with Yum, python version installation/removal and gathering info about already installed versions c"tdSN)r selfs Y/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/clselectpython/pkgmanager.py_create_config_dirszPkgManager._create_config_dirssz/var/log/cl-python-last-yum.logctSr)rrs r_scan_interpreter_versionsz%PkgManager._scan_interpreter_versions-s#%%%rcdtd|ddzS)Nz{}/.lock.)r formatreplace)rversions r_get_lock_file_pathzPkgManager._get_lock_file_path0s2 :#4#4 OOC $ $$&$&& &rc|}|s,||}|sdStjd|}d|D}|S)a Should return list of major versions available to install from currently enabled repos. Note, this can be an empty list if no NodeJS version has been released to repos yet or in case of network/repos/yum problem. OR None if our cache is updating right now because it was absent/outdated/corrupted/etc. :rtype: list | None Nzalt-python(\d+)cXg|]'}d|d|ddg(S)rrrN)join).0rs r z1PkgManager.checkout_available..Js5RRRWSXXwqz7122;788RRRr)_read_yum_cacheupdate_yum_cacherefindall)rdata availables rcheckout_availablezPkgManager.checkout_available4sx##%%   ! ! # # #''))D tJ0$77 RR RRR rc~t|sd|S|}|r|SdS)z5Do some common pre-installation/uninstallation checksz>Invalid version "{}". It should be two digits separeted by dotN)r r_check_yum_in_progress)rr working_errors r_verify_actionzPkgManager._verify_actionMsR(( N>>DfWoo N3355  !  ! !rcX|j|ddz}|jdd|gzS)ax Build the yum install argv for an alt-python version. Defense-in-depth: `version` is already validated by `_verify_action()` (`is_major_version()` enforces \d+\.\d+), but with shell=False this is no longer load-bearing for command-injection safety. :param version: major python version, e.g. "3.11" :rtype: list[str] rr-yinstall _alt_namesr _yum_argvrrpkgs r format_cmd_string_for_installingz+PkgManager.format_cmd_string_for_installingVs2oR 8 88~y# 666rcX|j|ddz}|jdd|gzS)z Build the yum remove argv for an alt-python version. :param version: major python version, e.g. "3.11" :rtype: list[str] rrr1remover3r6s rformat_cmd_string_for_removingz)PkgManager.format_cmd_string_for_removingds2oR 8 88~x 555rcLddlm}|}||S)zJ Check what passed version isn't used any web-application r)ApplicationsManager)$clselect.clselectpython.apps_managerr=is_version_in_use)rr= apps_managers r_is_version_in_usezPkgManager._is_version_in_usens9 MLLLLL**,, --g666rN)__name__ __module__ __qualname____doc__rr _config_dirr r4 _log_filerrr+r/r8r; staticmethodrArrrrs KJ1I&&&&&&2!!! 7 7 766677\777rr) __future__rrrr' clselect.baseclselect.pkgmanagerrrrr r r r r rrIrrrLs&%%%%%&&&&&& ;;;;;;_7_7_7_7_7_7_7_7_7_7r