# HG changeset patch # User cmlenz # Date 1119344023 0 # Node ID d8d44216258a6cd24ad5e909fc2485ee370c8b26 # Parent 21c52720ed32e5c9c327c2d49358804bd5c86cb9 Exit the slave script when the master disconnects; and other minor fixes. diff --git a/bitten/master.py b/bitten/master.py --- a/bitten/master.py +++ b/bitten/master.py @@ -96,7 +96,7 @@ parser.add_option('-p', '--port', action='store', type='int', dest='port', help='port number to use') parser.add_option('-H', '--host', action='store', dest='host', - help='the host name of IP address to bind to') + help='the host name or IP address to bind to') parser.add_option('--debug', action='store_const', dest='loglevel', const=logging.DEBUG, help='enable debugging output') parser.add_option('-v', '--verbose', action='store_const', dest='loglevel', @@ -129,7 +129,8 @@ try: master.run() except KeyboardInterrupt: + # FIXME: gracefully shutdown all active sessions pass if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/bitten/slave.py b/bitten/slave.py --- a/bitten/slave.py +++ b/bitten/slave.py @@ -99,4 +99,4 @@ slave.run() if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/bitten/util/beep.py b/bitten/util/beep.py --- a/bitten/util/beep.py +++ b/bitten/util/beep.py @@ -23,7 +23,8 @@ Current limitations: * No support for the TSL and SASL profiles. - * No support for mapping frames (SEQ frames for TCP mapping). + * No support for mapping frames (SEQ frames for TCP mapping). + * No localization support (xml:lang attribute). """ import asynchat @@ -149,6 +150,10 @@ self.channelno = cycle_through(first_channelno, 2147483647, step=2) self.channels = {0: Channel(self, 0, ManagementProfileHandler)} + def handle_close(self): + logging.debug('Connection closed by peer') + self.close() + def handle_connect(self): """Called by asyncore when the connection is established.""" @@ -299,6 +304,7 @@ def handle_close(self): """Called by asyncore when the socket has been closed.""" self.terminated = True + Session.handle_close(self) def greeting_received(self, profiles): """Sub-classes should override this to start the channels they need. @@ -644,7 +650,16 @@ self.channel.send_err(msgno, MIMEMessage(xml)) def send_start(self, profiles, handle_ok=None, handle_error=None): - """Send a request to start a new channel to the peer.""" + """Send a request to start a new channel to the peer. + + @param profiles A list of profiles to request for the channel, each + element being an instance of a `ProfileHandler` + sub-class + @param handle_ok An optional callback function that will be invoked when + the channel has been successfully started + @param handle_error An optional callback function that will be invoked + when the peer refuses to start the channel + """ channelno = self.session.channelno.next() def handle_reply(cmd, msgno, message): if cmd == 'RPY':