Added working_dir arg for tmux command sections

This commit is contained in:
2Shirt 2018-12-06 15:29:06 -07:00
parent dc606a8780
commit ca4234b1c3
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 9 additions and 3 deletions

View file

@ -654,7 +654,8 @@ def run_mprime_test(state):
run_program(['apple-fans', 'max'])
tmux_update_pane(
state.panes['mprime'],
command=['hw-diags-prime95', global_vars['TmpDir']])
command=['hw-diags-prime95', global_vars['TmpDir']],
working_dir=global_vars['TmpDir'])
time_limit = int(MPRIME_LIMIT) * 60
try:
for i in range(time_limit):

View file

@ -32,7 +32,8 @@ def tmux_split_window(
lines=None, percent=None,
behind=False, vertical=False,
follow=False, target_pane=None,
command=None, text=None, watch=None):
working_dir=None, command=None,
text=None, watch=None):
"""Run tmux split-window command and return pane_id as str."""
# Bail early
if not lines and not percent:
@ -57,6 +58,8 @@ def tmux_split_window(
if target_pane:
cmd.extend(['-t', str(target_pane)])
if working_dir:
cmd.extend(['-c', working_dir])
if command:
cmd.extend(command)
elif text:
@ -71,13 +74,15 @@ def tmux_split_window(
result = run_program(cmd)
return result.stdout.decode().strip()
def tmux_update_pane(pane_id, command=None, text=None):
def tmux_update_pane(pane_id, command=None, text=None, working_dir=None):
"""Respawn with either a new command or new text."""
# Bail early
if not command and not text:
raise Exception('Neither command nor text specified.')
cmd = ['tmux', 'respawn-pane', '-k', '-t', pane_id]
if working_dir:
cmd.extend(['-c', working_dir])
if command:
cmd.extend(command)
elif text: