python更新游戏程序

#!/usr/bin/env python
#coding:utf-8

import os
import shutil
import zipfile

dm_path = '/data/bz-tw-and'
script_path = os.getcwd()
new_dm_dir = script_path+'/bz_new/scripts'
after_zip = '.zip'
for (root,dirs,filename) in os.walk(script_path):
    for file in filename:
        if file[-4:] == after_zip:
            zip_package = os.path.join(root,file)
            z = zipfile.ZipFile(zip_package,'r')
            z.extractall(script_path+'bz_new')
            z.close
for qu_name in os.listdir(dm_path):
    backup_dm = dm_path+'/'+qu_name+'/'+'_scripts'
    now_dm = dm_path+'/'+qu_name+'/'+'scripts'
    if os.path.exists(backup_dm):
         shutil.rmtree(backup_dm)
         os.rename(now_dm,backup_dm)
    else:
         os.rename(now_dm,backup_dm)
    shutil.copytree(new_dm_dir,now_dm)
    os.remove(now_dm+'/Config.lua')
    shutil.copyfile(dm_path+'/'+qu_name+'/Config.lua',now_dm+'/Config.lua')

猜你喜欢

转载自blog.51cto.com/yht1990/2133459
今日推荐