From 432ec7ff7d65aad1e88effd03ea205c788969022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Tue, 7 Mar 2017 15:57:50 +0100 Subject: [PATCH 1/4] Fix usage of logger constants in command system The definition of various constants was refactored to use enumerations in commit 2fbadc91e9dc. One reference in the command system was not changed to use the new enum, however. --- src/command_system/implementation/standard.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/command_system/implementation/standard.py b/src/command_system/implementation/standard.py index 8644242cd..e9fc100f5 100644 --- a/src/command_system/implementation/standard.py +++ b/src/command_system/implementation/standard.py @@ -24,7 +24,7 @@ import dialogs from common import gajim from common import helpers from common.exceptions import GajimGeneralException -from common.logger import Constants +from common.logger import KindConstant from ..errors import CommandError from ..framework import CommandContainer, command, doc @@ -32,10 +32,6 @@ from ..mapping import generate_usage from .hosts import ChatCommands, PrivateChatCommands, GroupChatCommands -# This holds constants fron the logger, which we'll be using in some of our -# commands. -lc = Constants() - class StandardCommonCommands(CommandContainer): """ This command container contains standard commands which are common @@ -107,7 +103,7 @@ class StandardCommonCommands(CommandContainer): contact, time, kind, show, message, subject = row if not contact: - if kind == lc.KIND_CHAT_MSG_SENT: + if kind == KindConstant.CHAT_MSG_SENT: contact = gajim.nicks[self.account] else: contact = self.contact.name From f1ee561b9b4996a9812e930f302d863be8468a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Tue, 7 Mar 2017 16:18:57 +0100 Subject: [PATCH 2/4] Fix broken command system by importing CommandContainer modules ChatControlBase was split from ChatControl into its own module in commit 80221afc2ccb. With this split the import of the CommandContainer modules was removed as well, likely because their members are not referenced anywhere. However, importing these modules even when they are not used directly is crucial because the contained CommandContainers are only registered with the command system when their definitions are evaluated. Import the modules with CommandContainers in chat_control_base.py to fix the command system. Also add a comment stating more clearly why the imports need to be kept around. --- src/chat_control_base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/chat_control_base.py b/src/chat_control_base.py index 687819d28..d4be021b2 100644 --- a/src/chat_control_base.py +++ b/src/chat_control_base.py @@ -54,6 +54,13 @@ from common.connection_handlers_events import MessageOutgoingEvent from command_system.implementation.middleware import ChatCommandProcessor from command_system.implementation.middleware import CommandTools +# The members of these modules are not referenced directly anywhere in this +# module, but still they need to be kept around. Importing them automatically +# registers the contained CommandContainers with the command system, thereby +# populating the list of available commands. +import command_system.implementation.standard +import command_system.implementation.execute + try: import gtkspell HAS_GTK_SPELL = True From ceb7772b5b82ef392ffce8db0db7902fda2fa04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Tue, 7 Mar 2017 16:36:43 +0100 Subject: [PATCH 3/4] Correct some typos in command system comments --- src/command_system/framework.py | 4 ++-- src/command_system/implementation/middleware.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command_system/framework.py b/src/command_system/framework.py index c6922c953..38d1436a6 100644 --- a/src/command_system/framework.py +++ b/src/command_system/framework.py @@ -15,7 +15,7 @@ """ Provides a tiny framework with simple, yet powerful and extensible -architecture to implement commands in a streight and flexible, +architecture to implement commands in a straight and flexible, declarative way. """ @@ -67,7 +67,7 @@ class CommandProcessor(object): """ # This defines a command prefix (or an initializer), which should - # preceede a a text in order it to be processed as a command. + # precede a text in order for it to be processed as a command. COMMAND_PREFIX = '/' def process_as_command(self, text): diff --git a/src/command_system/implementation/middleware.py b/src/command_system/implementation/middleware.py index d291517c5..1ad925771 100644 --- a/src/command_system/implementation/middleware.py +++ b/src/command_system/implementation/middleware.py @@ -75,7 +75,7 @@ class ChatCommandProcessor(CommandProcessor): self.command_succeeded = True def looks_like_command(self, text, body, name, arguments): - # Command escape stuff ggoes here. If text was prepended by the + # Command escape stuff goes here. If text was prepended by the # command prefix twice, like //not_a_command (if prefix is set # to /) then it will be escaped, that is sent just as a regular # message with one (only one) prefix removed, so message will be From 0189305495ccf4989dac841df97c14b4a87c7520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Tue, 7 Mar 2017 16:48:32 +0100 Subject: [PATCH 4/4] Fix grep command in chat window Commit d75ebd95e5e3 modified the return value of logger.py's method get_search_results_for_query by appending another component to the tuple. Because of this unpacking the tuple in the command system's grep command failed. --- src/command_system/implementation/standard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command_system/implementation/standard.py b/src/command_system/implementation/standard.py index e9fc100f5..ba838eb40 100644 --- a/src/command_system/implementation/standard.py +++ b/src/command_system/implementation/standard.py @@ -100,7 +100,7 @@ class StandardCommonCommands(CommandContainer): raise CommandError(_("Limit must be an integer")) for row in results: - contact, time, kind, show, message, subject = row + contact, time, kind, show, message, subject, log_line_id = row if not contact: if kind == KindConstant.CHAT_MSG_SENT: