malwareconfigreporter.py 文件源码

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

项目:CAPE 作者: ctxis 项目源码 文件源码
def interpreter_path(self):
        '''
        Returns the path for python interpreter, assuming it can be found. Because of various factors (inlcuding ablity to override) this may not be accurate.

        '''
        if not self.__interpreter_path:
            #first try sys.executable--this is reliable most of the time but doesn't work when python is embedded, ex. using wsgi mod for web server
            if "python" in os.path.basename(sys.executable):
                self.__interpreter_path = sys.executable
            #second try sys.prefix and common executable names
            else:
                possible_path = os.path.join(sys.prefix, "python.exe")
                if os.path.exists(possible_path):
                    self.__interpreter_path = possible_path
                possible_path = os.path.join(sys.prefix, "bin", "python")
                if os.path.exists(possible_path):
                    self.__interpreter_path = possible_path
            #other options to consider:
            #look at some library paths, such as os.__file__, use system path to find python executable that uses that library
            #use shell and let it find python. Ex. which python
        return self.__interpreter_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号