@@ -141,7 +141,12 @@ class tmux_cmd(object):
141
141
142
142
Usage::
143
143
144
- proc = tmux_cmd('new-session', '-s%' % 'my session')
144
+ c = tmux_cmd('new-session', '-s%' % 'my session')
145
+
146
+ # You can actually see the command in the .cmd attribute
147
+ print(c.cmd)
148
+
149
+ proc = c.execute()
145
150
146
151
if proc.stderr:
147
152
raise exc.LibTmuxException(
@@ -178,6 +183,8 @@ def __init__(self, *args, **kwargs):
178
183
179
184
self .cmd = cmd
180
185
186
+ def execute (self ):
187
+ cmd = self .cmd
181
188
try :
182
189
self .process = subprocess .Popen (
183
190
cmd ,
@@ -213,6 +220,7 @@ def __init__(self, *args, **kwargs):
213
220
'self.stdout for %s: \n %s' %
214
221
(' ' .join (cmd ), self .stdout )
215
222
)
223
+ return self
216
224
217
225
218
226
class TmuxMappingObject (collections .MutableMapping ):
@@ -260,7 +268,7 @@ def __len__(self):
260
268
def __getattr__ (self , key ):
261
269
try :
262
270
return self ._info [self .formatter_prefix + key ]
263
- except :
271
+ except KeyError :
264
272
raise AttributeError ('%s has no property %s' %
265
273
(self .__class__ , key ))
266
274
@@ -354,8 +362,8 @@ def get_by_id(self, id):
354
362
355
363
356
364
def which (exe = None , default_paths = [
357
- '/bin' , '/sbin' , '/usr/bin' , '/usr/sbin' , '/usr/local/bin'
358
- ], append_env_path = True ):
365
+ '/bin' , '/sbin' , '/usr/bin' , '/usr/sbin' , '/usr/local/bin'
366
+ ], append_env_path = True ):
359
367
"""Return path of bin. Python clone of /usr/bin/which.
360
368
361
369
from salt.util - https://www.github.com/saltstack/salt - license apache
@@ -413,7 +421,7 @@ def get_version():
413
421
:returns: tmux version
414
422
:rtype: :class:`distutils.version.LooseVersion`
415
423
"""
416
- proc = tmux_cmd ('-V' )
424
+ proc = tmux_cmd ('-V' ). execute ()
417
425
if proc .stderr :
418
426
if proc .stderr [0 ] == 'tmux: unknown option -- V' :
419
427
if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments