##// END OF EJS Templates
ensure a fallback exists, so use local std{in,out,err}...
Brandon Parsons -
Show More
@@ -70,6 +70,11 b' class IOStream:'
70 def close(self):
70 def close(self):
71 pass
71 pass
72
72
73 # setup stdin/stdout/stderr to sys.stdin/sys.stdout/sys.stderr
74 devnull = open(os.devnull, 'a')
75 stdin = IOStream(sys.stdin, fallback=devnull)
76 stdout = IOStream(sys.stdout, fallback=devnull)
77 stderr = IOStream(sys.stderr, fallback=devnull)
73
78
74 class IOTerm:
79 class IOTerm:
75 """ Term holds the file or file-like objects for handling I/O operations.
80 """ Term holds the file or file-like objects for handling I/O operations.
@@ -82,14 +87,10 b' class IOTerm:'
82 # this class will make it easier to embed it into other environments which
87 # this class will make it easier to embed it into other environments which
83 # are not a normal terminal (such as a GUI-based shell)
88 # are not a normal terminal (such as a GUI-based shell)
84 def __init__(self, stdin=None, stdout=None, stderr=None):
89 def __init__(self, stdin=None, stdout=None, stderr=None):
85 self.stdin = IOStream(stdin, sys.stdin)
90 mymodule = sys.modules[__name__]
86 self.stdout = IOStream(stdout, sys.stdout)
91 self.stdin = IOStream(stdin, mymodule.stdin)
87 self.stderr = IOStream(stderr, sys.stderr)
92 self.stdout = IOStream(stdout, mymodule.stdout)
88
93 self.stderr = IOStream(stderr, mymodule.stderr)
89 # setup stdin/stdout/stderr to sys.stdin/sys.stdout/sys.stderr
90 stdin = sys.stdin if not sys.stdin else IOStream(sys.stdin)
91 stdout = sys.stdout if not sys.stdout else IOStream(sys.stdout)
92 stderr = sys.stderr if not sys.stderr else IOStream(sys.stderr)
93
94
94
95
95 class Tee(object):
96 class Tee(object):
General Comments 0
You need to be logged in to leave comments. Login now