l#g3dZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZeeZd Zd Zgd Zd d gZGdd ZdZGddZdS)z4 This module gets and caches news from imunify blog N) HTTPError) ElementTree)suppress) getLogger) HostingPanel)retry_onz#https://blog.imunify360.com/rss.xmli,)titlepubDateguidlinkrNewsFeedceZdZdZdZeeeje j j fdddZ edZ edZeefd Zed Zd S) r <z"/var/imunify360/tmp/feed_cache.rss ctj|SN)r clear_cache)argss Q/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/api/newsfeed.pyzNewsFeed."sx3T:) max_trieson_errorcK|r|d{Vttjt |j5}tj| }| d}fd|DcdddS#1swxYwYdS)NitemcRg|]#}|d|D$S)cDi|]}|jtv|j|jS)tag TAGS_TO_READtext.0childs r z+NewsFeed.get...-s5yL00Iuz000r) is_allowed)r#r category_infos r z NewsFeed.get..,sX  ++D11!%r) _expired_refresh PanelCategoryrNAMEopencache_file_pathr fromstringreaditer)cls cache_fileroot imunify_newsr's @rgetz NewsFeed.gets <<>> !,,.. %lnn&9:: #% & & *)*//*;*;<>#- . . #!#!1!1#2E!F!F  !" Y[[#55; 3=((rcxKtjdtt|d{VSr)asyncioget_event_looprun_in_executor _fetch_urlRSS_FEED_REMOTE_URL)r2timeouts rrAzNewsFeed._fetchIsO+--== *17         rcKtd|tt5t j|jddddS#1swxYwYdS)NzClearing cache due to error: %s)r>warningrFileNotFoundErrorr9unlinkr.)r2rs rrzNewsFeed.clear_cacheOs8$??? ' ( ( + + Ic) * * * + + + + + + + + + + + + + + + + + +sAA AN)__name__ __module__ __qualname__rFr. classmethodrr ParseErrorurllibrequestURLErrorr6r*r)_TIMEOUTrArrrrr r sI:O X  !89::  [ $11[1))[)"*   [ ++[+++rc  ddi}tj||}tj||5}|cdddS#1swxYwYdS#t j$rtwxYw)Nz User-Agentzimunify360-urllib/0.1)headers)rO)rYrZRequesturlopenr0socketrO TimeoutError)urlrOr^reqresponses rrMrMVs  !89n$$S'$:: ^ # #C # 9 9 #X==?? # # # # # # # # # # # # # # # # # # >s0AA6A) A6)A--A60A-1A66B c&eZdZhdZdZdZdZdS)r+>pleskcpanel directadminzstandalone-imunifyc|}|tjvr|n tj|_tjtjh|jhz z|_dSr)lowerr+panel_categoriesno_panel_categorycurrent competitors)selfp_names r__init__zPanelCategory.__init__isb777 F0 )9  += \N=rcd|D}d||jv}tfd|jD}| p|S)Nc2h|]}|jdk |jS)category)rr!r"s r z+PanelCategory.is_allowed..us-    EI,C,CEJ,C,C,Crz|||c3 K|]}|vV dSrr)r#comjoined_categorys r z+PanelCategory.is_allowed..}s9& & '*C? "& & & & & & r)joinrkrnanyro)rpritem_categoriescurrent_in_categorycompetitors_in_categoryrys @rr&zPanelCategory.is_allowedts  $(     **_55;;=="lo="%& & & & .2.>& & & # #  +*A.AArN)rTrUrVrlrmrrr&rrrr+r+csK:99,   BBBBBrr+)__doc__rJr9rarEurllib.requestrY urllib.errorr xml.etreer contextlibrloggingr(defence360agent.simple_rpc.hosting_panelrdefence360agent.utilsr__file__r>rNr\r __all__r rMr+rrrrsP """"""!!!!!!AAAAAA****** 8  ; 333  #9+9+9+9+9+9+9+9+x   BBBBBBBBBBr