From 34a99f86ce6a88952049db813f9cdd4de7ade0bd Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sun, 16 Apr 2023 15:43:18 +0200 Subject: imap-tool: Reorder mailbox stats action Signed-off-by: Paul Kocialkowski --- imap-tool | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/imap-tool b/imap-tool index 455e009..0fbc169 100755 --- a/imap-tool +++ b/imap-tool @@ -11,11 +11,11 @@ from enum import Enum class imap_action(Enum): MAILBOX_LIST = 1 MAILBOX_LIST_SUB = 2 - MAILBOX_CREATE = 3 - MAILBOX_DELETE = 4 - MAILBOX_SUBSCRIBE = 5 - MAILBOX_UNSUBSCRIBE = 6 - MAILBOX_STATS = 7 + MAILBOX_STATS = 3 + MAILBOX_CREATE = 4 + MAILBOX_DELETE = 5 + MAILBOX_SUBSCRIBE = 6 + MAILBOX_UNSUBSCRIBE = 7 MAILBOX_RENAME = 8 MAILBOX_ARCHIVE = 9 @@ -40,13 +40,13 @@ class imap_tool(): "Actions:\n" \ " mailbox-list\n" \ " mailbox-list-sub\n" \ + " mailbox-stats [mailbox]" \ " mailbox-create [mailbox]\n" \ " mailbox-delete [mailbox]\n" \ " mailbox-subscribe [mailbox]\n" \ " mailbox-unsubscribe [mailbox]\n" \ " mailbox-rename [mailbox] [mailbox]\n" \ - " mailbox-archive [mailbox] [year]\n" \ - " mailbox-stats" + " mailbox-archive [mailbox] [year]\n" def error_decode(self, data): return data[0].decode() @@ -88,6 +88,14 @@ class imap_tool(): for entry in data: name = entry.decode().split(" ")[-1] print("- " + name) + elif self.action == imap_action.MAILBOX_STATS: + ret, data = imap.examine(self.mailbox) + if ret != "OK": + print("Error getting stats for mailbox " + self.mailbox) + raise Exception() + + count = int(data[0]) + print("Mailbox " + self.mailbox + " has " + str(count) + " entries") elif self.action == imap_action.MAILBOX_CREATE: ret, data = imap.create(self.mailbox) if ret != "OK": @@ -116,14 +124,6 @@ class imap_tool(): raise Exception() print("Unsubscribed from mailbox " + self.mailbox) - elif self.action == imap_action.MAILBOX_STATS: - ret, data = imap.examine(self.mailbox) - if ret != "OK": - print("Error getting stats for mailbox " + self.mailbox) - raise Exception() - - count = int(data[0]) - print("Mailbox " + self.mailbox + " has " + str(count) + " entries") elif self.action == imap_action.MAILBOX_RENAME: ret, data = imap.rename(self.mailbox[0], self.mailbox[1]) if ret != "OK": -- cgit v1.2.3