def s3_check_python_lib(global_mandatory, template_mandatory, template_optional, global_optional):
    """
        checks for optional as well as mandatory python libraries
    """

    errors = []
    warnings = []

    for dependency, err in global_mandatory.iteritems():
        try:
            if "from" in dependency:
                exec dependency
            else:
                exec "import %s" % dependency
        except ImportError:
            if err:
                errors.append(err)
            else:
                errors.append("S3 unresolved dependency: %s required for Sahana to run" % dependency)

    for dependency, err in template_mandatory.iteritems():
        try:
            if "from" in dependency:
                exec dependency
            else:
                exec "import %s" % dependency
        except ImportError:
            if err:
                errors.append(err)
            else:
                errors.append("Unresolved template dependency: %s required" % dependency)

    for dependency, warn in template_optional.iteritems():
        try:
            if "from" in dependency:
                exec dependency
            else:
                exec "import %s" % dependency
        except ImportError:
            if warn:
                warnings.append(warn)
            else:
                warnings.append("Unresolved optional dependency: %s required" % dependency)

    for dependency, warn in global_optional.iteritems():
        try:
            if "from" in dependency:
                exec dependency
            else:
                exec "import %s" % dependency
        except __HOLE__:
            if warn:
                warnings.append(warn)
            else:
                warnings.append("Unresolved optional dependency: %s required" % dependency)

    return errors, warnings

# END =========================================================================
dataset/ETHPy150Open sahana/eden/modules/s3_update_check.py/s3_check_python_lib