summaryrefslogtreecommitdiff
path: root/pypers/twisted/P13.html
blob: 049184b8bd4f1d8b21b0d95aa7ccdad3cda3390f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
        <html>
        <head>
        <meta name="generator" content="Generated by Python">
        <title>P13</title>
        
<STYLE TYPE="text/css">
  body { font-size: 160%; }
</STYLE>

        </head>
<body bgcolor="lightblue">

       
<table border=0 summary='a table'>
<tr>
  <td bgcolor="lightblue"><small>
<table border=0 summary='a table'>
<tr>
  <td bgcolor="lightblue">
<table border=0 summary='a table'>
<tr>
  <td bgcolor="lightblue"><img src = "cjlogo.jpg" alt = "logo"></td> 
</tr>
</table>
</td> 
</tr>
<tr>
  <td bgcolor="lightblue">
<table border=0 summary='a table'>
<tr>
  <td bgcolor="lightblue"><a href='P14.html'>Next</a></td> <td bgcolor="lightblue"><a href='P12.html'>Prev</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P01.html'>First</a></td> <td bgcolor="lightblue"><a href='P16.html'>Last</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P13.html'>P13</a></td> <td bgcolor="lightblue"></td> 
</tr>
<tr>
  <td bgcolor="lightblue"></td> <td bgcolor="lightblue"></td> 
</tr>
</table>
</td> 
</tr>
<tr>
  <td bgcolor="lightblue">
<table border=0 summary='a table'>
<tr>
  <td bgcolor="lightblue"><a href='P01.html'>P01</a></td> <td bgcolor="lightblue"><a href='P02.html'>P02</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P03.html'>P03</a></td> <td bgcolor="lightblue"><a href='P04.html'>P04</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P05.html'>P05</a></td> <td bgcolor="lightblue"><a href='P06.html'>P06</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P07.html'>P07</a></td> <td bgcolor="lightblue"><a href='P08.html'>P08</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P09.html'>P09</a></td> <td bgcolor="lightblue"><a href='P10.html'>P10</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P11.html'>P11</a></td> <td bgcolor="lightblue"><a href='P12.html'>P12</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P13.html'>P13</a></td> <td bgcolor="lightblue"><a href='P14.html'>P14</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"><a href='P15.html'>P15</a></td> <td bgcolor="lightblue"><a href='P16.html'>P16</a></td> 
</tr>
<tr>
  <td bgcolor="lightblue"></td> <td bgcolor="lightblue"></td> 
</tr>
</table>
</td> 
</tr>
</table>
</small></td> <td bgcolor="lightblue"><h1>A server spawning processes</h1><br/>

<pre>
class FakeTelnet(protocol.Protocol):
    dirToRunIn = os.getcwd()
    def connectionMade(self):
        print 'connection made'
        self.pp = ProcessProtocol(self)
        cmd = self.factory.cmd_list
        reactor.spawnProcess(self.pp, cmd[0], cmd, os.environ,
                             self.dirToRunIn, usePTY=True)
    def dataReceived(self, data):
        self.pp.transport.write(data)
    def connectionLost(self, reason=None):
        print 'connection lost'
        self.pp.transport.loseConnection()

class ProcessProtocol(protocol.ProcessProtocol):
    def __init__(self, telnet):
        self.telnet = telnet
    def outReceived(self, data):
        self.telnet.transport.write(data)
    def errReceived(self, data):
        self.telnet.transport.write("! " + data)
    def processEnded(self, status):
        print 'protocol connection lost'
        self.telnet.transport.loseConnection()
</pre></td> 
</tr>
</table>

        </body>
        
</html>