codekingpro/portable-devtools
114k
1import importlib2import os3 4from ._core import ShellDetectionFailure5 6__version__ = "1.5.4"7 8 9def detect_shell(pid=None, max_depth=10):10 name = os.name11 try:12 impl = importlib.import_module(".{}".format(name), __name__)13 except ImportError:14 message = "Shell detection not implemented for {0!r}".format(name)15 raise RuntimeError(message)16 try:17 get_shell = impl.get_shell18 except AttributeError:19 raise RuntimeError("get_shell not implemented for {0!r}".format(name))20 shell = get_shell(pid, max_depth=max_depth)21 if shell:22 return shell23 raise ShellDetectionFailure()24 