some forgotten commits
authorTero Marttila <terom@fixme.fi>
Wed, 26 Mar 2008 01:12:11 +0200
changeset 15 e31e38d654b6
parent 12 cf388baabf0a
child 16 521fec9bb663
some forgotten commits

committer: Tero Marttila <terom@fixme.fi>
irc.py
logwatcher.py
nexus.py
--- a/irc.py	Tue Mar 25 19:10:59 2008 +0200
+++ b/irc.py	Wed Mar 26 01:12:11 2008 +0200
@@ -5,11 +5,11 @@
 
 import buffer
 
-HOSTNAME        = "irc6.marttila.de"
+HOSTNAME        = "irc.fixme.fi"
 PORT            = 6667
 NICKNAME        = "FixBot"
 USERNAME        = "fixme"
-CHANNEL         = "#fixme-test"
+CHANNEL         = "#fixme"
 
 class ReplyException (Exception) :
     def __init__ (self, reply) :
--- a/logwatcher.py	Tue Mar 25 19:10:59 2008 +0200
+++ b/logwatcher.py	Wed Mar 26 01:12:11 2008 +0200
@@ -1,8 +1,9 @@
 from twisted.internet import protocol, reactor
 from twisted.python import log
-import sys, re
+import sys
 
 import api
+import logwatch_config as config
 
 class TailProcessProtocol (protocol.ProcessProtocol) :
     def __init__ (self, module, name, filters) :
@@ -38,46 +39,6 @@
         log.err(msg)
         self.module.error(msg)
 
-class Filter (object) :
-    def __init__ (self, regexp, event_type) :
-        self.regexp = re.compile(regexp)
-        self.event_type = event_type
-
-    def test (self, line) :
-        match = self.regexp.search(line)
-        
-        if match :
-            return self._filter(match)
-        
-    def _filter (self, match) :
-        return match.string
-
-class AutoFilter (Filter) :
-    # your event type here, as a string
-    EVENT = None
-
-    # your regexp here, with named matchgroups
-    REGEXP = None
-
-    # your output format, with named interpolation params
-    OUTPUT = None
-    
-    def __init__ (self) :
-        super(AutoFilter, self).__init__(self.REGEXP, self.EVENT)
-    
-    def _filter (self, match) :
-        return self.OUTPUT % match.groupdict()
-
-class SudoFilter (AutoFilter) :
-    EVENT   = "sudo"
-    REGEXP  = "sudo:\s*(?P<username>\S+) : TTY=(?P<tty>\S+) ; PWD=(?P<pwd>.+?) ; USER=(?P<target_user>\S+) ; COMMAND=(?P<command>.*)"
-    OUTPUT  = "%(username)s:%(tty)s - %(pwd)s - `%(command)s` as %(target_user)s"
-
-class SSHFilter (AutoFilter) :
-    EVENT   = "ssh"
-    REGEXP  = "(?P<success>Accepted|Failed) password for (?P<username>\S+) from (?P<ip>\S+) port (?P<port>\S+) (?P<proto>\S+)"
-    OUTPUT  = "%(success)s login for %(username)s from %(ip)s:%(port)s proto %(proto)s"
-
 class LogWatchModule (api.Module) :
     name = "logs"
     version = 0x0001
@@ -87,13 +48,8 @@
         "sudo",
         "ssh",
     ]
-
-    log_files = (
-        ("auth.log", "/var/log/auth.log", (
-            SudoFilter(),
-            SSHFilter(),
-        )),
-    )
+    
+    log_files = config.log_files
 
     log_objs = None
 
--- a/nexus.py	Tue Mar 25 19:10:59 2008 +0200
+++ b/nexus.py	Wed Mar 26 01:12:11 2008 +0200
@@ -11,7 +11,7 @@
         self.nexus = nexus
         
         log.msg("Connecting to IRC at %s:%d" % (irc.HOSTNAME, irc.PORT))
-        reactor.connectTCP6(irc.HOSTNAME, irc.PORT, self)
+        reactor.connectTCP(irc.HOSTNAME, irc.PORT, self)
 
         self.connection = None