From df7cc6ed2bca06e524058225deba607e2b0676f7 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Tue, 26 Mar 2024 17:49:16 +0000 Subject: [PATCH] Fix export (Thank you roughnecks). Load commands first at session start (New PubSub related code might block or postpone commands from being loaded). --- slixfeed/action.py | 9 +++++---- slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 4 ++-- slixfeed/xmpp/component.py | 4 ++-- slixfeed/xmpp/process.py | 3 +-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/slixfeed/action.py b/slixfeed/action.py index f14f26e..7e9b625 100644 --- a/slixfeed/action.py +++ b/slixfeed/action.py @@ -92,7 +92,7 @@ except ImportError: 'Arc90 Lab algorithm is disabled.') -async def export_feeds(self, jid, jid_file, ext): +def export_feeds(self, jid, jid_file, ext): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid: {}: jid_file: {}: ext: {}'.format(function_name, jid, jid_file, ext)) cache_dir = config.get_default_cache_directory() @@ -757,7 +757,7 @@ def export_to_markdown(jid, filename, results): file.write('# Subscriptions for {}\n'.format(jid)) file.write('## Set of feeds exported with Slixfeed\n') for result in results: - file.write('- [{}]({})\n'.format(result[0], result[1])) + file.write('- [{}]({})\n'.format(result[1], result[2])) file.write('\n\n* * *\n\nThis list was saved on {} from xmpp:{} using ' '[Slixfeed](https://gitgud.io/sjehuda/slixfeed)\n' .format(dt.current_date(), jid)) @@ -765,6 +765,7 @@ def export_to_markdown(jid, filename, results): # TODO Consider adding element jid as a pointer of import def export_to_opml(jid, filename, results): + print(jid, filename, results) function_name = sys._getframe().f_code.co_name logger.debug('{} jid: {} filename: {}' .format(function_name, jid, filename)) @@ -783,8 +784,8 @@ def export_to_opml(jid, filename, results): body = ET.SubElement(root, "body") for result in results: outline = ET.SubElement(body, "outline") - outline.set("text", result[0]) - outline.set("xmlUrl", result[1]) + outline.set("text", result[1]) + outline.set("xmlUrl", result[2]) # outline.set("type", result[2]) tree = ET.ElementTree(root) tree.write(filename) diff --git a/slixfeed/version.py b/slixfeed/version.py index a912d6e..7487e2f 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.48' -__version_info__ = (0, 1, 48) +__version__ = '0.1.49' +__version_info__ = (0, 1, 49) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index fe85b4e..848bdc5 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -277,6 +277,7 @@ class Slixfeed(slixmpp.ClientXMPP): message_log = '{}' logger.debug(message_log.format(function_name)) status_message = 'Slixfeed version {}'.format(__version__) + self.adhoc_commands() for operator in self.operators: XmppPresence.send(self, operator['jid'], status_message) await profile.update(self) @@ -294,7 +295,6 @@ class Slixfeed(slixmpp.ClientXMPP): Config.add_settings_jid(self.settings, jid_bare, db_file) await task.start_tasks_xmpp_pubsub(self, jid_bare) # XmppCommand.adhoc_commands(self) - self.adhoc_commands() # self.service_reactions() task.task_ping(self) time_end = time.time() @@ -2589,7 +2589,7 @@ class Slixfeed(slixmpp.ClientXMPP): # form['instructions'] = ('✅️ Feeds have been exported') exts = payload['values']['filetype'] for ext in exts: - filename = await action.export_feeds(self, jid_bare, jid_file, ext) + filename = action.export_feeds(self, jid_bare, jid_file, ext) url = await XmppUpload.start(self, jid_bare, filename) chat_type = await get_chat_type(self, jid_bare) XmppMessage.send_oob(self, jid_bare, url, chat_type) diff --git a/slixfeed/xmpp/component.py b/slixfeed/xmpp/component.py index b79f2ba..f5d9509 100644 --- a/slixfeed/xmpp/component.py +++ b/slixfeed/xmpp/component.py @@ -239,6 +239,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): message_log = '{}' logger.debug(message_log.format(function_name)) status_message = 'Slixfeed version {}'.format(__version__) + self.adhoc_commands() for operator in self.operators: XmppPresence.send(self, operator['jid'], status_message) await profile.update(self) @@ -256,7 +257,6 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): Config.add_settings_jid(self.settings, jid_bare, db_file) await task.start_tasks_xmpp_pubsub(self, jid_bare) # XmppCommand.adhoc_commands(self) - self.adhoc_commands() # self.service_reactions() task.task_ping(self) time_end = time.time() @@ -2550,7 +2550,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): # form['instructions'] = ('✅️ Feeds have been exported') exts = payload['values']['filetype'] for ext in exts: - filename = await action.export_feeds(self, jid_bare, jid_file, ext) + filename = action.export_feeds(self, jid_bare, jid_file, ext) url = await XmppUpload.start(self, jid_bare, filename) chat_type = await get_chat_type(self, jid_bare) XmppMessage.send_oob(self, jid_bare, url, chat_type) diff --git a/slixfeed/xmpp/process.py b/slixfeed/xmpp/process.py index b3c33dc..295833d 100644 --- a/slixfeed/xmpp/process.py +++ b/slixfeed/xmpp/process.py @@ -538,8 +538,7 @@ async def message(self, message): # self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message XmppPresence.send(self, jid_bare, status_message, status_type=status_type) - filename = await action.export_feeds(self, jid_bare, - jid_file, ext) + filename = action.export_feeds(self, jid_bare, jid_file, ext) url = await XmppUpload.start(self, jid_bare, filename) # response = ( # 'Feeds exported successfully to {}.\n{}'