How to use the libtmux.exc.LibTmuxException function in libtmux

To help you get started, we’ve selected a few libtmux 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 / libtmux / pane.py View on Github external
:param target_pane: ``target_pane``, or ``-U``,``-D``, ``-L``, ``-R``.
        :type target_pane: string
        :rtype: :class:`Pane`

        """

        if 'height' in kwargs:
            proc = self.cmd('resize-pane', '-y%s' % int(kwargs['height']))
        elif 'width' in kwargs:
            proc = self.cmd('resize-pane', '-x%s' % int(kwargs['width']))
        else:
            proc = self.cmd('resize-pane', args[0])

        if proc.stderr:
            raise exc.LibTmuxException(proc.stderr)

        self.server._update_panes()
        return self
github tmux-python / libtmux / libtmux / server.py View on Github external
kill 'asdfasd'.

        Returns
        -------
        :class:`Server`

        Raises
        ------
        :exc:`exc.BadSessionName`
        """
        session_check_name(target_session)

        proc = self.cmd('kill-session', '-t%s' % target_session)

        if proc.stderr:
            raise exc.LibTmuxException(proc.stderr)

        return self
github SurrealAI / surreal / surreal / orchestrate / tmux_runner.py View on Github external
def get_window(self, session, window_name):
        if isinstance(session, str):
            # get actual session from session name
            session = self.get_session(session)
            if session is None:
                return None
        try:
            return session.find_where({'window_name': window_name})
        except LibTmuxException:
            return None
github tmux-python / libtmux / libtmux / session.py View on Github external
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.LibTmuxException(
                'multiple active windows found. %s' % active_windows
            )

        if len(self._windows) == int(0):
            raise exc.LibTmuxException('No Windows')
github tmux-python / libtmux / libtmux / exc.py View on Github external
class TmuxCommandNotFound(LibTmuxException):

    """Application binary for tmux not found."""

    pass


class BadSessionName(LibTmuxException):

    """Disallowed session name for tmux (empty, contains periods or colons)."""

    pass


class OptionError(LibTmuxException):

    """Root error for any error involving invalid, ambiguous or bad options."""

    pass


class UnknownOption(OptionError):

    """Option unknown to tmux show-option(s) or show-window-option(s)."""

    pass


class InvalidOption(OptionError):

    """Option invalid to tmux, introduced in tmux v2.4."""
github tmux-python / libtmux / libtmux / window.py View on Github external
----------
        target_pane : str
            'target_pane', '-U' ,'-D', '-L', '-R', or '-l'.

        Return
        ------
        :class:`Pane`
        """

        if target_pane in ['-l', '-U', '-D', '-L', '-R']:
            proc = self.cmd('select-pane', '-t%s' % self.id, target_pane)
        else:
            proc = self.cmd('select-pane', '-t%s' % target_pane)

        if proc.stderr:
            raise exc.LibTmuxException(proc.stderr)

        return self.attached_pane
github tmux-python / tmuxp / libtmux / window.py View on Github external
:type target_pane: string
        :rtype: :class:`Pane`

        """

        if target_pane in ['-l', '-U', '-D', '-L', '-R']:
            proc = self.cmd(
                'select-pane',
                '-t%s' % self.get('window_id'),
                target_pane
            )
        else:
            proc = self.cmd('select-pane', '-t%s' % target_pane)

        if proc.stderr:
            raise exc.LibTmuxException(proc.stderr)

        return self.attached_pane()