j~zddlmZddlmZddlmZddlZddlmZddlmZm Z m Z m Z m Z m Z Gdd eZdS) )print_function)division)absolute_importN)BasePkgManager) CONFIG_DIRis_major_versioncreate_config_dirs ALT_NAMESscan_node_versionsALT_NODE_PREFIXcneZdZdZfdZeZeZdZ dZ dZ dZ dZ dZd Zd Zed ZxZS) PkgManagerz Class responsible for all interactions with Yum, NodeJS version installation/removal and gathering info about already installed versions cVtt|dSN)superr__init__)self __class__s Y/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/clselectnodejs/pkgmanager.pyrzPkgManager.__init__s% j$((*****z/var/log/cl-nodejs-last-yum.logc0|j|z}|jdd|gzS)z Build the yum groupinstall argv for an alt-nodejs version. :param version: major NodeJS version, e.g. "18" :rtype: list[str] -y groupinstall _alt_names _yum_argvrversiongroups r format_cmd_string_for_installingz+PkgManager.format_cmd_string_for_installing-s$')~~u ===rc2|j|z}|jddd|gzS)u0 Build the yum groupremove argv for an alt-nodejs version. Testing repo must be enabled — otherwise yum cannot see groups that were originally installed from cloudlinux-updates-testing. :param version: major NodeJS version, e.g. "18" :rtype: list[str] z'--enablerepo=cloudlinux-updates-testingr groupremoverrs rformat_cmd_string_for_removingz)PkgManager.format_cmd_string_for_removing7s.')~ 5 -!   rc<td|zS)Nz{}/.lock)r format)rrs r_get_lock_file_pathzPkgManager._get_lock_file_pathGs!2!27!;!;;;rc~t|sd|S|}|r|SdS)z5Do some common pre-installation/uninstallation checksz3Invalid version "{}". It should be positive integerN)r r&_check_yum_in_progress)rr working_errors r_verify_actionzPkgManager._verify_actionJsR(( C3396'?? C3355  !  ! !rc|}|s,||}|sdStjd|}|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-nodejs(\d+)\n)_read_yum_cacheupdate_yum_cacherefindall)rdata availables rcheckout_availablezPkgManager.checkout_availableSse##%%   ! ! # # #''))D tJ3T:: rctSr)r rs r_scan_interpreter_versionsz%PkgManager._scan_interpreter_versionsls!###rc"tdSr)r r5s r_create_config_dirszPkgManager._create_config_dirsosrcLddlm}|}||S)zJ Check what passed version isn't used any web-application r)ApplicationsManager)$clselect.clselectnodejs.apps_managerr:is_version_in_use)rr: apps_managers r_is_version_in_usezPkgManager._is_version_in_users9 MLLLLL**,, --g666r)__name__ __module__ __qualname____doc__rr _config_dirr r _log_filer!r$r'r+r3r6r8 staticmethodr> __classcell__)rs@rrrs +++++KJ1I>>>   <<<!!!2$$$77\77777rr) __future__rrrr/ clselect.baseclselect.pkgmanagerrrr r r r r rrrrKs&%%%%%&&&&&& ;;;;;;c7c7c7c7c7c7c7c7c7c7r