def _if_not_python_lib(library):
    def argcatcher(func):
        functools.wraps(func)

        def decorator(*args, **kwargs):
            with settings(warn_only=True):
                errcount = int(env.safe_run_output("%s -c 'import %s' 2>&1 | grep -c ImportError | cat" % (_python_cmd(env), library)))
                result = 0 if errcount >= 1 else 1
            if result == 0:
                return func(*args, **kwargs)
            else:
                return result
        return decorator
    return argcatcher
Decorator that checks if a python library is installed.
dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/custom/shared.py/_if_not_python_lib