1111import os
1212import logging
1313
14- from .util import tmux , TmuxRelationalObject
14+ from .util import tmux_cmd , TmuxRelationalObject
1515from .session import Session
1616from . import formats , exc
1717
@@ -69,10 +69,13 @@ def __init__(
6969 if colors :
7070 self .colors = colors
7171
72- def tmux (self , * args , ** kwargs ):
73- """Return :class:`util.tmux ` send tmux commands with sockets, colors.
72+ def cmd (self , * args , ** kwargs ):
73+ """Return :class:`util.tmux_cmd ` send tmux commands with sockets, colors.
7474
75- :rtype: :class:`util.tmux`
75+ :rtype: :class:`util.tmux_cmd`
76+
77+ :versionchanged: 0.8
78+ Renamed from ``.tmux`` to ``.cmd``.
7679
7780 """
7881
@@ -91,14 +94,14 @@ def tmux(self, *args, **kwargs):
9194 else :
9295 raise ValueError ('Server.colors must equal 88 or 256' )
9396
94- return tmux (* args , ** kwargs )
97+ return tmux_cmd (* args , ** kwargs )
9598
9699 def _list_sessions (self ):
97100 """Return list of sessions in :py:obj:`dict` form.
98101
99102 Retrieved from ``$ tmux(1) list-sessions`` stdout.
100103
101- The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux `
104+ The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux_cmd `
102105 which wraps :py:class:`subprocess.Popen`.
103106
104107 :rtype: :py:obj:`list` of :py:obj:`dict`
@@ -112,7 +115,7 @@ def _list_sessions(self):
112115 '-F%s' % '\t ' .join (tmux_formats ), # output
113116 )
114117
115- proc = self .tmux (
118+ proc = self .cmd (
116119 'list-sessions' ,
117120 * tmux_args
118121 )
@@ -169,7 +172,7 @@ def _list_windows(self):
169172
170173 Retrieved from ``$ tmux(1) list-windows`` stdout.
171174
172- The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux `
175+ The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux_cmd `
173176 which wraps :py:class:`subprocess.Popen`.
174177
175178 :rtype: list
@@ -179,7 +182,7 @@ def _list_windows(self):
179182 wformats = ['session_name' , 'session_id' ] + formats .WINDOW_FORMATS
180183 tmux_formats = ['#{%s}' % format for format in wformats ]
181184
182- proc = self .tmux (
185+ proc = self .cmd (
183186 'list-windows' , # ``tmux list-windows``
184187 '-a' ,
185188 '-F%s' % '\t ' .join (tmux_formats ), # output
@@ -227,7 +230,7 @@ def _list_panes(self):
227230
228231 Retrieved from ``$ tmux(1) list-panes`` stdout.
229232
230- The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux `
233+ The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux_cmd `
231234 which wraps :py:class:`subprocess.Popen`.
232235
233236 :rtype: list
@@ -241,7 +244,7 @@ def _list_panes(self):
241244 ] + formats .PANE_FORMATS
242245 tmux_formats = ['#{%s}\t ' % f for f in pformats ]
243246
244- proc = self .tmux (
247+ proc = self .cmd (
245248 'list-panes' ,
246249 '-a' ,
247250 '-F%s' % '' .join (tmux_formats ), # output
@@ -314,7 +317,7 @@ def has_session(self, target_session):
314317
315318 """
316319
317- proc = self .tmux ('has-session' , '-t%s' % target_session )
320+ proc = self .cmd ('has-session' , '-t%s' % target_session )
318321
319322 if 'failed to connect to server' in proc .stdout :
320323 return False
@@ -327,7 +330,7 @@ def has_session(self, target_session):
327330
328331 def kill_server (self ):
329332 """``$ tmux kill-server``."""
330- self .tmux ('kill-server' )
333+ self .cmd ('kill-server' )
331334
332335 def kill_session (self , target_session = None ):
333336 """Kill the tmux session with ``$ tmux kill-session``, return ``self``.
@@ -338,7 +341,7 @@ def kill_session(self, target_session=None):
338341 :rtype: :class:`Server`
339342
340343 """
341- proc = self .tmux ('kill-session' , '-t%s' % target_session )
344+ proc = self .cmd ('kill-session' , '-t%s' % target_session )
342345
343346 if proc .stderr :
344347 raise exc .TmuxpException (proc .stderr )
@@ -352,8 +355,7 @@ def switch_client(self, target_session):
352355
353356 """
354357
355- # tmux('switch-client', '-t', target_session)
356- proc = self .tmux ('switch-client' , '-t%s' % target_session )
358+ proc = self .cmd ('switch-client' , '-t%s' % target_session )
357359
358360 if proc .stderr :
359361 raise exc .TmuxpException (proc .stderr )
@@ -368,7 +370,7 @@ def attach_session(self, target_session=None):
368370 if target_session :
369371 tmux_args += ('-t%s' % target_session ,)
370372
371- proc = self .tmux ('attach-session' , * tmux_args )
373+ proc = self .cmd ('attach-session' , * tmux_args )
372374
373375 if proc .stderr :
374376 raise exc .TmuxpException (proc .stderr )
@@ -412,7 +414,7 @@ def new_session(self,
412414
413415 if self .has_session (session_name ):
414416 if kill_session :
415- self .tmux ('kill-session' , '-t%s' % session_name )
417+ self .cmd ('kill-session' , '-t%s' % session_name )
416418 logger .info ('session %s exists. killed it.' % session_name )
417419 else :
418420 raise exc .TmuxSessionExists (
@@ -437,7 +439,7 @@ def new_session(self,
437439 if not attach :
438440 tmux_args += ('-d' ,)
439441
440- proc = self .tmux (
442+ proc = self .cmd (
441443 'new-session' ,
442444 * tmux_args
443445 )
0 commit comments