term.py: register_cleanup() fix
This commit is contained in:
parent
b8bf2c7df2
commit
e52588b5af
1 changed files with 16 additions and 8 deletions
|
|
@ -47,14 +47,7 @@ class MMGenTerm(object):
|
|||
|
||||
@classmethod
|
||||
def register_cleanup(cls):
|
||||
if gc.platform == 'linux' and not hasattr(cls,'cleanup_registered'):
|
||||
import atexit
|
||||
atexit.register(
|
||||
lambda: termios.tcsetattr(
|
||||
cls.stdin_fd,
|
||||
termios.TCSADRAIN,
|
||||
cls.orig_term) )
|
||||
cls.cleanup_registered = True
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def init(cls,noecho=False):
|
||||
|
|
@ -74,6 +67,17 @@ class MMGenTerm(object):
|
|||
|
||||
class MMGenTermLinux(MMGenTerm):
|
||||
|
||||
@classmethod
|
||||
def register_cleanup(cls):
|
||||
if not hasattr(cls,'cleanup_registered'):
|
||||
import atexit
|
||||
atexit.register(
|
||||
lambda: termios.tcsetattr(
|
||||
cls.stdin_fd,
|
||||
termios.TCSADRAIN,
|
||||
cls.orig_term) )
|
||||
cls.cleanup_registered = True
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
termios.tcsetattr( cls.stdin_fd, termios.TCSANOW, cls.orig_term )
|
||||
|
|
@ -159,6 +163,10 @@ class MMGenTermLinux(MMGenTerm):
|
|||
|
||||
class MMGenTermLinuxStub(MMGenTermLinux):
|
||||
|
||||
@classmethod
|
||||
def register_cleanup(cls):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def init(cls,noecho=False):
|
||||
cls.stdin_fd = sys.stdin.fileno()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue