From f925a8effe374e4af61ab1601b0ae3bd7d828d3f Mon Sep 17 00:00:00 2001 From: "Schimon Jehudah, Adv." Date: Thu, 13 Jun 2024 19:37:34 +0300 Subject: [PATCH] Fix functionality search; Delete module task. --- slixfeed/task.py | 131 -------------------------------------- slixfeed/utilities.py | 14 ++++ slixfeed/version.py | 4 +- slixfeed/xmpp/commands.py | 2 +- 4 files changed, 17 insertions(+), 134 deletions(-) delete mode 100644 slixfeed/task.py diff --git a/slixfeed/task.py b/slixfeed/task.py deleted file mode 100644 index 4e9ef85..0000000 --- a/slixfeed/task.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" - -IMPORTANT CONSIDERATION - -This file appears to be redundant and may be replaced by a dict handler that -would match task keyword to functions. - -Or use it as a class Task - -tasks_xmpp_chat = {"check" : check_updates, - "status" : task_status_message, - "interval" : task_message} -tasks_xmpp_pubsub = {"check" : check_updates, - "pubsub" : task_pubsub} - -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"): - -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 - -5) Animate "You have X news items" - 📬️ when sent - 📫️ after sent - -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 - 📂 Send a URL from a blog or a news site. - JID: self.boundjid.bare - MUC: self.alias - -""" - -""" - -TIMEOUT - -import signal - -def handler(signum, frame): - print("Timeout!") - raise Exception("end of time") - -# This line will set the alarm for 5 seconds - -signal.signal(signal.SIGALRM, handler) -signal.alarm(5) - -try: - # Your command here - pass -except Exception as exc: - print(exc) - -""" - -import asyncio -import os -import slixfeed.config as config -from slixfeed.log import Logger - -logger = Logger(__name__) - - -class Task: - - - def start(self, jid_bare, callback): - callback(self, jid_bare) - - - def stop(self, jid_bare, task): - if (jid_bare in self.task_manager and - task in self.task_manager[jid_bare]): - self.task_manager[jid_bare][task].cancel() - else: - logger.debug('No task {} for JID {} (Task.stop)' - .format(task, jid_bare)) - - -""" -NOTE -This is an older system, utilizing local storage instead of XMPP presence. -This function is good for use with protocols that might not have presence. -ActivityPub, IRC, LXMF, Matrix, Nostr, SMTP, Tox. -""" -async def select_file(self): - """ - Initiate actions by JID (Jabber ID). - """ - main_task = [] - while True: - db_dir = config.get_default_data_directory() - if not os.path.isdir(db_dir): - msg = ('Slixfeed does 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/') - # print(await current_time(), msg) - 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))] - # self.task_manager.update({jid: tg}) diff --git a/slixfeed/utilities.py b/slixfeed/utilities.py index e06d8f6..5528d14 100644 --- a/slixfeed/utilities.py +++ b/slixfeed/utilities.py @@ -307,6 +307,20 @@ class SQLiteMaintain: await sqlite.maintain_archive(db_file, limit) +""" + +Consider utilizing a dict as a handler that would match task keyword to functions. + +tasks_xmpp_chat = {"check" : check_updates, + "status" : task_status_message, + "interval" : task_message} + +tasks_xmpp_pubsub = {"check" : check_updates, + "pubsub" : task_pubsub} + +""" + + class Task: diff --git a/slixfeed/version.py b/slixfeed/version.py index dfa4b9b..30e63d9 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.77' -__version_info__ = (0, 1, 77) +__version__ = '0.1.78' +__version_info__ = (0, 1, 78) diff --git a/slixfeed/xmpp/commands.py b/slixfeed/xmpp/commands.py index 03632d1..fcd242b 100644 --- a/slixfeed/xmpp/commands.py +++ b/slixfeed/xmpp/commands.py @@ -931,7 +931,7 @@ class XmppCommands: return message - async def search_items(db_file, query): + def search_items(db_file, query): if query: if len(query) > 3: results = sqlite.search_entries(db_file, query)