<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import subprocess <EOL> from contextlib import contextmanager <EOL> @ contextmanager <EOL> def preserve_stty_settings ( ) : <EOL> """<STR_LIT>""" <EOL> stty_settings = STTYSettings ( ) <EOL> stty_settings . save_stty_options ( ) <EOL> yield <EOL> stty_settings . restore_ssty_options ( ) <EOL> class STTYSettings ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _stty_options = None <EOL> def save_stty_options ( self ) : <EOL> self . _stty_options = self . _run_cmd ( '<STR_LIT>' ) <EOL> def restore_ssty_options ( self ) : <EOL> self . _run_cmd ( '<STR_LIT>' + self . _stty_options ) <EOL> def _run_cmd ( self , cmd ) : <EOL> po = subprocess . Popen ( cmd , shell = True , stdout = subprocess . PIPE ) <EOL> stdout , _ = po . communicate ( ) <EOL> return stdout </s>
