wo4hddlZddlZddlZddlmZmZddlmZddlZej e Z GddZ dZ GddeZGd d eZGd d e ZdS)N)ABCMetaabstractmethod)isclosec*eZdZdZdZdZdZdZdZdZ dS) FeatureStatuserror installed installingremoving not_installedmanaged_by_lveznot-supported-by-cl-soloN) __name__ __module__ __qualname__ERROR INSTALLED INSTALLINGREMOVING NOT_INSTALLEDMANAGED_BY_LVENOT_SUPPORTED_BY_CL_SOLOe/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/subsys/features/abstract_feature.pyrr s4 EIJH#M%N9rrcfd}|S)z If Easy Apache 4 not installed, then raising an error :raises FeatureError :param func: install or remove func :return func: cKtjdstd|i|d{VS)Nz/etc/cpanel/ea4/is_ea4z3Hardened PHP is compatible only with Easy Apache 4!)ospathisfile FeatureError)argskwargsfuncs rwrapperzea4_only..wrappers\w~~677 E T4*6*********rrr#r$s` rea4_onlyr&s#+++++ NrceZdZdZdS)r z*Feature operation can't be performed errorNrrr__doc__rrrr r (s44Drr ceZdZdZdS) FeatureNoticez+Feature operation can't be performed noticeNr(rrrr+r+.s55Drr+c,eZdZdZdZdZgZddZdZe dZ e dZ e dZ edZe dZd efd Zed efd Zed efd Zed efd ZedZedZdZdS)AbstractFeatureNcX|js Jd|js Jd||_dS)Nzvariable isn't set!)INSTALL_LOG_FILE_MASKREMOVE_LOG_FILE_MASK_sink)selfsinks r__init__zAbstractFeature.__init__:s=)@@+@@@)(??*???( rcHK|d{V|_|SN)check_installed is_installedr2s rinitzAbstractFeature.init@s1"&"6"6"8"8888888 rc6||jSr6) _get_live_logr/r9s rinstallation_live_logz%AbstractFeature.installation_live_logDs!!$"<===rc6||jSr6)r<r0r9s rremoval_live_logz AbstractFeature.removal_live_logHs!!$";<<%>"]N3s88,,88::MM-00!                  V%9:   55 s5CBB7* C7B;;C>B;?CC$#C$c*tj|S)zo :param str log_mask: regexp of log file path :return: list of files found by log_mask )glob)log_masks r_ls_logszAbstractFeature._ls_logsZs y"""rcntt|j||dS)a Returns path of log file, which used by some process. If log file used by process, assuming that installation/removal is in the progress :param str file_mask: regexp of log file path :return: str path of log, used by some process N)nextfilterrTrX)rO file_masks rr<zAbstractFeature._get_live_logbs-F3. Y0G0GHH$OOOrreturnc^K|jrdS|jrdS|d{VS)NFT)r=r?_check_installed_implr9s rr7zAbstractFeature.check_installednsJ  % 5   4//111111111rc KdS)NFrr9s rr_z%AbstractFeature._check_installed_implus urc"Kt)z :return str: path to log file with installation process :raise FeatureError: when feature is already installed, concurrent operation is in progress, feature is not applicable for given setup, etc. NotImplementedErrorr9s rinstallzAbstractFeature.installys"###rc"Ktr6rbr9s rremovezAbstractFeature.removes!###rcfd}|S)a Checks before operation if similar or mutually exclusive operation is in the progress. Checks if there are condition why operation can't be performed. :raises FeatureError: if operation couldn't be performed :returns str msg: log path if already ongoing operation :returns continue function isntall/remove: if operation is permitted cK|jrtd|jr'td|j|jp|d{VS)Nz$Wait until uninstalling is finished!z{} is already installed)r?r r8r+formatNAMEr=r2r#s rr$z>AbstractFeature.raise_if_shouldnt_install_now..wrappers{$ "#IJJJ" #-44TY??-AttDzz1A1A1A1A1A1A Arrr%s` rraise_if_shouldnt_install_nowz-AbstractFeature.raise_if_shouldnt_install_nows( B B B B Brcfd}|S)z :raises FeatureError: if operation couldn't be performed :returns str msg: log path if already ongoing operation :returns continue function isntall/remove: if operation is permitted cK|jrtd|js'td|j|jp|d{VS)Nz$Wait until installation is finished!z+Can't delete {}, because it's not installed)r=r r8r+rirjr?rks rr$z=AbstractFeature.raise_if_shouldnt_remove_now..wrappers) "#IJJJ& #AHH  (<$$t**,<,<,<,<,<,< >X>==X=  [ ##\# P P[ P2t2222T^$s$$$^$$c$$$^$\0\,     rr-) metaclass)rVloggingrabcrrmathrrF getLoggerrloggerrr& Exceptionr r+r-rrrrs4  ''''''''  8 $ $::::::::$     9        L   U U U U U U U U U U U r