util.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:cb-defense-splunk-app 作者: carbonblack 项目源码 文件源码
def get_base_app_name():
    """
    Base App name, which this script belongs to.
    """
    import __main__
    main_name = __main__.__file__
    absolute_path = os.path.normpath(main_name)
    parts = absolute_path.split(os.path.sep)
    parts.reverse()
    for key in ("apps", "slave-apps", "master-apps"):
        try:
            idx = parts.index(key)
            if parts[idx + 1] == "etc":
                return parts[idx - 1]
        except (ValueError, IndexError):
            pass
    raise RestError(
        status=500,
        message='Cannot get app name from file: %s' % main_name
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号