Beispiel #1
0
    def __init__(self, mode, time, version):
        # self.arg = arg
        self.mode = mode
        self.time = time
        self.inputversion = version
        self.outdir = "hot_res"
        self.src = "src"
        self.res = "res"
        self.copy = Copy()
        self.copy.createDir(self.outdir)
        self.recodepath = "%s/recode.json" % self.outdir
        self.tools = Tools()

        self.log = "%s/log.json" % self.outdir
        self.logdata = ""

        self.packversionPath = "%s/version.json" % self.outdir
        self.packversion = int(self.copy.getFileData(self.packversionPath,
                                                     "0")) + 1
        self.hotVersion = "1.0.%d" % self.packversion

        self.hotSaveDir = "%s/%s" % (self.outdir, self.hotVersion)
        self.copy.createDir(self.hotSaveDir)

        if self.mode == "init":
            self.createRecode()
        elif self.mode == "pack":
            self.getDiff()
        elif self.mode == "repack":
            self.packversion = int(self.inputversion)
            self.hotVersion = "3.0.%d" % self.packversion
            self.hotSaveDir = "%s/%s" % (self.outdir, self.hotVersion)
            self.packHotRes(self.hotSaveDir)
Beispiel #2
0
    def __init__(self):
        self.res = "res"
        self.tools = Tools()
        self.copy = Copy()
        self.packCount = 0
        self.toDir = "res_zip"
        self.MB = 1024 * 1024 * 30
        self.filterlist = [
            "effectexportjson", "font", "fonts", "gameConfig", "icon", "login",
            "music", "onlineUpdate", "particles", "shaders", "yayasdk"
        ]
        self.baselist = ["res/%s" % n for n in self.filterlist]
        print self.baselist

        self.filterFilelist = [
            "res/heroInfo_1/%s" % n for n in [
                "warning_bg.png", "common_button1_normal.png",
                "common_button1_down.png", "common_button1_disable.png",
                "common_button2_normal.png", "common_button2_down.png",
                "warning_notice_view.json"
            ]
        ]

        self.currentVersion = 1
        self.currentVersionFlag = "3.0.%d"

        self.out_zip = "out_zip"
        if os.path.exists(self.out_zip):
            shutil.rmtree(self.out_zip)
        os.makedirs(self.out_zip)

        self.baseDir = "base"
        if not os.path.exists(self.baseDir):
            os.makedirs(self.baseDir)

        if not os.path.exists(self.toDir):
            os.makedirs(self.toDir)
        else:
            if os.path.exists(self.toDir + "/res"):
                shutil.rmtree(self.toDir + "/res")

        self.currentDir = ""
        self.currentZipDir = ""
        self.currentPackSize = 0

        self.handerBase()
        # return;

        self.createZipDir()
        self.startup(self.res)
        self.packmusic()

        os.system("zip -r %s.zip %s" % (self.out_zip, self.out_zip))
Beispiel #3
0
def updateShowLabelStatus():
    global btnStatus, showLabel, btnStatuslist

    if showLabel == '0':
        showLabel = '1'
    else:
        showLabel = '0'

    btnStatus['text'] = btnStatuslist[showLabel]

    copy.saveDataToFile('python/androidMode.txt', showLabel)
    xmlPath = 'frameworks/runtime-src/proj.android/AndroidManifest.xml'
    f = open(xmlPath, 'rb')
    data = f.read()
    f.close()
    if showLabel == '1':
        replace_re = re.compile('希望之光.*?\"')
        data = replace_re.sub('希望之光\"', data)
        # data = data.replace('希望之光_.+?\"','希望之光\"')
    elif showLabel == '0':
        str = '希望之光_' + Copy().getFileData('python/log.txt').split(
            '_')[0] + '\"'
        replace_re = re.compile('希望之光.*?\"')
        data = replace_re.sub(str, data)

        # data = data.replace('希望之光.*?$',str)

    f = open(xmlPath, 'wb')
    f.write(data)
    f.close()
