How to use the tmuxp.util.run_before_script function in tmuxp

To help you get started, we’ve selected a few tmuxp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmux-python / tmuxp / tests / test_util.py View on Github external
def test_raise_BeforeLoadScriptNotExists_if_not_exists():
    script_file = os.path.join(fixtures_dir, 'script_noexists.sh')

    with pytest.raises(BeforeLoadScriptNotExists):
        run_before_script(script_file)

    with pytest.raises(OSError):
        run_before_script(script_file)
github tmux-python / tmuxp / tests / test_util.py View on Github external
def test_beforeload_returns_stderr_messages():
    script_file = os.path.join(fixtures_dir, 'script_failed.sh')

    with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
        run_before_script(script_file)
        assert excinfo.match(r'failed with returncode')
github tmux-python / tmuxp / tests / test_util.py View on Github external
def test_return_stdout_if_ok(capsys):
    script_file = os.path.join(fixtures_dir, 'script_complete.sh')

    run_before_script(script_file)
    out, err = capsys.readouterr()
    assert 'hello' in out
github tmux-python / tmuxp / tests / test_util.py View on Github external
def test_raise_BeforeLoadScriptError_if_retcode():
    script_file = os.path.join(fixtures_dir, 'script_failed.sh')

    with pytest.raises(BeforeLoadScriptError):
        run_before_script(script_file)
github tmux-python / tmuxp / tests / test_util.py View on Github external
def test_beforeload_returncode():
    script_file = os.path.join(fixtures_dir, 'script_failed.sh')

    with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
        run_before_script(script_file)
        assert excinfo.match(r'113')
github tmux-python / tmuxp / tmuxp / workspacebuilder.py View on Github external
assert self.server.has_session(session.name)
        assert session.id

        assert isinstance(session, Session)

        focus = None

        if 'before_script' in self.sconf:
            try:
                cwd = None

                # we want to run the before_script file cwd'd from the
                # session start directory, if it exists.
                if 'start_directory' in self.sconf:
                    cwd = self.sconf['start_directory']
                run_before_script(self.sconf['before_script'], cwd=cwd)
            except Exception as e:
                self.session.kill_session()
                raise e
        if 'options' in self.sconf:
            for option, value in self.sconf['options'].items():
                self.session.set_option(option, value)
        if 'global_options' in self.sconf:
            for option, value in self.sconf['global_options'].items():
                self.session.set_option(option, value, _global=True)
        if 'environment' in self.sconf:
            for option, value in self.sconf['environment'].items():
                self.session.set_environment(option, value)

        for w, wconf in self.iter_create_windows(session):
            assert isinstance(w, Window)