How to use the shellingham.ShellDetectionFailure function in shellingham

To help you get started, we’ve selected a few shellingham 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 pypa / pipenv / pipenv / patched / crayons.py View on Github external
COLORS = __all__[:-2]

is_ipython = "get_ipython" in dir()

if (
    os.environ.get("CMDER_ROOT")
    or os.environ.get("VSCODE_PID")
    or os.environ.get("TERM_PROGRAM") == "Hyper"
):
    is_native_powershell = False
else:
    is_native_powershell = True

try:
    is_powershell = "powershell" in shellingham.detect_shell()[0]
except shellingham.ShellDetectionFailure:
    is_powershell = False

if is_ipython or (is_powershell and is_native_powershell):
    """when ipython is fired lot of variables like _oh, etc are used.
       There are so many ways to find current python interpreter is ipython.
       get_ipython is easiest is most appealing for readers to understand.
    """
    DISABLE_COLOR = True
else:
    DISABLE_COLOR = False


class ColoredString(object):
    """Enhanced string for __len__ operations on Colored output."""

    def __init__(self, color, s, always_color=False, bold=False):
github python-poetry / poetry / poetry / utils / shell.py View on Github external
def get(cls):  # type: () -> Shell
        """
        Retrieve the current shell.
        """
        if cls._shell is not None:
            return cls._shell

        try:
            name, path = detect_shell(os.getpid())
        except (RuntimeError, ShellDetectionFailure):
            raise RuntimeError("Unable to detect the current shell.")

        cls._shell = cls(name, path)

        return cls._shell
github berdario / pew / pew / pew.py View on Github external
def _detect_shell():
    shell = os.environ.get('SHELL', None)
    if not shell:
        if 'CMDER_ROOT' in os.environ:
            shell = 'Cmder'
        elif windows:
            try:
                _, shell = shellingham.detect_shell()
            except shellingham.ShellDetectionFailure:
                shell = os.environ.get('COMSPEC', 'cmd.exe')
        else:
            shell = 'sh'
    return shell
github dephell / dephell / dephell / shells.py View on Github external
def _shell_info(self) -> Tuple[str, Path]:
        # detect by shellingham
        try:
            name, path = detect_shell()
        except (ShellDetectionFailure, RuntimeError):
            pass
        else:
            return name, Path(path)

        # detect by env
        for env in ('SHELL', 'COMSPEC'):
            path = os.environ.get(env)
            if path:
                path = Path(path).resolve()
                return path.stem, path

        # try to find any known shell
        for name in sorted(self.shells):
            path = shutil.which(name)
            if path is not None:
                return name, Path(path)

shellingham

Tool to Detect Surrounding Shell

ISC
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis

Similar packages