Beispiel #4
0
def removeAssetsFoIJM():
    ijmfiles = ['main.js', 'platform.json']
    assetsRoot = toBaseDir + 'assets/'
    copy = Copy()
    if not os.path.exists(assetsRoot):
        print "找不到文件夹%s" % assetsRoot

    for item in os.walk(assetsRoot):
        if not item[2]:
            continue

        for file in item[2]:
            if os.path.splitext(file)[-1] == ".DS_Store":
                print "svn file"
                continue

            fileRoot = os.path.join(item[0], file)
            relativePath = fileRoot.replace(assetsRoot, '')
            if relativePath in ijmfiles:
                print "get file %s" % relativePath
                toPath = fileRoot.replace('/assets/', '/assets_backup/')
                copy.copyFile(fileRoot, toPath)
                copy.removeFile(fileRoot)

    print "操作结束"
Beispiel #5
0
class Icon:
    """docstring for Icon"""
    def __init__(self):
        self.copy = Copy()
        self.main = '/Users/osx/Downloads/out/'
        self.mainback = '/Users/osx/Documents/maple/projects/冒险大乱斗/newHope/frameworks/runtime-src/'

    """
    将下载的out文件删除
    """    
    def removeoutdir(self):
        self.copy.removeDir(self.main)

    def start(self,p,p_n=''):
        print "start to copy icons"
        if p == "android":
            self.root =  self.main + 'android/'
            self.backRoot =  self.mainback + 'proj.android/platform/'
        elif p == "ios":
            self.root = self.main +  'ios/'
            self.backRoot = self.mainback + 'proj.ios_mac/ios/'
        else:
            raise("平台参数错误")     

        filterList = ['.DS_Store']    
        print os.listdir(self.root)    
        for searchDir in os.listdir(self.root):
            if searchDir in filterList or (not p_n == '' and not p_n == searchDir):
                print "filter dir %s"%searchDir
                continue


            print "dir = ",searchDir 
            if os.path.exists(self.backRoot + searchDir):
                print self.root + searchDir, " =============> ", self.backRoot + searchDir + '/res'
                self.copy.copyFiles(self.root + searchDir,self.backRoot + searchDir + '/res') 
                self.copy.removeDir(self.backRoot + searchDir + '/res/max')
            else:
                print "dir %s can't be find......."%(self.backRoot + searchDir)           
        
        self.removeoutdir()
Beispiel #6
0
 def __init__(self):
     self.copy = Copy()
     self.main = '/Users/osx/Downloads/out/'
     self.mainback = '/Users/osx/Documents/maple/projects/冒险大乱斗/newHope/frameworks/runtime-src/'
