@S09FddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZmZddlZddlZddlmZddlmZdd lmZdd lmZmZmZmZd Zd ZddZ ddee ddffdZ!dde ee fdZ"eddZ#dZ$ ddZ%dS)N)suppress) lru_cachewraps)chain)Path)OptionalTuple Generator) SimpleRpc)run_in_executor)ValidationError) AV_PID_PATHIM360_NON_RESIDENT_PID_PATHIM360_RESIDENT_PID_PATHantivirus_modecVtjrtnt}|rzt j}tt5t| }||kotj |cdddS#1swxYwYdS)z/Check if non-resident agent instance is runningNF) renabledrrexistsosgetpidr Exceptionint read_textpsutil pid_exists)rpc_process_pid_path current_pidpids T/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/rpc_tools/utils.pyrpc_is_runningr s &-N 3N""$$Aikk i  A A*446677C+%@&*;C*@*@ A A A A A A A A A A A A A A A A 5s;BB"%B"ctjrtStjrMt j}ttj}||kotj |SdS)z&Check if the agent instance is runningF) ConfigSOCKET_ACTIVATIONr rrrrrrrr)rrs r is_runningr$'sl  %''=ikk )35566k!resultr5s rget_schema_pathsrHGsi$ ,T%[[^^"F >> ', 6D MM  K. . 6  Mr%cg}t|D]$}|t|%tt |SN)rHappendr:dictr)r>r& base_paths rprepare_schemarOSsM F%e,,//  l9--.... v  r%c<tfd}|S)NcdKttjfdd{VS)NciSrK)argsfkwargssrz.wrapper.._saa.@.@.@r%)r asyncioget_event_loop)rTrVrUs``rwrapperz*run_in_executor_decorator..wrapper\sW$  " $ $&@&@&@&@&@&@         r%)r)rUrZs` rrun_in_executor_decoratorr[[s3 1XX    X Nr%cg}|D]w}|d|d|} } | r,|r*||| | N||| |xt|} t|} | dkr/| | kr)||| | |rt |iS)aP :param list affected: IPs that were changed during operation :param list of tuples || list of str not_affected: IPs & it's listnames that weren't changed during operation :param list all_list: list of all IPs that take place in operation :param str success_warning: msg if IP was changed :param str failure_warning: msg if IPs wasn't changed and it's absent in any other lists :param str in_another_list_warning: msg if IPs wasn't changed , however it present in another list :return list of st warnings: msg to be printed reclistnamerI)getrLformatlenr ) affected not_affected dest_listnameall_listsuccess_warningfailure_warningin_another_list_warningwarningsitemrecordr^ num_deleted total_nums rgenerate_warningsrnes*HKK;](K(K  K/ K OO3::68LL M M M M OOO226=II J J J Jh--KH I1}}k11..{IFFGGG(h''' Ir%)Nr&rK)&r+rXr contextlibr functoolsrr itertoolsrpathlibrtypingrr r r.r defence360agent.contracts.configr r"$defence360agent.model.simplificationr "defence360agent.rpc_tools.validater defence360agent.utilsrrrrr r$r:r)rHrOr[rnrSr%rrxs  &&&&&&&&---------- @@@@@@@@@@@@>>>>>>       ) ) ) )#tT4   HU4[1     1   "!&&&&&&r%