custom.py 文件源码

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

项目:AlphaGSM 作者: SectorAlpha 项目源码 文件源码
def install(server,*,eula=False):
    if not os.path.isdir(server.data["dir"]):
        os.makedirs(server.data["dir"])
    mcjar=os.path.join(server.data["dir"],server.data["exe_name"])
    if not os.path.isfile(mcjar):
        raise ServerError("Can't find server jar ({}). Please place the files in the directory and/or update the 'exe_name' then run setup again".format(mcjar))
    server.data.save()

    eulafile=os.path.join(server.data["dir"],"eula.txt")
    configfile=os.path.join(server.data["dir"],"server.properties")
    if not os.path.isfile(configfile) or (eula and not os.path.isfile(eulafile)): # use as flag for has the server created it's files
        print("Starting server to create settings")
        try:
            ret=sp.check_call(["java","-jar",server.data["exe_name"],"nogui"],cwd=server.data["dir"],shell=False,timeout=20)
        except sp.CalledProcessError as ex:
            print("Error running server. Java returned status: "+ex.returncode)
        except sp.TimeoutExpired as ex:
            print("Error running server. Process didn't complete in time")
    updateconfig(configfile,{"server-port":str(server.data["port"])})
    if eula:
        updateconfig(eulafile,{"eula":"true"})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号