Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Darst <rkd@zgib.net>2009-08-01 00:38:26 (GMT)
committer Richard Darst <rkd@zgib.net>2009-08-01 00:38:26 (GMT)
commit48940a3200faae1f8947f2ea5be0f85ac6379fb1 (patch)
tree8a469388df7c5362ca1c8a69a0ab44b1ed260d50
parentadacd645f987d2837ad00b3928f3678c49a2fe2a (diff)
First effort at realtime updating of log files
- With this change, the .log.txt is updated after every said line, so that people can catch up to the meeting. - This is a general mechanism, but not the most efficient for this task: It re-opens the file after every line. This isn't ideal, but was easiest to integrate. There are other considerations, such as the fact that filenames can change during the meeting (#meetingname command) or file permissions change (#restrictlogs). I still need to work out how to deal with these issues... darcs-hash:20090801003826-82ea9-fddfe6f61bf11ccce94fd80f6f66f3ffbe5fc9f7.gz
-rw-r--r--meeting.py34
-rw-r--r--writers.py6
2 files changed, 29 insertions, 11 deletions
diff --git a/meeting.py b/meeting.py
index dc5b69e..576df8a 100644
--- a/meeting.py
+++ b/meeting.py
@@ -95,7 +95,7 @@ class Config(object):
"Log: %(urlBasename)s.log.html")
input_codec = 'utf-8'
output_codec = 'utf-8'
- update_realtime = False
+ update_realtime = True
def enc(self, text):
return text.encode(self.output_codec, 'replace')
def dec(self, text):
@@ -115,14 +115,27 @@ class Config(object):
self.M = M
self.writers = { }
- if writeRawLog:
- self.writers['.log.txt'] = writers.TextLog(self.M)
- for extension, writer in self.writer_map.iteritems():
- def save_file():
- pass
- self.writers[extension] = writer(self.M)
if hasattr(self, "init"):
self.init()
+
+ if writeRawLog:
+ def save_file(text, extension='.log.txt'):
+ # Don't save if meeting is already over, or configured to
+ # not update in real time.
+ if self.M._meetingIsOver or not self.update_realtime or \
+ not hasattr(self.M, 'starttime'):
+ return
+ self.writeToFile(text, self.filename()+extension)
+ self.writers['.log.txt'] = writers.TextLog(self.M,
+ save_file=save_file)
+ for extension, writer in self.writer_map.iteritems():
+ def save_file(text, extension=extension):
+ # Don't save if meeting is already over, or configured to
+ # not update in real time.
+ if self.M._meetingIsOver or not self.update_realtime:
+ return
+ self.writeToFile(text, self.filename()+extension)
+ self.writers[extension] = writer(self.M, save_file=save_file)
def filename(self, url=False):
# provide a way to override the filename. If it is
# overridden, it must be a full path (and the URL-part may not
@@ -464,9 +477,6 @@ class Meeting(MeetingCommands, object):
self.do_link(nick=nick, line=line,
linenum=linenum, time_=time_)
- for writer in self.config.writers:
- if hasattr(writer, 'addline'):
- writer.addlogline(logline)
def addrawline(self, nick, line, time_=None):
"""This adds a line to the log, bypassing command execution.
"""
@@ -487,6 +497,10 @@ class Meeting(MeetingCommands, object):
nick, line.strip())
self.lines.append(logline)
linenum = len(self.lines)
+ for ext, writer in self.config.writers.iteritems():
+ if hasattr(writer, 'addline'):
+ writer.addline(logline)
+ return linenum
def additem(self, m):
"""Add an item to the meeting minutes list.
diff --git a/writers.py b/writers.py
index e40c037..c942b77 100644
--- a/writers.py
+++ b/writers.py
@@ -69,8 +69,9 @@ def replaceWRAP(item):
class _BaseWriter(object):
- def __init__(self, M):
+ def __init__(self, M, save_file=None, **kwargs):
self.M = M
+ self.save_file = save_file
def format(self, extension=None):
"""Override this method to implement the formatting.
@@ -126,6 +127,9 @@ class TextLog(_BaseWriter):
M = self.M
"""Write raw text logs."""
return "\n".join(M.lines)
+ def addline(self, line):
+ self.save_file(self.format())
+
class HTMLlog(_BaseWriter):