main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:bastion-ssh 作者: wcc526 项目源码 文件源码
def shell(self):
        """Open a shell."""
        # Make sure we can restore the terminal to a working state after
        # interactive stuff is over
        oldtty = None
        try:
            oldtty = termios.tcgetattr(self.input.fileno())

            # Set tty mode to raw - this is a bit dangerous because it stops
            # Ctrl+C working! But that is required so that you can Ctrl+C
            # remote things
            tty.setraw(self.input.fileno())

            # For testing you could use cbreak mode - here Ctrl+C will kill the
            # local yaybu instance but otherwise is quite like raw mode
            # tty.setcbreak(self.input.fileno())

            # We want non-blocking mode, otherwise session might hang
            # This might cause socket.timeout exceptions, which we just ignore
            # for read() operations
            self.channel.settimeout(0.0)

            self.handle_communications()
        except Exception, e:
            LOG.warn(e, exc_info=True)
        finally:
            if oldtty:
                termios.tcsetattr(self.input.fileno(), termios.TCSADRAIN, oldtty)
            self.channel.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号