[Otfbot-dev] [Git] OTFBot branch, master, updated. 279d80ce02fa35e4aeaa484271e8a0b69414196c

git version control gitrepo at otfbot.org
So Nov 7 15:31:41 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OTFBot".

The branch, master has been updated
       via  279d80ce02fa35e4aeaa484271e8a0b69414196c (commit)
       via  575609c8e7913e70fe4904aba4601102a3165e96 (commit)
      from  dbac12064d47b0c0891c426600341c6074f5af95 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 279d80ce02fa35e4aeaa484271e8a0b69414196c
Author: allo <allo at laxu.de>
Date:   Sun Nov 7 15:30:13 2010 +0100

    no error logger for "cannot listen".
    
    error logger is only for things, which should be reported as bug. if the
    tcpServer cannot listen on a socket, its a configuration issue (stale
    socket file / already used tcpPort)

diff --git a/otfbot/services/tcpServer.py b/otfbot/services/tcpServer.py
index 05a1689..d456f5b 100644
--- a/otfbot/services/tcpServer.py
+++ b/otfbot/services/tcpServer.py
@@ -23,6 +23,7 @@
 """
 
 from twisted.internet import protocol
+from twisted.internet.error import CannotListenError
 from twisted.internet.protocol import Factory, Protocol
 from twisted.internet.tcp import Server
 from twisted.protocols.basic import LineOnlyReceiver
@@ -79,7 +80,10 @@ class botService(service.MultiService):
         if "tcp" in modes or "socket" in modes:
             try:
                 service.MultiService.startService(self)
+            except CannotListenError, e:
+                self.logger.warning(e)
             except Exception, e:
+                self.logger.error(repr(e))
                 self.logger.error(e)
 
 
commit 575609c8e7913e70fe4904aba4601102a3165e96
Author: allo <allo at laxu.de>
Date:   Sun Nov 7 15:25:10 2010 +0100

    logging with Condition instead of Lock and polling every second

diff --git a/otfbot/plugins/ircClient/log.py b/otfbot/plugins/ircClient/log.py
index 76720bd..f3b3997 100644
--- a/otfbot/plugins/ircClient/log.py
+++ b/otfbot/plugins/ircClient/log.py
@@ -23,7 +23,7 @@
 """
 
 from twisted.internet import reactor
-from threading import Lock
+from threading import Condition
 
 from otfbot.lib import chatMod
 from otfbot.lib.pluginSupport.decorators import callback
@@ -67,7 +67,7 @@ class Plugin(chatMod.chatMod):
         self.logs=[]
         self.privateLogs=[]
         self.stopThread=False
-        self.bufferLock=Lock()
+        self.bufferCondition=Condition()
 
     def timemap(self):
         return {'y': self.ts("%Y"), 'm': self.ts("%m"), 'd': self.ts("%d")}
@@ -113,28 +113,30 @@ class Plugin(chatMod.chatMod):
                 file = open(filename, "a")
                 file.write(self.ts() + " " + mystring.encode("UTF-8") + "\n")
                 file.close()
+        self.bufferCondition.acquire()
         while not self.stopThread:
-            time.sleep(1)
-            self.bufferLock.acquire()
+            self.bufferCondition.wait()
             logs=copy.copy(self.logs)
             self.logs=[]
             privateLogs=copy.copy(self.privateLogs)
             self.privateLogs=[]
-            self.bufferLock.release()
             for call in logs:
                 real_log(self, call[0], call[1], call[2])
             for call in privateLogs:
                 real_logPrivate(self, call[0], call[1])
+        self.bufferCondition.release()
 
     def log(self, channel, string, timestamp=True):
-        self.bufferLock.acquire()
+        self.bufferCondition.acquire()
         self.logs.append((channel, string, timestamp))
-        self.bufferLock.release()
+        self.bufferCondition.notify()
+        self.bufferCondition.release()
 
     def logPrivate(self, user, mystring):
-        self.bufferLock.acquire()
+        self.bufferCondition.acquire()
         self.privateLogs.append((user, mystring))
-        self.bufferLock.release()
+        self.bufferCondition.notify()
+        self.bufferCondition.release()
 
     def openLog(self, channel):
         self.channels[string.lower(channel)] = 1
-----------------------------------------------------------------------

Summary of changes:
 otfbot/plugins/ircClient/log.py |   20 +++++++++++---------
 otfbot/services/tcpServer.py    |    4 ++++
 2 files changed, 15 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
OTFBot



Mehr Informationen über die Mailingliste Otfbot-dev