美文网首页
python调用其他目录的python文件

python调用其他目录的python文件

作者: 一剑卿心 | 来源:发表于2019-11-01 20:28 被阅读0次
    #test.py
    
    ATLAS_PROCESS_PATH = "../../../../../Resources/GenerateAtlas.py"
    
    def getScriptPath():
        return os.path.dirname(os.path.realpath(sys.argv[0]))
    
    def callCmd(cmd):
        sys.stdout.flush()
        process = subprocess.Popen(cmd, shell = True)
        retCode = process.wait()
        sys.stdout.flush()
    
        return retCode
    
    def main():
        # 1.Call Generate atlas config.
        print("--Generate atlases config Start.")
    
        cmdList = ["python"]
        cmdPath = os.path.normpath(os.path.join(getScriptPath(), ATLAS_PROCESS_PATH))
        cmdList.append(cmdPath)
        if len(sys.argv) > 1:
            cmdList.append("-1")
            for i in range(1, len(sys.argv)):
                cmdList.append(sys.argv[i])
    
        retCode = callCmd(" ".join(cmdList))
        if retCode != 0:
            print("ERROR:Generate atlases list failed")
    
        print("--Generate atlases config End.")
    
        time.sleep(3)
    
    

    相关文章

      网友评论

          本文标题:python调用其他目录的python文件

          本文链接:https://www.haomeiwen.com/subject/akpqbctx.html