Beispiel #7
0
class SVN():
    """docstring for SVN"""
    def __init__(self, mode, time, version):
        # self.arg = arg
        self.mode = mode
        self.time = time
        self.inputversion = version
        self.outdir = "hot_res"
        self.src = "src"
        self.res = "res"
        self.copy = Copy()
        self.copy.createDir(self.outdir)
        self.recodepath = "%s/recode.json" % self.outdir
        self.tools = Tools()

        self.log = "%s/log.json" % self.outdir
        self.logdata = ""

        self.packversionPath = "%s/version.json" % self.outdir
        self.packversion = int(self.copy.getFileData(self.packversionPath,
                                                     "0")) + 1
        self.hotVersion = "1.0.%d" % self.packversion

        self.hotSaveDir = "%s/%s" % (self.outdir, self.hotVersion)
        self.copy.createDir(self.hotSaveDir)

        if self.mode == "init":
            self.createRecode()
        elif self.mode == "pack":
            self.getDiff()
        elif self.mode == "repack":
            self.packversion = int(self.inputversion)
            self.hotVersion = "3.0.%d" % self.packversion
            self.hotSaveDir = "%s/%s" % (self.outdir, self.hotVersion)
            self.packHotRes(self.hotSaveDir)

    def saveRecode(self):
        f = open(self.recodepath, "w")
        json.dump(self.recodedata, f)
        f.close()

    def getDiff(self):

        f = open(self.recodepath, "r")
        self.recodedata = json.load(f)
        f.close()

        self.getDiffSignalDir(self.res)
        self.getDiffSignalDir(self.src)
        self.saveRecode()

        f = open(self.log, "w")
        f.write(self.logdata)
        f.close()

        self.packHotRes(self.hotSaveDir)

    def getDiffSignalDir(self, dir):
        for item in os.walk(dir):
            if not item[2]:
                continue
            for f in item[2]:
                file = os.path.join(item[0], f)
                t = os.path.getmtime(file)
                oldTime = 0
                if file in self.recodedata:
                    oldTime = self.recodedata[file]
                """
					check weather mofidy file or not 
				"""
                checknow = self.time == 0.0 and t > oldTime
                timesperate = time.time() - self.time * 3600
                checktime = self.time > 0.0 and t > timesperate
                """
					有两种比对 
					1.如果输入的时间是now那么只比对当前文件的个性时间和记录的时间差值大于0 认不文件是修改过的
					2.如果输入时间(以小时为单位)则计算当前时间前n个小时内有修改过的文件
				"""
                if checknow or checktime:
                    self.recodedata[file] = t
                    self.copy.copyFile(file, "%s/%s" % (self.hotSaveDir, file))
                    self.logdata = self.logdata + file + "\n"

    def packHotRes(self, versionDir):
        res = "%s/res" % versionDir
        src = "%s/src" % versionDir
        if not os.path.exists(res) and not os.path.exists(src):
            print "no res need zip %s %s" % (res, src)
            sys.exit()

        self.tools.jscompile("%s/src" % versionDir)
        zf = zipfile.ZipFile("%s/%d.zip" % (self.outdir, self.packversion),
                             "w", zipfile.zlib.DEFLATED)

        def zipDir(dir):
            for item in os.walk(dir):
                if not item[2]:
                    continue
                for f in item[2]:
                    file = os.path.join(item[0], f)
                    name = file[len(versionDir):]
                    # name = file
                    zf.write(file, name)

        zipDir(res)
        zipDir(src)

        vf = "%s/game_version.json" % self.outdir
        f = open(vf, "w")
        json.dump({"version": self.hotVersion}, f)
        f.close()
        zf.write(vf, "game_version.json")

        self.copy.saveDataToFile(self.packversionPath, str(self.packversion))

    def createRecode(self):
        f = open(self.recodepath, "w")
        self.recodedata = {}
        si = self.tools.getdirsize(self.res)
        maxSize = 1024 * 1024 * 400
        if not si > maxSize:
            self.createRecodeSignalDir(self.res)
        else:
            self.tools.alert("请先压缩资源在操作")
            return
        if os.path.exists("%s/resource.js" % self.src):
            self.createRecodeSignalDir(self.src)
        else:
            self.tools.alert("请记录JS而不是JSC")
            return
        json.dump(self.recodedata, f, indent=2)
        f.close()

    def createRecodeSignalDir(self, dir):

        for item in os.walk(dir):
            if not item[2]:
                continue

            for f in item[2]:
                file = os.path.join(item[0], f)
                t = os.path.getmtime(file)
                self.recodedata[file] = t
