Skip to content

Commit 8a5b98e

Browse files
committed
!squash more
1 parent ac22d35 commit 8a5b98e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/libtmux/server.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,27 @@ def __init__(
118118
self.colors = colors
119119

120120
def is_alive(self) -> bool:
121+
"""If server alive or not.
122+
123+
>>> tmux = Server(socket_name="no_exist")
124+
>>> assert not tmux.is_alive()
125+
"""
121126
try:
122127
res = self.cmd("list-sessions")
123-
print(f"returncode: {res.returncode}")
124-
print(f"stdout: {res.stdout}")
125-
print(f"stderr: {res.stderr}")
126128
return res.returncode == 0
127129
except Exception:
128130
return False
129131

130132
def raise_if_dead(self) -> None:
133+
"""Raise if server not connected.
134+
135+
>>> tmux = Server(socket_name="no_exist")
136+
>>> try:
137+
... tmux.raise_if_dead()
138+
... except Exception as e:
139+
... print(type(e))
140+
<class 'subprocess.CalledProcessError'>
141+
"""
131142
tmux_bin = shutil.which("tmux")
132143
if tmux_bin is None:
133144
raise exc.TmuxCommandNotFound()

0 commit comments

Comments
 (0)