0
! ˆ
ƒmÃa–ß=¿JJj"Tâ‚À½p S�ÿÅ î
Index of /FSS-BCZ/root/sys/devices/system/cpu/cpu3/node0/memory16
Index of /FSS-BCZ/root/sys/devices/system/cpu/cpu3/node0/memory16
#
ˆl–Ãa¾”êj"Tâ€zàpM)‹FÿÉ
ƒi Â¿Æ 1
"""
This module gets and caches news from imunify blog
"""
import asyncio
import os
import socket
import time
import urllib.request
from urllib.error import HTTPError
from xml.etree import ElementTree
from contextlib import suppress
from logging import getLogger
from defence360agent.simple_rpc.hosting_panel import HostingPanel
from defence360agent.utils import retry_on
logger = getLogger(__file__)
RSS_FEED_REMOTE_URL = "https://blog.imunify360.com/feed/"
_TIMEOUT = 300 # default timeout for network operations here
TAGS_TO_READ = ["title", "pubDate", "guid", "link"]
__all__ = ["HTTPError", "NewsFeed"]
class NewsFeed:
cache_ttl = 60 # in minutes
cache_file_path = "/var/imunify360/tmp/feed_cache.rss"
@classmethod
@retry_on(
(ElementTree.ParseError, urllib.request.URLError),
max_tries=10,
on_error=lambda *args: NewsFeed.clear_cache(*args),
)
async def get(cls):
if cls._expired():
await cls._refresh()
category_info = PanelCategory(HostingPanel().NAME)
with open(cls.cache_file_path) as cache_file:
root = ElementTree.fromstring(cache_file.read())
imunify_news = root.iter("item")
return [
{
child.tag: child.text
for child in item
if child.tag in TAGS_TO_READ
}
for item in imunify_news