Commit 653546570de4ed72ad07022a9ff50198165228dc
- Date: Fri May 09 21:07:28 +0000 2008
- Committer: Rodrigo Lazo (rlazo.paz@gmail.com)
- Author: Rodrigo Lazo (rlazo.paz@gmail.com)
- Commit SHA1: 653546570de4ed72ad07022a9ff50198165228dc
- Tree SHA1: 96d4b866b7bb6a2cb8de0d29f1f2d712fefa66bf
fixed unread msg double counting + pdb in code
Commit diff
| |   |
| 120 | 120 | connection.""" |
| 121 | 121 | self.config = ConfigParser() |
| 122 | 122 | self.read_msgs = list() |
| 123 | self.empty_msg_queue = True |
| 123 | 124 | self.plugin_manager = PluginManager() |
| 124 | 125 | self.connection = None |
| 125 | 126 | self.unread_msg_count = 0 |
| … | … | |
| 194 | 194 | |
| 195 | 195 | if not self.has_new_mail(): |
| 196 | 196 | logging.info("[Main] No new messages") |
| 197 | | self.plugin_manager.emit_signal('no_new_messages') |
| 197 | self.plugin_manager.emit_signal('no_new_messages', empty_queue = self.empty_msg_queue) |
| 198 | 198 | # Check again later |
| 199 | | len(self.read_msgs) == 0 or \ |
| 199 | if self.empty_msg_queue: |
| 200 | 200 | self.status_icon.set_from_file(self.status_icon.inactive_icon) |
| 201 | 201 | return True |
| 202 | 202 | self.status_icon.set_from_file(self.status_icon.active_icon) |
| … | … | |
| 213 | 213 | self.connection.refreshInfo() |
| 214 | 214 | msgs = self.connection.getMsgList() |
| 215 | 215 | # are all the messages already seen? |
| 216 | | import pdb |
| 217 | | pdb.set_trace() |
| 218 | 216 | |
| 219 | 217 | set1 = set(x["id"] for x in self.read_msgs) |
| 220 | 218 | same_messages = set1.issuperset(x["id"] for x in msgs) |
| 221 | | if not same_messages: |
| 222 | | self.read_msgs = msgs[:] |
| 219 | self.empty_msg_queue = len(msgs) == 0 |
| 220 | self.read_msgs = msgs[:] |
| 223 | 221 | return not same_messages |
| 224 | 222 | except Exception, ex: |
| 225 | 223 | logging.exception("[Main] getUnreadMsgCount() failed, will try again later") |
| toggle raw diff |
--- a/gmail-sentinel.py
+++ b/gmail-sentinel.py
@@ -120,6 +120,7 @@ class Gnotify:
connection."""
self.config = ConfigParser()
self.read_msgs = list()
+ self.empty_msg_queue = True
self.plugin_manager = PluginManager()
self.connection = None
self.unread_msg_count = 0
@@ -193,9 +194,9 @@ class Gnotify:
if not self.has_new_mail():
logging.info("[Main] No new messages")
- self.plugin_manager.emit_signal('no_new_messages')
+ self.plugin_manager.emit_signal('no_new_messages', empty_queue = self.empty_msg_queue)
# Check again later
- len(self.read_msgs) == 0 or \
+ if self.empty_msg_queue:
self.status_icon.set_from_file(self.status_icon.inactive_icon)
return True
self.status_icon.set_from_file(self.status_icon.active_icon)
@@ -212,13 +213,11 @@ class Gnotify:
self.connection.refreshInfo()
msgs = self.connection.getMsgList()
# are all the messages already seen?
- import pdb
- pdb.set_trace()
set1 = set(x["id"] for x in self.read_msgs)
same_messages = set1.issuperset(x["id"] for x in msgs)
- if not same_messages:
- self.read_msgs = msgs[:]
+ self.empty_msg_queue = len(msgs) == 0
+ self.read_msgs = msgs[:]
return not same_messages
except Exception, ex:
logging.exception("[Main] getUnreadMsgCount() failed, will try again later") |