annotate zbmux.tac @ 17:b0fc5f8da118

Rename to zbmux.tac, and use application framework. Add emacs magic so it gets edited in Python mode. Make log file rotate at 1Mb.
author darius@Inchoate
date Sun, 18 Jan 2009 13:32:29 +1030
parents zbmux.py@ce3712110055
children 0baf9538a1b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
1 #
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
2 # Mux the ZB module to TCP ports
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
3 #
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
4 # Copyright (c) 2009
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
5 # Daniel O'Connor <darius@dons.net.au>. All rights reserved.
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
6 #
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
7 # Redistribution and use in source and binary forms, with or without
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
8 # modification, are permitted provided that the following conditions
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
9 # are met:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
10 # 1. Redistributions of source code must retain the above copyright
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
11 # notice, this list of conditions and the following disclaimer.
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
12 # 2. Redistributions in binary form must reproduce the above copyright
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
13 # notice, this list of conditions and the following disclaimer in the
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
14 # documentation and/or other materials provided with the distribution.
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
15 #
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
16 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
19 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
26 # SUCH DAMAGE.
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
27 #
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
28
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
29 from twisted.application import internet, service
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
30 from twisted.internet.serialport import SerialPort
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
31 from twisted.internet.protocol import Protocol
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
32 from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
33 from twisted.conch.insults import insults
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
34 from twisted.protocols import basic
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
35 from twisted.internet import protocol, reactor
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
36 from twisted.python import log
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
37 import sys, zb, logging, logging.handlers, string
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
38
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
39 portname = '/dev/cuaU0'
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
40 baudrate = 38400
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
41 lognamebase = '/tmp/zbmux-%d.log'
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
42 baseport = 1080
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
43 zbids = [1, 2]
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
44
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
45 class ZBClient(insults.TerminalProtocol):
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
46 """Client for the TCP connection"""
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
47 #: Time to wait before sending pending data (seconds)
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
48 QUEUE_TIME = 0.1
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
49
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
50 def connectionMade(self):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
51 log.msg("Got new client")
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
52 self.terminal.eraseDisplay()
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
53 self.terminal.resetPrivateModes([])
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
54
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
55 # Send the last whole line we've seen out
15
a472d6eab97e Play back the last 5 lines to newly connected clients rather than 1.
darius@Inchoate
parents: 14
diff changeset
56 for l in self.factory.lastlines:
a472d6eab97e Play back the last 5 lines to newly connected clients rather than 1.
darius@Inchoate
parents: 14
diff changeset
57 self.message(l + '\n')
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
58
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
59 self.pending = ""
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
60 self.pendtimer = None
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
61 self.factory.clients.append(self)
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
62
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
63 def connectionLost(self, reason):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
64 log.msg("Lost a client")
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
65 self.factory.clients.remove(self)
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
66
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
67 def keystrokeReceived(self, keyID, modifier):
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
68 """Got some data, add it to the pending output queue"""
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
69 if modifier != None:
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
70 print "Received unhandled modifier: %s" % (str(modifier))
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
71 return
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
72 #if keyID not in string.printable:
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
73 # print "Received unhandled keyID: %r" % (keyID,)
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
74 # return
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
75 #log.msg("Got key ->%s<-" % (keyID))
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
76 self.pending = self.pending + keyID
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
77 if self.pendtimer == None:
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
78 self.pendtimer = reactor.callLater(self.QUEUE_TIME, self.sendData)
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
79
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
80 def sendData(self):
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
81 """Send pending data to module"""
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
82 #log.msg("sending " + self.pending)
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
83 self.factory.zbproto.sendData(self.factory.zbid, self.pending)
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
84 self.pending = ""
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
85 self.pendtimer = None
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
86
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
87 def message(self, message):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
88 """Called to write a mesage to our client"""
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
89 self.terminal.write(message)
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
90
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
91 class ZBFactory(protocol.ServerFactory):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
92 """Factory for a ZB module
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
93
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
94 Represents a remote ZB module and has zero or more clients and a log file.
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
95 """
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
96 protocol = ZBClient
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
97
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
98 def __init__(self, zbid, lognamebase):
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
99 self.zbid = zbid
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
100 self.clients = []
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
101 self.tmpline = ""
15
a472d6eab97e Play back the last 5 lines to newly connected clients rather than 1.
darius@Inchoate
parents: 14
diff changeset
102 self.lastlines = []
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
103
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
104 # Open logger
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
105 self.logger = logging.getLogger('Zigbee-%d' % (zbid))
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
106 self.logger.setLevel(logging.DEBUG)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
107
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
108 # Add the log message handler to the logger
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
109 handler = logging.handlers.RotatingFileHandler(
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
110 lognamebase % (zbid), maxBytes = 1 * 1024 * 1024, backupCount = 5)
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
111
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
112 self.logger.addHandler(handler)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
113
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
114 def message(self, zbid, message):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
115 """Called when we get a message, check it's for us - if it is log it and write to our clients"""
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
116 if zbid != self.zbid:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
117 return
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
118
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
119 for c in self.clients:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
120 c.message(message)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
121
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
122 # Logger is line oriented, convert from packet oriented here
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
123 self.tmpline = self.tmpline + message
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
124 tmp = self.tmpline.split('\n')
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
125 for l in tmp[0:-1]:
15
a472d6eab97e Play back the last 5 lines to newly connected clients rather than 1.
darius@Inchoate
parents: 14
diff changeset
126 self.lastlines.append(l)
a472d6eab97e Play back the last 5 lines to newly connected clients rather than 1.
darius@Inchoate
parents: 14
diff changeset
127 self.lastlines = self.lastlines[-5:]
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
128 self.logger.debug(l.replace('\n', ''))
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
129 self.tmpline = tmp[-1]
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
130
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
131 class ZBProto(Protocol):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
132 """Protocol to handle packets from the ZB module on the serial port"""
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
133 def __init__(self):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
134 self.pkts = zb.Packets()
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
135 self.factories = []
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
136
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
137 def dataReceived(self, data):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
138 """Parses data from ZB module into packets, calls each factory if a RX packet is received"""
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
139 #log.msg("Read data " + data)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
140 if self.pkts.processstr(data) > 0:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
141 while len(self.pkts.pktq) > 0:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
142 a = self.pkts.pktq.pop(0)
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
143 #log.msg("type is " + str(type(a)))
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
144 if type(a) == type(zb.RX_16_Bit()):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
145 #log.msg("Rx'd from %d => %s" % (a.sender, a.payloadstr))
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
146 for f in self.factories:
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
147 f.message(a.sender, a.payloadstr)
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
148 if type(a) == type(zb.TX_Status()):
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
149 #log.msg("Tx status for frame %d is %s" % (a.frameid, a.statusMsg))
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
150 pass
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
151
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
152 def sendData(self, zbid, data):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
153 """Sends a chunk of data to our ZB module"""
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
154 #log.msg("%d <= %s" % (zbid, data))
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
155
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
156 # Chop up data into pieces the module can handle
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
157 maxsz = zb.TX_16_Bit.PKT_MAX_PAYLOAD
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
158 for i, j in zip(range(0, len(data), maxsz), range(maxsz, len(data) + maxsz, maxsz)):
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
159 p = zb.TX_16_Bit(zbid, data[i:j])
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
160 self.transport.write(p.Pack())
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
161 #log.msg("sent " + str(p))
14
ac60a9244bdf Use proper telnet protocol classes.
darius@Inchoate
parents: 12
diff changeset
162
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
163 application = service.Application('zbmux')
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
164
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
165 # ZigBee serial protocol handler
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
166 zbproto = ZBProto()
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
167 SerialPort(zbproto, portname, reactor, baudrate = 38400)
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
168
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
169 # Per-module TCP listener
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
170 for id in zbids:
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
171 f = ZBFactory(id, lognamebase)
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
172 f.zbproto = zbproto
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
173 f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
174 insults.ServerProtocol,
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
175 ZBClient)
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
176 zbproto.factories.append(f)
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
177 internet.TCPServer(baseport + id, f).setServiceParent(
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
178 service.IServiceCollection(application))
12
a3ec3f2988ac Initial commit of zbmux.
darius@Inchoate
parents:
diff changeset
179
17
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
180 ######################################################################
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
181 #
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
182 # These lines tell Emacs to edit this file in Python mode
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
183 #;;; Local Variables: ***
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
184 #;;; mode:python ***
b0fc5f8da118 Rename to zbmux.tac, and use application framework.
darius@Inchoate
parents: 16
diff changeset
185 #;;; End: ***