RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
python更新游戏程序
#!/usr/bin/env python
#coding:utf-8

import os
import re
import sys
import shutil
import zipfile
import datetime

time = datetime.datetime.now()
folderName = time.strftime("%Y%m%d%H%M")
dm_path = '/data/bz-tw-and/'
package_path = '/data/update/bz_new/'
after_zip = '.zip'
package_name = ''
temp = 'temp/'

def update():
    num = []
    for filename in os.listdir(package_path):
        if filename[-4:] == after_zip:
            z = zipfile.ZipFile(package_path+filename,'r')
            z.extractall(package_path)
            z.close
    for qu_name in os.listdir(dm_path):
        if re.match('s\d+',qu_name):
            backup_dm = dm_path+qu_name+'/_scripts'
            now_dm = dm_path+qu_name+'/scripts'
            if os.path.exists(backup_dm) and os.path.exists(now_dm):
                 shutil.rmtree(backup_dm)
                 os.rename(now_dm,backup_dm)
            else:
                 if os.path.exists(now_dm):
                     os.rename(now_dm,backup_dm)
            shutil.copytree(package_path+ 'scripts',now_dm)
            os.remove(now_dm+'/Config.lua')
            shutil.copyfile(dm_path + qu_name+'/Config.lua',now_dm+'/Config.lua')
            num.append(qu_name[1:])
    num = list(map(int,num))
    num = sorted(num)
    for name in num:
        print('\033[31ms%s\033[0m已经更新完成...'% name)
    if not os.path.exists(package_path+temp):
        os.mkdir(package_path+temp)
    os.mkdir(package_path+temp+folderName)
    for filename in os.listdir(package_path):
        if filename != 'temp':
            shutil.move(package_path +filename,package_path + temp + folderName)
update()

网页标题:python更新游戏程序
转载来源:http://lswzjz.com/article/jpchoe.html