fixbot/example.py
author Tero Marttila <terom@fixme.fi>
Fri, 05 Feb 2010 21:48:14 +0200
changeset 58 31a17b0b5159
parent 21 aa6df8f9c44a
permissions -rw-r--r--
remove concept of event_types, the event.type is now just sent as a string
21
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     1
from twisted.internet import protocol, reactor
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     2
from twisted.python import log
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     3
import sys
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     4
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     5
import api
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     6
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     7
class ExampleModule (api.Module) :
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     8
    name = "example"
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
     9
    version = 0x0001
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    10
    
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    11
    def handleConnect (self) :
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    12
        self.sendEvent("example", "this is an example event")
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    13
        self.disconnect()
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    14
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    15
if __name__ == '__main__' :
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    16
    log.startLogging(sys.stderr)
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    17
    
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    18
    module = ExampleModule()
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    19
    reactor.run()
aa6df8f9c44a add initial code back under fixbot/, the git-convert somehow broke
terom@fixme.fi
parents:
diff changeset
    20