Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __enter__(self):
self.tmux_config = self.tempfile(self.tmux_config_contents())
self.bash_config = self.tempfile(self.bash_config_contents())
self.server = tmuxp.Server()
if self.use_existing_session:
try:
session_dict = self.server.attached_sessions() # until tmuxp bug is fixed
if session_dict is None:
raise tmuxp.exc.TmuxpException
self.session = tmuxp.Session(self.server, **session_dict[0])
except tmuxp.exc.TmuxpException:
self.session = self.server.new_session(session_name='rlundotesting')
else:
self.session = self.server.new_session(session_name='rlundotesting', kill_session=True)
self.window = self.session.new_window(attach=False)
try:
output = self.window.panes[0].cmd('respawn-pane', '-k', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
if output.stderr:
raise ValueError(repr(output.stderr) + " " + repr(self.window.panes))
(pane, ) = self.window.panes
output = pane.cmd('respawn-pane', '-k', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
if output.stderr:
raise ValueError(repr(output.stderr) + " " + repr(self.window.panes))
pane.cmd('split-window', '-h', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
pane.cmd('split-window', '-v', 'bash --rcfile %s --noprofile' % (self.bash_config.name, ))
def test_new_session(self):
new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
new_session = Session.new_session(session_name=new_session_name)
self.assertIsInstance(new_session, Session)
def test_new_session(self):
new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
new_session = Session.new_session(session_name=new_session_name)
self.assertIsInstance(new_session, Session)
def test_new_session(self):
new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
new_session = Session.new_session(session_name=new_session_name)
self.assertIsInstance(new_session, Session)
def test_new_session(self):
new_session_name = TEST_SESSION_PREFIX + str(randint(0, 1337))
new_session = Session.new_session(session_name=new_session_name)
self.assertIsInstance(new_session, Session)
)
raise exc.TmuxSessionExists(
'Session name %s is already running.' %
self.sconf['session_name']
)
else:
session = self.server.new_session(
session_name=self.sconf['session_name']
)
assert(self.sconf['session_name'] == session.get('session_name'))
assert(len(self.sconf['session_name']) > 0)
self.session = session
assert(isinstance(session, Session))
focus = None
for w, wconf in self.iter_create_windows(session):
assert(isinstance(w, Window))
focus_pane = None
for p, pconf in self.iter_create_panes(w, wconf):
assert(isinstance(p, Pane))
p = p
if 'layout' in wconf:
w.select_layout(wconf['layout'])
if 'focus' in pconf and pconf['focus']:
focus_pane = p