From b7fc562c888f1c71c5b462c5cb612455625d838c Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 28 May 2019 08:52:45 +0200 Subject: Also skip librsvg import on AttributeError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case python-gobject isn’t installed, but another package (such as libibus) provides overrides, the gi module will still get imported fine despite being empty, resulting in a traceback. To prevent this, we also catch AttributeError so that gi.require_version can fail. --- poezio/windows/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poezio/windows/image.py b/poezio/windows/image.py index dfd2eae2..ebecb5ad 100644 --- a/poezio/windows/image.py +++ b/poezio/windows/image.py @@ -20,7 +20,7 @@ try: from gi.repository import Rsvg import cairo HAS_RSVG = True -except (ImportError, ValueError): +except (ImportError, ValueError, AttributeError): HAS_RSVG = False from poezio.windows.base_wins import Win -- cgit v1.2.3 From 91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 7 Jun 2019 16:09:06 +0200 Subject: plugins/figlet: error out when figlet doesn't exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugins/figlet.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/figlet.py b/plugins/figlet.py index b8fcb813..4d4c7577 100644 --- a/plugins/figlet.py +++ b/plugins/figlet.py @@ -11,15 +11,35 @@ Say something in a Chat tab. .. note:: Can create fun things when used with :ref:`The rainbow plugin `. """ -from poezio.plugin import BasePlugin + import subprocess +from poezio.plugin import BasePlugin + + +def is_figlet() -> bool: + """Ensure figlet exists""" + process = subprocess.Popen( + ['which', 'figlet'], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + return process.wait() == 0 class Plugin(BasePlugin): def init(self): + if not is_figlet(): + self.api.information( + 'Couldn\'t find the figlet program. ' + 'Please install it and reload the plugin.', + 'Error', + ) + return None + self.api.add_event_handler('muc_say', self.figletize) self.api.add_event_handler('conversation_say', self.figletize) self.api.add_event_handler('private_say', self.figletize) + return None def figletize(self, msg, tab): process = subprocess.Popen( -- cgit v1.2.3 From 7250eff3353a76101ff60b2127751b58fbcbc1ce Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Wed, 12 Jun 2019 19:49:00 +0530 Subject: Corrected the search for lastlog messages and refresh of the window. Corrected the search for lastlog messages and refresh of the window. patch from Maxime Buquet Corrected the search for lastlog messages and refresh of the window. --- plugins/lastlog.py | 58 ++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/plugins/lastlog.py b/plugins/lastlog.py index ae946f46..5198527e 100644 --- a/plugins/lastlog.py +++ b/plugins/lastlog.py @@ -12,7 +12,7 @@ import re from poezio.plugin import BasePlugin -from poezio.tabs import ConversationTab, PrivateTab, MucTab +from poezio import tabs from poezio.text_buffer import Message, TextBuffer @@ -32,60 +32,32 @@ def add_line(text_buffer: TextBuffer, text: str) -> None: ) -def add_message(text_buffer: TextBuffer, msg: Message) -> None: - """Adds a message to the TextBuffer""" - text_buffer.add_message( - msg.txt, - msg.time, - None, # Nickname - None, # Nick Color - False, # History - None, # User - msg.highlight, - msg.identifier, - msg.str_time, - None, # Jid - ) - - class Plugin(BasePlugin): """Lastlog Plugin""" def init(self): - self.api.add_tab_command( - ConversationTab, 'lastlog', self.command_lastlog, - usage='', help=( - 'Search in the buffer and returns results' - 'on the screen' - ), - ) - self.api.add_tab_command( - MucTab, 'lastlog', self.command_lastlog, usage='', - help=('Search in the buffer and returns results' - 'on the screen'), - ) - self.api.add_tab_command( - PrivateTab, 'lastlog', self.command_lastlog, usage='', - help=('Search in the buffer and returns results' - 'on the screen'), - ) + for tab in tabs.ConversationTab, tabs.PrivateTab, tabs.MucTab: + self.api.add_tab_command( + tab, + 'lastlog', + self.command_lastlog, + usage='', + help='Search in the buffer and returns results' + 'on the screen') def command_lastlog(self, input_): """Define lastlog command""" text_buffer = self.api.current_tab()._text_buffer - search_re = re.compile(input_) + search_re = re.compile(input_, re.I) res = [] + add_line(text_buffer, "Lastlog:") for message in text_buffer.messages: - if message.nickname is not None: - self.core.information('Foo: %s> %s' % (message.nickname, message.txt), 'Info') if message.nickname is not None and \ search_re.search(message.txt) is not None: res.append(message) - - add_line(text_buffer, "Lastlog for '%s', %d match(es)" % (input_, len(res))) - - for message in res: - message.nickname = None - add_message(text_buffer, message) + add_line(text_buffer, "%s" % (message.txt)) + add_line(text_buffer, "End of Lastlog") + self.api.current_tab().text_win.pos = 0 + self.api.current_tab().core.refresh_window() -- cgit v1.2.3 From f9d34fc789e038280b63f5b76ae0130bf05c269e Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Mon, 17 Jun 2019 18:17:56 +0530 Subject: Updated copyright for lastlog plugin --- plugins/lastlog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/lastlog.py b/plugins/lastlog.py index 5198527e..fd500e08 100644 --- a/plugins/lastlog.py +++ b/plugins/lastlog.py @@ -2,7 +2,8 @@ # -*- coding: utf-8 -*- # vim:fenc=utf-8 # -# Copyright © 2018 Maxime “pep” Buquet +# Copyright © 2018 Maxime “pep” Buquet +# Copyright © 2019 Madhur Garg # # Distributed under terms of the zlib license. See the COPYING file. -- cgit v1.2.3