Added watch option for tmux_split_window()

This commit is contained in:
2Shirt 2018-12-05 03:41:27 -07:00
parent 43b9645c69
commit 2d69d93154
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -204,7 +204,7 @@ def build_outer_panes(state):
# Top # Top
state.panes['Top'] = tmux_split_window( state.panes['Top'] = tmux_split_window(
behind=True, lines=2, vertical=True, behind=True, lines=2, vertical=True,
text='{GREEN}Hardware Diagnostics{CLEAR}'.format(**COLORS)) text=TOP_PANE_TEXT)
# Started # Started
state.panes['Started'] = tmux_split_window( state.panes['Started'] = tmux_split_window(
@ -216,9 +216,7 @@ def build_outer_panes(state):
# Progress # Progress
state.panes['Progress'] = tmux_split_window( state.panes['Progress'] = tmux_split_window(
lines=SIDE_PANE_WIDTH, lines=SIDE_PANE_WIDTH,
text='{BLUE}Progress{CLEAR}\nGoes here\n\n{Meh}'.format( watch=state.progress_out)
Meh=time.strftime('%H:%M:%S %Z'),
**COLORS))
def check_dev_attributes(dev): def check_dev_attributes(dev):
"""Check if device should be tested and allow overrides.""" """Check if device should be tested and allow overrides."""
@ -600,13 +598,13 @@ def tmux_split_window(
lines=None, percent=None, lines=None, percent=None,
behind=False, vertical=False, behind=False, vertical=False,
follow=False, target_pane=None, follow=False, target_pane=None,
command=None, text=None): command=None, text=None, watch=None):
"""Run tmux split-window command and return pane_id as str.""" """Run tmux split-window command and return pane_id as str."""
# Bail early # Bail early
if not lines and not percent: if not lines and not percent:
raise Exception('Neither lines nor percent specified.') raise Exception('Neither lines nor percent specified.')
if not command and not text: if not command and not text and not watch:
raise Exception('Neither command nor text specified.') raise Exception('No command, text, or watch file specified.')
# Build cmd # Build cmd
cmd = ['tmux', 'split-window', '-PF', '#D'] cmd = ['tmux', 'split-window', '-PF', '#D']
@ -628,7 +626,12 @@ def tmux_split_window(
if command: if command:
cmd.extend(command) cmd.extend(command)
elif text: elif text:
cmd.extend(['echo-and-hold', text]) cmd.extend(['echo-and-hold "{}"'.format(text)])
elif watch:
cmd.extend([
'watch', '--color', '--no-title',
'--interval', '1',
'cat', watch])
# Run and return pane_id # Run and return pane_id
result = run_program(cmd) result = run_program(cmd)
@ -644,7 +647,7 @@ def tmux_update_pane(pane_id, command=None, text=None):
if command: if command:
cmd.extend(command) cmd.extend(command)
elif text: elif text:
cmd.extend(['echo-and-hold', text]) cmd.extend(['echo-and-hold "{}"'.format(text)])
run_program(cmd) run_program(cmd)