def handr_res(): p = PackRes("res", "res-new") cmd = input("1:compress 2:uncompress\n") if cmd == 1: p.run() checkDir("res-new", "res") elif cmd == 2: p.resBackToNormal()
#encoding=utf-8 import os, re, sys from helper.respack import PackRes from myutil.utils import repalceDirName, copyFile, copyDir """ svn st | awk '{if ( $1 == "?") { print $2}}' | xargs svn add svn add --no-ignore ** """ p = PackRes("res", "res-new") def checkDir(fr, to): ls = [] for item in os.walk(fr): if not item[2]: continue for f in item[2]: if not ".DS" in f: ls.append(os.path.join(item[0], f)) for f in ls: ff = f.replace(fr, to) if not os.path.exists(ff): print "lose file ", ff def compressRes(): p.run() checkDir("res-new", "res") print "compress successfully"
def hortPack2(projectroot, dirlist, staticfilelist, f, t, store): retlist = [] for d in dirlist: dd = os.path.join(projectroot, d) if not os.path.exists(dd) or not os.path.isdir(dd): print "%s is not exits or is not a dir" % dd ret = os.popen("svn diff %s -r r%s:%s --summarize" % (dd, f, t)).readlines() for l in ret: change = l[1:].strip() if os.path.exists(change): retlist.append(change) savePath = os.path.join(projectroot, store) print "savePath = %s" % savePath for fi in retlist: if not os.path.isfile(fi) or not os.path.exists(fi): continue copyFile(fi, fi.replace(projectroot, savePath)) for fi in staticfilelist: if not os.path.exists(fi): print "can not find the staticfilelist file %s" % fi continue base_name = os.path.basename(fi) copyFile(fi, os.path.join(savePath, base_name)) # game_version_path = os.path.join(store, "game_version.json") # if os.path.exists(game_version_path): # changeGameVersion(next_version, game_version_path) # else: # print "%s is not a file"%game_version_path handle_res(store) PackRes(os.path.join(savePath, "res"), os.path.join(savePath, "res-new")).run() compilejs(os.path.join(savePath, "src"), os.path.join(savePath, "jsc_src")) z = zipfile.ZipFile(savePath + ".zip", "w") for f in retlist: ff = f.replace(projectroot, savePath) tu = os.path.splitext(ff) if tu[1] == ".js": ff = tu[0] + ".jsc" if not os.path.exists(ff): continue z.write(ff, ff.replace(savePath, "")) print "write %s to zip" % ff for f in staticfilelist: if not os.path.exists(f): continue base_name = os.path.basename(f) z.write(os.path.join(savePath, base_name), base_name) print "write %s to zip" % os.path.join(savePath, base_name) handleMainjs() copyFile("mainjs/main.jsc", os.path.join(savePath, "main.jsc")) z.write(os.path.join(savePath, "main.jsc"), "main.jsc")