2023-11-22 12:47:34 +01:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
FIXME
|
|
|
|
|
|
|
|
|
|
1) Function check_readiness or event "changed_status" is causing for
|
|
|
|
|
triple status messages and also false ones that indicate of lack
|
|
|
|
|
of feeds.
|
|
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
|
|
|
|
|
1) Deprecate "add" (see above) and make it interactive.
|
|
|
|
|
Slixfeed: Do you still want to add this URL to subscription list?
|
|
|
|
|
See: case _ if message_lowercase.startswith("add"):
|
|
|
|
|
|
|
|
|
|
2) Use loop (with gather) instead of TaskGroup.
|
|
|
|
|
|
|
|
|
|
3) Assure message delivery before calling a new task.
|
|
|
|
|
See https://slixmpp.readthedocs.io/en/latest/event_index.html#term-marker_acknowledged
|
|
|
|
|
|
|
|
|
|
4) Do not send updates when busy or away.
|
|
|
|
|
See https://slixmpp.readthedocs.io/en/latest/event_index.html#term-changed_status
|
|
|
|
|
|
2023-11-26 06:48:09 +01:00
|
|
|
|
5) Animate "You have X news items"
|
|
|
|
|
📬️ when sent
|
|
|
|
|
📫️ after sent
|
|
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
|
NOTE
|
|
|
|
|
|
|
|
|
|
1) Self presence
|
|
|
|
|
Apparently, it is possible to view self presence.
|
|
|
|
|
This means that there is no need to store presences in order to switch or restore presence.
|
|
|
|
|
check_readiness
|
|
|
|
|
<presence from="slixfeed@canchat.org/xAPgJLHtMMHF" xml:lang="en" id="ab35c07b63a444d0a7c0a9a0b272f301" to="slixfeed@canchat.org/xAPgJLHtMMHF"><status>📂 Send a URL from a blog or a news website.</status><x xmlns="vcard-temp:x:update"><photo /></x></presence>
|
|
|
|
|
JID: self.boundjid.bare
|
|
|
|
|
MUC: self.nick
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
import logging
|
|
|
|
|
import os
|
|
|
|
|
import slixmpp
|
|
|
|
|
|
2023-12-28 19:16:33 +01:00
|
|
|
|
from slixfeed.config import initdb, get_default_dbdir, get_value_default
|
2023-12-28 15:50:23 +01:00
|
|
|
|
from slixfeed.datetime import current_time
|
2023-12-28 19:16:33 +01:00
|
|
|
|
from slixfeed.fetch import download_updates
|
2023-12-28 15:50:23 +01:00
|
|
|
|
from slixfeed.sqlite import (
|
2023-12-05 09:18:29 +01:00
|
|
|
|
get_entry_unread,
|
|
|
|
|
get_settings_value,
|
|
|
|
|
get_number_of_items,
|
|
|
|
|
get_number_of_entries_unread
|
|
|
|
|
)
|
2023-12-28 15:50:23 +01:00
|
|
|
|
# from xmpp import Slixfeed
|
|
|
|
|
import slixfeed.xmpp.client as xmpp
|
2023-11-22 12:47:34 +01:00
|
|
|
|
|
|
|
|
|
main_task = []
|
|
|
|
|
jid_tasker = {}
|
|
|
|
|
task_manager = {}
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
FIXME
|
|
|
|
|
|
|
|
|
|
Tasks don't begin at the same time.
|
|
|
|
|
|
|
|
|
|
This is noticeable when calling "check" before "status".
|
|
|
|
|
|
|
|
|
|
await taskhandler.start_tasks(
|
|
|
|
|
self,
|
|
|
|
|
jid,
|
|
|
|
|
["check", "status"]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
"""
|
2023-11-23 17:55:36 +01:00
|
|
|
|
async def start_tasks_xmpp(self, jid, tasks):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("start_tasks_xmpp", jid, tasks)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
task_manager[jid] = {}
|
|
|
|
|
for task in tasks:
|
2023-11-26 06:48:09 +01:00
|
|
|
|
# print("task:", task)
|
|
|
|
|
# print("tasks:")
|
|
|
|
|
# print(tasks)
|
2023-11-23 17:55:36 +01:00
|
|
|
|
# breakpoint()
|
2023-11-22 12:47:34 +01:00
|
|
|
|
match task:
|
|
|
|
|
case "check":
|
|
|
|
|
task_manager[jid]["check"] = asyncio.create_task(
|
|
|
|
|
check_updates(jid)
|
|
|
|
|
)
|
|
|
|
|
case "status":
|
|
|
|
|
task_manager[jid]["status"] = asyncio.create_task(
|
|
|
|
|
send_status(self, jid)
|
|
|
|
|
)
|
|
|
|
|
case "interval":
|
|
|
|
|
task_manager[jid]["interval"] = asyncio.create_task(
|
|
|
|
|
send_update(self, jid)
|
|
|
|
|
)
|
2023-11-23 17:55:36 +01:00
|
|
|
|
# for task in task_manager[jid].values():
|
|
|
|
|
# print("task_manager[jid].values()")
|
|
|
|
|
# print(task_manager[jid].values())
|
|
|
|
|
# print("task")
|
|
|
|
|
# print(task)
|
|
|
|
|
# print("jid")
|
|
|
|
|
# print(jid)
|
|
|
|
|
# breakpoint()
|
|
|
|
|
# await task
|
|
|
|
|
|
|
|
|
|
async def clean_tasks_xmpp(jid, tasks):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("clean_tasks_xmpp", jid, tasks)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
for task in tasks:
|
|
|
|
|
# if task_manager[jid][task]:
|
|
|
|
|
try:
|
|
|
|
|
task_manager[jid][task].cancel()
|
|
|
|
|
except:
|
|
|
|
|
print("No task", task, "for JID", jid, "(clean_tasks)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
TODO
|
|
|
|
|
|
|
|
|
|
Rename to "start_tasks"
|
|
|
|
|
|
|
|
|
|
Pass a list (or dict) of tasks to start
|
|
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
|
|
2023-12-04 15:41:02 +01:00
|
|
|
|
Consider callback e.g. Slixfeed.send_status.
|
2023-11-22 12:47:34 +01:00
|
|
|
|
|
|
|
|
|
Or taskhandler for each protocol or specific taskhandler function.
|
|
|
|
|
"""
|
|
|
|
|
async def task_jid(self, jid):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("task_jid", jid)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
JID (Jabber ID) task manager.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
jid : str
|
|
|
|
|
Jabber ID.
|
|
|
|
|
"""
|
2023-12-04 15:41:02 +01:00
|
|
|
|
enabled = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
get_settings_value,
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"enabled"
|
|
|
|
|
)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), "enabled", enabled, jid)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
if enabled:
|
|
|
|
|
# NOTE Perhaps we want to utilize super with keyword
|
|
|
|
|
# arguments in order to know what tasks to initiate.
|
|
|
|
|
task_manager[jid] = {}
|
|
|
|
|
task_manager[jid]["check"] = asyncio.create_task(
|
|
|
|
|
check_updates(jid)
|
|
|
|
|
)
|
|
|
|
|
task_manager[jid]["status"] = asyncio.create_task(
|
|
|
|
|
send_status(self, jid)
|
|
|
|
|
)
|
|
|
|
|
task_manager[jid]["interval"] = asyncio.create_task(
|
|
|
|
|
send_update(self, jid)
|
|
|
|
|
)
|
|
|
|
|
await task_manager[jid]["check"]
|
|
|
|
|
await task_manager[jid]["status"]
|
|
|
|
|
await task_manager[jid]["interval"]
|
|
|
|
|
# tasks_dict = {
|
|
|
|
|
# "check": check_updates,
|
|
|
|
|
# "status": send_status,
|
|
|
|
|
# "interval": send_update
|
|
|
|
|
# }
|
|
|
|
|
# for task, function in tasks_dict.items():
|
|
|
|
|
# task_manager[jid][task] = asyncio.create_task(
|
|
|
|
|
# function(jid)
|
|
|
|
|
# )
|
|
|
|
|
# await function
|
|
|
|
|
else:
|
|
|
|
|
# FIXME
|
|
|
|
|
# The following error occurs only upon first attempt to stop.
|
|
|
|
|
# /usr/lib/python3.11/asyncio/events.py:73: RuntimeWarning: coroutine 'Slixfeed.send_update' was never awaited
|
|
|
|
|
# self._args = None
|
|
|
|
|
# RuntimeWarning: Enable tracemalloc to get the object allocation traceback
|
|
|
|
|
try:
|
|
|
|
|
task_manager[jid]["interval"].cancel()
|
|
|
|
|
except:
|
|
|
|
|
None
|
|
|
|
|
await send_status(self, jid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def send_update(self, jid, num=None):
|
2023-12-14 09:43:30 +01:00
|
|
|
|
print("send_update", jid)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), jid, "def send_update")
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
Send news items as messages.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
jid : str
|
|
|
|
|
Jabber ID.
|
|
|
|
|
num : str, optional
|
|
|
|
|
Number. The default is None.
|
|
|
|
|
"""
|
|
|
|
|
# print("Starting send_update()")
|
|
|
|
|
# print(jid)
|
2023-12-14 09:43:30 +01:00
|
|
|
|
enabled = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-14 09:43:30 +01:00
|
|
|
|
get_settings_value,
|
|
|
|
|
"enabled"
|
2023-11-22 12:47:34 +01:00
|
|
|
|
)
|
2023-12-14 09:43:30 +01:00
|
|
|
|
if enabled:
|
|
|
|
|
new = await initdb(
|
|
|
|
|
jid,
|
|
|
|
|
get_entry_unread,
|
|
|
|
|
num
|
2023-11-22 12:47:34 +01:00
|
|
|
|
)
|
2023-12-14 09:43:30 +01:00
|
|
|
|
if new:
|
|
|
|
|
# TODO Add while loop to assure delivery.
|
|
|
|
|
# print(await current_time(), ">>> ACT send_message",jid)
|
2023-12-28 15:50:23 +01:00
|
|
|
|
chat_type = await xmpp.Slixfeed.is_muc(self, jid)
|
2023-12-14 09:43:30 +01:00
|
|
|
|
# NOTE Do we need "if statement"? See NOTE at is_muc.
|
|
|
|
|
if chat_type in ("chat", "groupchat"):
|
2023-12-28 15:50:23 +01:00
|
|
|
|
xmpp.Slixfeed.send_message(
|
2023-12-14 09:43:30 +01:00
|
|
|
|
self,
|
|
|
|
|
mto=jid,
|
|
|
|
|
mbody=new,
|
|
|
|
|
mtype=chat_type
|
|
|
|
|
)
|
|
|
|
|
# TODO Do not refresh task before
|
|
|
|
|
# verifying that it was completed.
|
|
|
|
|
await refresh_task(
|
|
|
|
|
self,
|
|
|
|
|
jid,
|
|
|
|
|
send_update,
|
|
|
|
|
"interval"
|
|
|
|
|
)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# interval = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
# jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# get_settings_value,
|
2023-11-22 12:47:34 +01:00
|
|
|
|
# "interval"
|
|
|
|
|
# )
|
|
|
|
|
# task_manager[jid]["interval"] = loop.call_at(
|
|
|
|
|
# loop.time() + 60 * interval,
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# send_update(jid)
|
|
|
|
|
# )
|
|
|
|
|
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), "asyncio.get_event_loop().time()")
|
|
|
|
|
# print(await current_time(), asyncio.get_event_loop().time())
|
2023-11-22 12:47:34 +01:00
|
|
|
|
# await asyncio.sleep(60 * interval)
|
|
|
|
|
|
|
|
|
|
# loop.call_later(
|
|
|
|
|
# 60 * interval,
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# send_update(jid)
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
# print
|
|
|
|
|
# await handle_event()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def send_status(self, jid):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("send_status", jid)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), jid, "def send_status")
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
Send status message.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
jid : str
|
|
|
|
|
Jabber ID.
|
|
|
|
|
"""
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), "> SEND STATUS",jid)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
status_text="🤖️ Slixfeed RSS News Bot"
|
2023-12-04 15:41:02 +01:00
|
|
|
|
enabled = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
get_settings_value,
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"enabled"
|
|
|
|
|
)
|
|
|
|
|
if not enabled:
|
|
|
|
|
status_mode = "xa"
|
2023-11-26 06:48:09 +01:00
|
|
|
|
status_text = "📫️ Send \"Start\" to receive updates"
|
2023-11-22 12:47:34 +01:00
|
|
|
|
else:
|
2023-12-04 15:41:02 +01:00
|
|
|
|
feeds = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
get_number_of_items,
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"feeds"
|
|
|
|
|
)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), jid, "has", feeds, "feeds")
|
2023-11-22 12:47:34 +01:00
|
|
|
|
if not feeds:
|
|
|
|
|
print(">>> not feeds:", feeds, "jid:", jid)
|
|
|
|
|
status_mode = "available"
|
|
|
|
|
status_text = (
|
2023-12-01 14:22:03 +01:00
|
|
|
|
"📪️ Send a URL from a blog or a news website"
|
2023-11-22 12:47:34 +01:00
|
|
|
|
)
|
|
|
|
|
else:
|
2023-12-04 15:41:02 +01:00
|
|
|
|
unread = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
get_number_of_entries_unread
|
2023-11-22 12:47:34 +01:00
|
|
|
|
)
|
|
|
|
|
if unread:
|
|
|
|
|
status_mode = "chat"
|
|
|
|
|
status_text = (
|
2023-11-27 18:22:56 +01:00
|
|
|
|
"📬️ There are {} news items"
|
2023-11-22 12:47:34 +01:00
|
|
|
|
).format(str(unread))
|
|
|
|
|
# status_text = (
|
|
|
|
|
# "📰 News items: {}"
|
|
|
|
|
# ).format(str(unread))
|
|
|
|
|
# status_text = (
|
|
|
|
|
# "📰 You have {} news items"
|
|
|
|
|
# ).format(str(unread))
|
|
|
|
|
else:
|
|
|
|
|
status_mode = "available"
|
2023-12-01 14:22:03 +01:00
|
|
|
|
status_text = "📭️ No news"
|
2023-11-22 12:47:34 +01:00
|
|
|
|
|
|
|
|
|
# breakpoint()
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), status_text, "for", jid)
|
2023-12-28 15:50:23 +01:00
|
|
|
|
xmpp.Slixfeed.send_presence(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
self,
|
|
|
|
|
pshow=status_mode,
|
|
|
|
|
pstatus=status_text,
|
|
|
|
|
pto=jid,
|
|
|
|
|
#pfrom=None
|
|
|
|
|
)
|
|
|
|
|
# await asyncio.sleep(60 * 20)
|
|
|
|
|
await refresh_task(
|
|
|
|
|
self,
|
|
|
|
|
jid,
|
|
|
|
|
send_status,
|
|
|
|
|
"status",
|
|
|
|
|
"20"
|
|
|
|
|
)
|
|
|
|
|
# loop.call_at(
|
|
|
|
|
# loop.time() + 60 * 20,
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# send_status(jid)
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def refresh_task(self, jid, callback, key, val=None):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("refresh_task", jid, key)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
Apply new setting at runtime.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
jid : str
|
|
|
|
|
Jabber ID.
|
|
|
|
|
key : str
|
|
|
|
|
Key.
|
|
|
|
|
val : str, optional
|
|
|
|
|
Value. The default is None.
|
|
|
|
|
"""
|
|
|
|
|
if not val:
|
2023-12-04 15:41:02 +01:00
|
|
|
|
val = await initdb(
|
2023-11-22 12:47:34 +01:00
|
|
|
|
jid,
|
2023-12-04 15:41:02 +01:00
|
|
|
|
get_settings_value,
|
2023-11-22 12:47:34 +01:00
|
|
|
|
key
|
|
|
|
|
)
|
|
|
|
|
# if task_manager[jid][key]:
|
|
|
|
|
if jid in task_manager:
|
|
|
|
|
try:
|
|
|
|
|
task_manager[jid][key].cancel()
|
|
|
|
|
except:
|
|
|
|
|
print("No task of type", key, "to cancel for JID", jid)
|
2023-12-28 18:58:49 +01:00
|
|
|
|
# task_manager[jid][key] = loop.call_at(
|
|
|
|
|
# loop.time() + 60 * float(val),
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# (callback(self, jid))
|
|
|
|
|
# # send_update(jid)
|
|
|
|
|
# )
|
|
|
|
|
task_manager[jid][key] = loop.create_task(
|
|
|
|
|
wait_and_run(self, callback, jid, val)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
)
|
|
|
|
|
# task_manager[jid][key] = loop.call_later(
|
|
|
|
|
# 60 * float(val),
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# send_update(jid)
|
|
|
|
|
# )
|
|
|
|
|
# task_manager[jid][key] = send_update.loop.call_at(
|
|
|
|
|
# send_update.loop.time() + 60 * val,
|
|
|
|
|
# send_update.loop.create_task,
|
|
|
|
|
# send_update(jid)
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
2023-12-28 18:58:49 +01:00
|
|
|
|
async def wait_and_run(self, callback, jid, val):
|
|
|
|
|
await asyncio.sleep(60 * float(val))
|
|
|
|
|
await callback(self, jid)
|
|
|
|
|
|
|
|
|
|
|
2023-11-22 12:47:34 +01:00
|
|
|
|
# TODO Take this function out of
|
|
|
|
|
# <class 'slixmpp.clientxmpp.ClientXMPP'>
|
|
|
|
|
async def check_updates(jid):
|
2023-12-24 19:37:05 +01:00
|
|
|
|
# print("check_updates", jid)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), jid, "def check_updates")
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
Start calling for update check up.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
jid : str
|
|
|
|
|
Jabber ID.
|
|
|
|
|
"""
|
|
|
|
|
while True:
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), "> CHCK UPDATE",jid)
|
|
|
|
|
await initdb(jid, download_updates)
|
2023-12-28 19:16:33 +01:00
|
|
|
|
val = await get_value_default("check", "Settings")
|
2023-12-18 16:29:32 +01:00
|
|
|
|
await asyncio.sleep(60 * float(val))
|
2023-11-22 12:47:34 +01:00
|
|
|
|
# Schedule to call this function again in 90 minutes
|
|
|
|
|
# loop.call_at(
|
|
|
|
|
# loop.time() + 60 * 90,
|
|
|
|
|
# loop.create_task,
|
|
|
|
|
# self.check_updates(jid)
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
NOTE
|
|
|
|
|
This is an older system, utilizing local storage instead of XMPP presence.
|
2023-12-08 12:32:01 +01:00
|
|
|
|
This function is good for use with protocols that might not have presence.
|
|
|
|
|
ActivityPub, IRC, LXMF, Matrix, SMTP, Tox.
|
2023-11-22 12:47:34 +01:00
|
|
|
|
"""
|
|
|
|
|
async def select_file(self):
|
|
|
|
|
"""
|
|
|
|
|
Initiate actions by JID (Jabber ID).
|
|
|
|
|
"""
|
|
|
|
|
while True:
|
2023-12-04 15:41:02 +01:00
|
|
|
|
db_dir = get_default_dbdir()
|
2023-11-22 12:47:34 +01:00
|
|
|
|
if not os.path.isdir(db_dir):
|
|
|
|
|
msg = (
|
|
|
|
|
"Slixfeed can not work without a database.\n"
|
|
|
|
|
"To create a database, follow these steps:\n"
|
|
|
|
|
"Add Slixfeed contact to your roster.\n"
|
|
|
|
|
"Send a feed to the bot by URL:\n"
|
|
|
|
|
"https://reclaimthenet.org/feed/"
|
|
|
|
|
)
|
2023-12-04 15:41:02 +01:00
|
|
|
|
# print(await current_time(), msg)
|
2023-11-22 12:47:34 +01:00
|
|
|
|
print(msg)
|
|
|
|
|
else:
|
|
|
|
|
os.chdir(db_dir)
|
|
|
|
|
files = os.listdir()
|
|
|
|
|
# TODO Use loop (with gather) instead of TaskGroup
|
|
|
|
|
# for file in files:
|
|
|
|
|
# if file.endswith(".db") and not file.endswith(".db-jour.db"):
|
|
|
|
|
# jid = file[:-3]
|
|
|
|
|
# jid_tasker[jid] = asyncio.create_task(self.task_jid(jid))
|
|
|
|
|
# await jid_tasker[jid]
|
|
|
|
|
async with asyncio.TaskGroup() as tg:
|
|
|
|
|
for file in files:
|
|
|
|
|
if (file.endswith(".db") and
|
|
|
|
|
not file.endswith(".db-jour.db")):
|
|
|
|
|
jid = file[:-3]
|
|
|
|
|
main_task.extend([tg.create_task(self.task_jid(jid))])
|
|
|
|
|
# main_task = [tg.create_task(self.task_jid(jid))]
|
|
|
|
|
# task_manager.update({jid: tg})
|
|
|
|
|
|
|
|
|
|
|