File size: 635 Bytes
9c6594c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import importlib
import os
from ._core import ShellDetectionFailure
__version__ = "1.5.4"
def detect_shell(pid=None, max_depth=10):
name = os.name
try:
impl = importlib.import_module(".{}".format(name), __name__)
except ImportError:
message = "Shell detection not implemented for {0!r}".format(name)
raise RuntimeError(message)
try:
get_shell = impl.get_shell
except AttributeError:
raise RuntimeError("get_shell not implemented for {0!r}".format(name))
shell = get_shell(pid, max_depth=max_depth)
if shell:
return shell
raise ShellDetectionFailure()
|