~cbehrens/nova/lp844160-build-works-with-zones

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/test/stdio_test_consumer.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
# -*- test-case-name: twisted.test.test_stdio.StandardInputOutputTestCase.test_consumer -*-
 
2
# Copyright (c) 2006-2007 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
"""
 
6
Main program for the child process run by
 
7
L{twisted.test.test_stdio.StandardInputOutputTestCase.test_consumer} to test
 
8
that process transports implement IConsumer properly.
 
9
"""
 
10
 
 
11
import sys
 
12
 
 
13
from twisted.python import log, reflect
 
14
from twisted.internet import stdio, protocol
 
15
from twisted.protocols import basic
 
16
 
 
17
def failed(err):
 
18
    log.startLogging(sys.stderr)
 
19
    log.err(err)
 
20
 
 
21
class ConsumerChild(protocol.Protocol):
 
22
    def __init__(self, junkPath):
 
23
        self.junkPath = junkPath
 
24
 
 
25
    def connectionMade(self):
 
26
        d = basic.FileSender().beginFileTransfer(file(self.junkPath), self.transport)
 
27
        d.addErrback(failed)
 
28
        d.addCallback(lambda ign: self.transport.loseConnection())
 
29
 
 
30
 
 
31
    def connectionLost(self, reason):
 
32
        reactor.stop()
 
33
 
 
34
 
 
35
if __name__ == '__main__':
 
36
    reflect.namedAny(sys.argv[1]).install()
 
37
    from twisted.internet import reactor
 
38
    stdio.StandardIO(ConsumerChild(sys.argv[2]))
 
39
    reactor.run()