example.py
author Tero Marttila <terom@fixme.fi>
Wed, 26 Mar 2008 01:12:11 +0200
changeset 15 e31e38d654b6
parent 3 5ab150c4a328
permissions -rw-r--r--
some forgotten commits

committer: Tero Marttila <terom@fixme.fi>
3
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     1
from twisted.internet import protocol, reactor
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     2
from twisted.python import log
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     3
import sys
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     4
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     5
import api
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     6
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     7
class ExampleModule (api.Module) :
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     8
    name = "example"
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
     9
    version = 0x0001
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    10
    
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    11
    event_types = [
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    12
        "example"
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    13
    ]
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    14
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    15
    def handleConnect (self) :
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    16
        self.sendEvent("example", "this is an example event")
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    17
        self.disconnect()
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    18
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    19
if __name__ == '__main__' :
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    20
    log.startLogging(sys.stderr)
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    21
    
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    22
    module = ExampleModule()
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    23
    reactor.run()
5ab150c4a328 it works \o/ + the start of logwatcher.py
Tero Marttila <terom@paivola.fi>
parents:
diff changeset
    24