File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 25
25
##
26
26
## Copyright 2013 Arduino LLC (http://www.arduino.cc/)
27
27
28
- import tty , termios , select
28
+ import os , tty , termios , select
29
29
from contextlib import contextmanager
30
30
from sys import stdin , stdout
31
31
from subprocess import call
32
32
33
33
@contextmanager
34
34
def cbreak ():
35
- old_attrs = termios .tcgetattr (stdin )
36
- tty .setcbreak (stdin )
37
- tty .setraw (stdin )
35
+ if hasattr (stdin , "fileno" ) and os .isatty (stdin .fileno ()):
36
+ old_attrs = termios .tcgetattr (stdin )
37
+ tty .setcbreak (stdin )
38
+ tty .setraw (stdin )
38
39
try :
39
40
yield
40
41
finally :
41
- termios .tcsetattr (stdin , termios .TCSADRAIN , old_attrs )
42
+ if hasattr (stdin , "fileno" ) and os .isatty (stdin .fileno ()):
43
+ termios .tcsetattr (stdin , termios .TCSADRAIN , old_attrs )
42
44
43
45
class CRC :
44
46
def __init__ (self , file ):
You can’t perform that action at this time.
0 commit comments