Home | Trees | Indices | Help |
---|
|
1 # Copyright (c) 2002-2011 IronPort Systems and Cisco Systems 2 # 3 # Permission is hereby granted, free of charge, to any person obtaining a copy 4 # of this software and associated documentation files (the "Software"), to deal 5 # in the Software without restriction, including without limitation the rights 6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 # copies of the Software, and to permit persons to whom the Software is 8 # furnished to do so, subject to the following conditions: 9 # 10 # The above copyright notice and this permission notice shall be included in 11 # all copies or substantial portions of the Software. 12 # 13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 # SOFTWARE. 20 21 # -*- Mode: Python -*- 22 23 # code is from jesse, thx. 24 25 import coro 26 import termios 27 28 # from Python/Lib/tty.py 29 # Indexes for termios list. 30 IFLAG = 0 31 OFLAG = 1 32 CFLAG = 2 33 LFLAG = 3 34 ISPEED = 4 35 OSPEED = 5 36 CC = 6 373969 70 # to use: 71 # 72 # s = stdin() 73 # while 1: 74 # block = s.recv (1024) 75 # 76 # be sure to call restore() or your terminal will be hosed. 7741 coro.sock.__init__ (self, fd=0) 42 self.fd = 0 43 self.old = termios.tcgetattr (self.fd) 44 #print 'old=%r' % (self.old,) 45 self.new = termios.tcgetattr (self.fd) 46 self.new[LFLAG] &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN) 47 self.new[IFLAG] &= ~(termios.IGNBRK | termios.IXOFF | termios.IXON) 48 self.new[CC][termios.VMIN] = 1 49 self.new[CC][termios.VTIME] = 0 50 self.new[CC][termios.CINTR] = 254 # block ctrl-c? doesn't work. 51 #print 'new=%r' % (self.new,) 52 termios.tcsetattr (self.fd, termios.TCSANOW, self.new)5355 self.restore()5658 #print '[restoring stdin to %r]' % (self.old,) 59 termios.tcsetattr (self.fd, termios.TCSAFLUSH, self.old)60 63 66
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Feb 16 18:06:45 2012 | http://epydoc.sourceforge.net |