DRYer
This commit is contained in:
parent
e25b90c1b6
commit
7fe1376e34
@ -162,6 +162,8 @@ class BaseTest(TestCase):
|
|||||||
class PTY:
|
class PTY:
|
||||||
|
|
||||||
def __init__(self, argv, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20, cwd=None, env=None):
|
def __init__(self, argv, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20, cwd=None, env=None):
|
||||||
|
if isinstance(argv, str):
|
||||||
|
argv = shlex.split(argv)
|
||||||
pid, self.master_fd = fork()
|
pid, self.master_fd = fork()
|
||||||
self.is_child = pid == CHILD
|
self.is_child = pid == CHILD
|
||||||
if self.is_child:
|
if self.is_child:
|
||||||
@ -169,12 +171,7 @@ class PTY:
|
|||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
if cwd:
|
if cwd:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
if env:
|
os.execvpe(argv[0], argv, env or os.environ)
|
||||||
os.environ.clear()
|
|
||||||
os.environ.update(env)
|
|
||||||
if isinstance(argv, str):
|
|
||||||
argv = shlex.split(argv)
|
|
||||||
os.execlp(argv[0], *argv)
|
|
||||||
os.set_blocking(self.master_fd, False)
|
os.set_blocking(self.master_fd, False)
|
||||||
self.cell_width = cell_width
|
self.cell_width = cell_width
|
||||||
self.cell_height = cell_height
|
self.cell_height = cell_height
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user