On this page
libtmux.neo.fetch_obj
- Module
- libtmux.neo
- Package
- libtmux
- Source
- src/libtmux/neo.py
-
Fetch the single
list-*row whose *obj_key* equals *obj_id*.A listing enumerates winlinks, so a window linked into one session at two indexes matches twice.
_best_winlinkthen picks the row tmux itself would act on, rather than whichever sorted last.Examples
>>> from libtmux.neo import fetch_obj >>> fetch_obj( ... server=pane.server, ... obj_key="pane_id", ... obj_id=pane.pane_id, ... list_cmd="list-panes", ... list_extra_args=("-t", pane.pane_id), ... )["pane_id"] == pane.pane_id TrueA pane that does not exist on a live server is a
TmuxObjectDoesNotExist, not a bare tmux error:>>> from libtmux import exc >>> try: ... fetch_obj( ... server=pane.server, ... obj_key="pane_id", ... obj_id="%99999", ... list_cmd="list-panes", ... list_extra_args=("-t", "%99999"), ... ) ... except exc.TmuxObjectDoesNotExist as e: ... print(e) Could not find pane_id=%99999 for list-panes ('-t', '%99999')- Parameters
-
-
server ( Server ) – The tmux server to query.
-
obj_key ( str ) – Identity field to match, e.g.
"pane_id". -
obj_id ( str ) – Value the identity field must equal, e.g.
"%3". -
list_cmd ( ListCmd ) – tmux list subcommand to run.
-
list_extra_args ( ListExtraArgs ) – Extra arguments appended verbatim to the tmux command, e.g.
("-t", "%3")to scope the listing to one object's parent.
-
- Returns
-
OutputRaw The matching row, as a dict of tmux format fields.
- Raises
-
-
TmuxObjectDoesNotExist – When the object does not exist -- whether tmux said so on stderr (
can't find pane: %99, for a-t-scoped listing) or the object simply never appeared in the rows. -
LibTmuxException – For every other tmux failure, notably an unreachable server.
-
0 declared, 0 inherited