Beispiel #8
0
class Handler():
    def __init__(self):
        self.res = "res"
        self.tools = Tools()
        self.copy = Copy()
        self.packCount = 0
        self.toDir = "res_zip"
        self.MB = 1024 * 1024 * 30
        self.filterlist = [
            "effectexportjson", "font", "fonts", "gameConfig", "icon", "login",
            "music", "onlineUpdate", "particles", "shaders", "yayasdk"
        ]
        self.baselist = ["res/%s" % n for n in self.filterlist]
        print self.baselist

        self.filterFilelist = [
            "res/heroInfo_1/%s" % n for n in [
                "warning_bg.png", "common_button1_normal.png",
                "common_button1_down.png", "common_button1_disable.png",
                "common_button2_normal.png", "common_button2_down.png",
                "warning_notice_view.json"
            ]
        ]

        self.currentVersion = 1
        self.currentVersionFlag = "3.0.%d"

        self.out_zip = "out_zip"
        if os.path.exists(self.out_zip):
            shutil.rmtree(self.out_zip)
        os.makedirs(self.out_zip)

        self.baseDir = "base"
        if not os.path.exists(self.baseDir):
            os.makedirs(self.baseDir)

        if not os.path.exists(self.toDir):
            os.makedirs(self.toDir)
        else:
            if os.path.exists(self.toDir + "/res"):
                shutil.rmtree(self.toDir + "/res")

        self.currentDir = ""
        self.currentZipDir = ""
        self.currentPackSize = 0

        self.handerBase()
        # return;

        self.createZipDir()
        self.startup(self.res)
        self.packmusic()

        os.system("zip -r %s.zip %s" % (self.out_zip, self.out_zip))

    def packmusic(self):
        to = "%s/res/music/android" % self.toDir
        if not os.path.exists(to):
            os.makedirs(to)
        self.copy.copyFiles("music/android", to)
        self.handlerVersion()
        self.zipCurerntPack()

    def handlerVersion(self):
        d = {"version": self.currentVersionFlag % self.currentVersion}
        json.dump(d, open("%s/game_version.json" % self.toDir, "w"))
        self.currentVersion = self.currentVersion + 1

    def handerBase(self):
        for _dir in self.baselist:
            to = self.baseDir + "/" + _dir
            self.copy.copyFiles(_dir, to)

        for file in self.filterFilelist:
            to = self.baseDir + "/" + file
            self.copy.copyFile(file, to)

    def startup(self, dir):

        for item in os.walk(dir):
            if not item[2]:
                continue

            rootbaseList = item[0].split("/")
            l = len(rootbaseList)
            if l > 1 and rootbaseList[1] in self.filterlist:
                print "filter dir %s" % rootbaseList[1]
                continue

            for file in item[2]:
                fromFile = os.path.join(item[0], file)
                if fromFile in self.filterFilelist:
                    print("file %s in base so filter" % fromFile)
                    continue
                toFile = fromFile.replace(self.res, self.currentDir, 1)
                self.currentPackSize = self.currentPackSize + os.path.getsize(
                    fromFile)
                self.copy.copyFile(fromFile, toFile)
                self.checkDir()

        # self.handlerVersion()
        # self.zipCurerntPack()
        self.checkDir(ingore=True)

    def zipCurerntPack(self):
        c = os.getcwd()
        # os.chdir(self.toDir)
        # os.system("zip -r %s/%s_%d.zip %s"%(self.out_zip,self.res,self.packCount,self.toDir))
        # os.chdir(c)

        zf = zipfile.ZipFile("%s/%d.zip" % (self.out_zip, self.packCount), "w",
                             zipfile.zlib.DEFLATED)
        for item in os.walk(self.toDir):
            if not item[2]:
                continue
            for file in item[2]:
                _file = os.path.join(item[0], file)
                _name = _file[len(self.toDir):]
                zf.write(_file, _name)
        shutil.rmtree(self.currentDir)

    def createZipDir(self):
        self.currentDir = "%s/res" % (self.toDir)

        if not os.path.exists(self.currentDir):
            os.makedirs(self.currentDir)

        self.packCount = self.packCount + 1
        self.currentPackSize = 0

    def checkDir(self, ingore=False):
        if ingore or self.currentPackSize > self.MB:
            self.handlerVersion()
            self.zipCurerntPack()
            self.createZipDir()
Beispiel #9
0
def useIJMAssets():
    ret = readAssetsType()
    # if ret == "ijm":
    #     saySome("当前已经是ijm资源了")
    #     return
    ijmRoot = toBaseDir + "ijm_assets/"
    copy = Copy()

    projectAssetsRoot = toBaseDir + "assets/"
    """ copy so  """
    copy.copyFile(ijmRoot + "lib/armeabi/libccgamec.so",
                  toBaseDir + "libs/armeabi/libccgamec.so")
    copy.copyFile(ijmRoot + "lib/armeabi/libccgamec.so",
                  toBaseDir + "base/libs/armeabi/libccgamec.so")
    """ copy assets """
    item = 0
    ijmAssets = ijmRoot + "assets/"
    for o in os.walk(ijmAssets):
        item = o
        break

    print item[1]

    for file in item[2]:
        copy.copyFile(ijmAssets + file, projectAssetsRoot + file)
        copy.copyFile(ijmAssets + file, toBaseDir + "base/assets/" + file)

    for d in item[1]:
        print "使用爱加密处理过的文件夹  %s" % d
        copy.removeDir(projectAssetsRoot + d)
        copy.copyDir(ijmAssets + d, projectAssetsRoot + d, showProgress=True)

    print "已经使用了爱加密处理过的资源了"
    alert("已经使用了爱加密处理过的资源了")
    recodeAssetsType("ijm")
Beispiel #10
0
"""   推送名字  """
pushPlatformCode = 0
pushPlatform = "null"
"""   平台名字  """
platform = ""
platformCode = 0
"""   功能操作模式  """
operationCode = 2

compentWidth = 30

btnDict = {}

selectList = []

copy = Copy()
top = Tkinter.Tk()
top.wm_title('希望之光android平台')

# def getNum(num,max,default):
#     if num > max:
#         return default
#     return num

logPath = 'python/log.txt'

jsonString = copy.getFileData("python/platform.txt")
jsonDic = json.loads(jsonString)
nameMap = jsonDic['code']

showLabel = '0'