File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -118,16 +118,27 @@ def __init__(
118
118
self .colors = colors
119
119
120
120
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
+ """
121
126
try :
122
127
res = self .cmd ("list-sessions" )
123
- print (f"returncode: { res .returncode } " )
124
- print (f"stdout: { res .stdout } " )
125
- print (f"stderr: { res .stderr } " )
126
128
return res .returncode == 0
127
129
except Exception :
128
130
return False
129
131
130
132
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
+ """
131
142
tmux_bin = shutil .which ("tmux" )
132
143
if tmux_bin is None :
133
144
raise exc .TmuxCommandNotFound ()
You can’t perform that action at this time.
0 commit comments