~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/examples/stdin.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
 
 
6
"""
 
7
An example of reading a line at a time from standard input
 
8
without blocking the reactor.
 
9
"""
 
10
 
 
11
from twisted.internet import stdio
 
12
from twisted.protocols import basic
 
13
 
 
14
class Echo(basic.LineReceiver):
 
15
    from os import linesep as delimiter
 
16
 
 
17
    def connectionMade(self):
 
18
        self.transport.write('>>> ')
 
19
 
 
20
    def lineReceived(self, line):
 
21
        self.sendLine('Echo: ' + line)
 
22
        self.transport.write('>>> ')
 
23
 
 
24
def main():
 
25
    stdio.StandardIO(Echo())
 
26
    from twisted.internet import reactor
 
27
    reactor.run()
 
28
 
 
29
if __name__ == '__main__':
 
30
    main()