Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# empty string for window_index will use the first one available
'-t%s:%s' % (self.get('session_id'), window_index),
)
proc = self.cmd('new-window', *window_args)
if proc.stderr:
raise exc.TmuxpException(proc.stderr)
window = proc.stdout[0]
window = dict(zip(wformats, window.split('\t')))
# clear up empty dict
window = dict((k, v) for k, v in window.items() if v)
window = Window(session=self, **window)
self.server._update_windows()
return window
if window_name:
window_args += ('-n', window_name)
if not attach:
window_args += ('-d',)
window = self.tmux('new-window', *window_args)
window = window.stdout[0]
window = dict(zip(formats, window.split('\t')))
# clear up empty dict
window = dict((k, v) for k, v in window.iteritems() if v)
window = Window(session=self, **window)
if automatic_rename:
window.set_window_option('automatic-rename', True)
self.server._update_windows()
return window
def attached_window(self):
'''
Returns active :class:`Window` object.
'''
active_windows = []
for window in self._windows:
if 'window_active' in window:
# for now window_active is a unicode
if window.get('window_active') == '1':
active_windows.append(Window(session=self, **window))
else:
continue
if len(active_windows) == 1:
return active_windows[0]
else:
raise Exception('multiple active windows found. %s' % active_windows)
if len(self._windows) == 0:
raise Exception('No Windows')
return False
def attached_window(self):
"""Return active :class:`Window` object.
:rtype: :class:`Window`
"""
active_windows = []
for window in self._windows:
if 'window_active' in window:
# for now window_active is a unicode
if window.get('window_active') == '1':
active_windows.append(Window(session=self, **window))
else:
continue
if len(active_windows) == int(1):
return active_windows[0]
else:
raise exc.TmuxpException(
'multiple active windows found. %s' % active_windows)
if len(self._windows) == int(0):
raise exc.TmuxpException('No Windows')
def list_windows(self):
"""Return a list of :class:`Window` from the ``tmux(1)`` session.
:rtype: :class:`Window`
"""
windows = [
w for w in self._windows if w['session_id'] == self._session_id
]
return [Window(session=self, **window) for window in windows]
Return a list of :class:`Window` from the ``tmux(1)`` session.
:rtype: :class:`Window`
'''
new_windows = self._windows
new_windows = [
w for w in new_windows if w['session_id'] == self._session_id
]
#self._windows[:] = []
assert(self.server)
logger.error(self.server)
return [Window(session=self, **window) for window in new_windows]