Esempio n. 1
0
    def recreateJsFileAndBackUp(self, folderName_: str):
        # 目标文件
        _targetJSPath = fileUtils.getPath(self._assetsFolderPath, folderName_)
        # 上层路径
        _targetParentPath = fileUtils.getPath(self._assetsFolderPath,
                                              folderName_ + "/..")
        # 备份路径
        _backUpPath = os.path.join(_targetParentPath,
                                   os.path.basename(_targetJSPath) + "_backUp")

        # 有备份
        if os.path.exists(_backUpPath):
            # 没有源,有可能删了。【代码执行错误的时候,会删除源,因为,源会变】
            if not os.path.exists(_targetJSPath):
                # 将备份 同步给 源
                shutil.copytree(_backUpPath, _targetJSPath)
                print("备份文件,拷贝回源路径")
            # 源里没有 创建备份的标示。
            if not os.path.isfile(_targetJSPath + '/backup_created'):
                # 删除 原有备份
                folderUtils.removeTree(_backUpPath)
                # 新备份
                shutil.copytree(_targetJSPath, _backUpPath)
                # 标记已经备份过了
                fileUtils.writeFileWithStr(_targetJSPath + '/backup_created',
                                           'backup end')
            else:
                print("已经创建过备份了")
        else:
            # 没备份文件 - 就备份一份
            shutil.copytree(_targetJSPath, _backUpPath)
            # 标记已经备份过了
            fileUtils.writeFileWithStr(_targetJSPath + '/backup_created',
                                       'backup end')
Esempio n. 2
0
def decompileApk(apkPath_, decompileTo_):
    cmdLogUtils.log("反编译 apk")
    folderUtils.makeSureDirIsExists(decompileTo_)
    if os.path.exists(decompileTo_):
        folderUtils.removeTree(decompileTo_)
    # 清理缓存的 framework ,确保 apktool 和 释放出的 framework 的一致性
    os.system("apktool empty-framework-dir")
    os.system("apktool d %s -o %s" % (apkPath_, decompileTo_))
Esempio n. 3
0
def removeNouseFolder(parentFolder_):
    _fodlerPathList = utils.folderUtils.getFolderListJustOneDepth(
        parentFolder_)
    for _i in range(len(_fodlerPathList)):
        _folderName = _fodlerPathList[_i]
        if _folderName.find("专区") < 0:
            _folderPath = os.path.join(parentFolder_, _folderName)
            print('_folderPath = ' + str(_folderPath))
            folderUtils.removeTree(_folderPath)
Esempio n. 4
0
 def __init__(
         self,
         modificationFolder_: str,  # 变更Unity后,打的新包
         finalProjectFolder_: str  # 谁复制到哪里后,在应用修改
 ):
     # assets 相对路径 Unity 2019
     _assetsPath = "unityLibrary/src/main/assets"
     _finalProjectAssetsPath = finalProjectFolder_ + _assetsPath
     _modificationFolderAssetsPath = modificationFolder_ + _assetsPath
     # 将 Assets 替换成新的
     if os.path.exists(_finalProjectAssetsPath):
         folderUtils.removeTree(_finalProjectAssetsPath)
     shutil.copytree(_modificationFolderAssetsPath, _finalProjectAssetsPath)
Esempio n. 5
0
def analyseCSharpAndCreateUML(csFolderPath_: str, pumlFolderPath_: str,
                              umlFolderPath_: str, plantUMLJar_: str):
    # 如果存在已经生成的puml文件,删除掉。
    if os.path.exists(pumlFolderPath_):
        folderUtils.removeTree(pumlFolderPath_)
    # 打印文件结构
    folderUtils.showFileStructureReg(csFolderPath_, [".*\.cs$"])
    # 将 cs 解析生成 puml
    createPuml(csFolderPath_, pumlFolderPath_)
    # 使用 puml 的 include.puml 生成 uml 图。
    createUML(plantUMLJar_, os.path.join(pumlFolderPath_, "include.puml"),
              umlFolderPath_)
    # 为每一个文件夹生成相应的 uml 图
    createIncludePuml(pumlFolderPath_, umlFolderPath_, plantUMLJar_)
Esempio n. 6
0
    def __init__(self,
                 modificationToolPath_: str,  # 工程修改器路径
                 sourceProjectFolder_: str,  # 修改前
                 modificationFolder_: str,  # 修改后
                 modificationJsonFolder_: str,  # 修改前后配置JSON生成到哪里
                 templateProjectFolder_: str,  # 将配置引用给谁
                 finalProjectFolder_: str  # 谁复制到哪里后,在应用修改
                 ):
        print("1 - compare projects : ")
        # 对比变更
        _modificationJsonPath = self.getModificationJson(
            modificationToolPath_,
            sourceProjectFolder_,
            modificationFolder_,
            modificationJsonFolder_
        )
        print("    diff json : " + _modificationJsonPath)

        # 重新生成最终工程
        print("2 - create new finalProjectFolder : ")
        if os.path.exists(finalProjectFolder_):
            print("    remove : " + finalProjectFolder_)
            folderUtils.removeTree(finalProjectFolder_)
        print("    copy : " + templateProjectFolder_ + " -> " + finalProjectFolder_)
        shutil.copytree(templateProjectFolder_, finalProjectFolder_)

        # 将 Class、Libraries、Data 拷贝到 最终文件夹
        print("3 - operate finalProjectFolder : ")
        print("    reset Classes")
        if os.path.exists(finalProjectFolder_ + "/Classes"):
            folderUtils.removeTree(finalProjectFolder_ + "/Classes")
        shutil.copytree(modificationFolder_ + "/Classes", finalProjectFolder_ + "/Classes")

        print("    reset Libraries")
        if os.path.exists(finalProjectFolder_ + "/Libraries"):
            folderUtils.removeTree(finalProjectFolder_ + "/Libraries")
        shutil.copytree(modificationFolder_ + "/Libraries", finalProjectFolder_ + "/Libraries")

        print("    reset Data")
        if os.path.exists(finalProjectFolder_ + "/Data"):
            folderUtils.removeTree(finalProjectFolder_ + "/Data")
        shutil.copytree(modificationFolder_ + "/Data", finalProjectFolder_ + "/Data")

        print("4 - modificate finalProjectFolder : ")
        # 将对比引用于最终工程
        self.applyModificationJson(
            modificationToolPath_,
            finalProjectFolder_,
            modificationJsonFolder_,
            _modificationJsonPath
        )
        print("5 - SUCCESS")
        print("    --------------------")
        print("6 - DIY Step")
        # Libraries 中 Plugins 还有 ThridParty 要再贴回去
        print("    reset Libraries/Plugins")
        shutil.copytree(templateProjectFolder_ + "/Libraries/Plugins", finalProjectFolder_ + "/Libraries/Plugins")
        print("    reset Libraries/ThridParty")
        shutil.copytree(templateProjectFolder_ + "/Libraries/ThridParty", finalProjectFolder_ + "/Libraries/ThridParty")
Esempio n. 7
0
 def BackupCodesAndPngs(self, dParameters_):
     _projectFolderPath = sysUtils.folderPathFixEnd(dParameters_["projectFolder"])
     _projectName = dParameters_["projectName"]
     _airAndPyPathList = folderUtils.getFilterFilesInPath(_projectFolderPath, [".air", ".py"])
     # 匹配 r"tpl1606022416813.png" 这样的内容
     _groupReg = r"r\"(.*)\.png\""
     # 要拷贝的png文件名
     _pngPathList = []
     for _i in range(len(_airAndPyPathList)):
         _airAndPyPath = _airAndPyPathList[_i]
         _matchGroupList = regUtils.getMatchGroupStrList(_airAndPyPath, _groupReg)  # 得到匹配的group阵列
         for _j in range(len(_matchGroupList)):
             _pngNameWithOutSuffix = _matchGroupList[_j][0]
             _pngPath = _projectFolderPath + "/" + _pngNameWithOutSuffix + ".png"
             if not _pngPath in _pngPathList:  # 没有记录过,就记录
                 _pngPathList.append(_pngPath)
     _tempPicsFolderPath = _projectFolderPath + "tempPics/"
     print("    拷贝代码实际使用图片到临时目录 : " + _tempPicsFolderPath)
     fileCopyUtils.copyFilesToFolder(_pngPathList, _tempPicsFolderPath)
     _backupProjectFolderPath = str(Path(self.subResPath + "/" + _projectName))  # 在资源文件内备份
     print('    备份位置 : ' + str(_backupProjectFolderPath))
     folderUtils.makeSureDirIsExists(_backupProjectFolderPath)
     print('    备份代码')
     fileCopyUtils.copyFilesInFolderTo(
         [".py", ".air"],
         _projectFolderPath,
         _backupProjectFolderPath,
         "include"
     )
     print('    备份图片')
     fileCopyUtils.copyFilesInFolderTo(
         [".png"],
         _tempPicsFolderPath,
         _backupProjectFolderPath,
         "include"
     )
     print('    删除临时目录')
     folderUtils.removeTree(_tempPicsFolderPath)
Esempio n. 8
0
    # _key             = _opsDict["key"]
    # _targetApkFolder = _opsDict["targetApkFolder"]
    # _targetApkName   = _opsDict["targetApkName"]

    # 获取参数
    _baseFolder = "/Volumes/18604037792/develop/TuYoo/GIT/MJ/APKRebuild/"
    _sourceApkPath = _baseFolder + "yy.apk"
    _decompileTo = _baseFolder + "deapk/"
    _keyStorePath = _baseFolder + "android.keystore"
    _keyPassword = "******"
    _key = "android.keystore"
    _targetApkFolder = _baseFolder + "outputs/"
    _targetApkName = "newApk.apk"

    # 反编译
    decompileApk(_sourceApkPath, _decompileTo)

    # apk 内的热更路径
    _hotFixFolderPath = _baseFolder + "deapk/assets/MJ_Android/"
    if os.path.exists(_hotFixFolderPath):
        folderUtils.removeTree(_hotFixFolderPath)

    # Unity 重新构建AB包,然后拷贝进去
    shutil.copytree(
        "/Volumes/18604037792/develop/TuYoo/GIT/MJ/majiang3d_super/Assets/StreamingAssets/MJ_Android",
        _hotFixFolderPath)

    # 编译回去
    recompileApk(_decompileTo, _keyStorePath, _keyPassword, _key,
                 _targetApkFolder, _targetApkName)
Esempio n. 9
0
    # 目标文件夹
    _removeTargetFolderPath = "farmRemote2/" + _publicType + "/" + _targetVersion

    # 认证信息
    access_key_id = os.getenv('OSS_TEST_ACCESS_KEY_ID', 'OSS_ID')
    access_key_secret = os.getenv('OSS_TEST_ACCESS_KEY_SECRET', 'OSS_Secret')
    # 目标位置
    endpoint = os.getenv('OSS_TEST_ENDPOINT', 'http://oss-cn-beijing.aliyuncs.com')
    syFarmBucketName = "公司-项目"

    # 统计文件夹下文件个数
    fileNeedToUpdate = 0
    for _root, _dirs, _files in os.walk(_resFolderPath):  # 遍历统计
        for _file in _files:
            fileNeedToUpdate = fileNeedToUpdate + 1
    print("上传本地res文件夹内容到oss -----------------------------------> " + str(fileNeedToUpdate) + " 个文件")

    # 上传OSS
    bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name=syFarmBucketName)

    try:
        uploadDir(_resFolderPath, _resFolderPath, bucket, _removeTargetFolderPath)
    except IOError:
        print("OSS 上传中断")
        sys.exit(1)

    # 拥有全部权限,然后删除
    print("上传本地res文件夹内容到oss <----------------------------------- 删除本地res")
    folderUtils.removeTree(_resFolderPath)
Esempio n. 10
0
    _miniClientJsonDict = dictFromJsonFile(str(_weChatGameConfigJsonPath))
    # 获取构建之后的目录
    _buildFolderPath = Path(str(_projectFolderPath) + "/build/")
    _buildBackFolderPath = Path(str(_projectFolderPath) + "/buildBack/")

    # 获取构建之后的res目录
    _resFolderPath = Path(str(_buildFolderPath) + "/wechatgame/res/")

    # 备份build  -------------------------------------------------------------------------------------------------
    # 判断当前的build 是否脚本发布生成的。如果是备份,如果不是删除,创建新的
    for _name in os.listdir(str(_buildFolderPath)):
        if _name.find("test_") == 0 or _name.find("ver_") == 0:
            shutil.copytree(str(_buildFolderPath), str(_buildBackFolderPath) + "/" + _name.split(".zip")[0])
            print("buildBack文件夹内创建 " + _name.split(".zip")[0] + " 备份")
            break;
    folderUtils.removeTree(str(_buildFolderPath))
    print("清空 原有 build")
    os.mkdir(str(_buildFolderPath))

    # 获取Git链接 -------------------------------------------------------------------------------------------------
    _repo = Repo.init(_projectFolderPath)

    # 获取当前满足版本格式的Tag中最大的tag号
    _tagStrList = [str(_tagName) for _tagName in _repo.tags if isVersionStr(str(_tagName))]
    _tagStrList = sorted(_tagStrList, key=functools.cmp_to_key(versionCompare), reverse=True)
    # 记录版本号
    _biggestTar = _tagStrList[0]
    print("当前最大 TAG : " + _biggestTar)

    # 只保留最大的10个tag号。
    for _i in range(9,len(_tagStrList)):
Esempio n. 11
0
 def DeleteFolder(self, dParameters_):
     _deleteFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["deleteFolderPath"])
     self.checkDeleteFolder(_deleteFolderPath)
     folderUtils.removeTree(str(_deleteFolderPath))
Esempio n. 12
0
            _tempDatetime = strToDatetime(_endDay + " 12:00:00")
            _tempDatetimeYestoday = getDayFromTargetDay(_tempDatetime, -1)
            _tempDay = _tempDatetimeYestoday.split(" ")[0]
            _fileSubPath = _tempDay + "/" + _beginTime.split(
                ":")[0] + "_" + _endTime.split(":")[0]
        else:
            _fileSubPath = _endDay + "/" + _beginTime.split(
                ":")[0] + "_" + _endTime.split(":")[0]

        _filePath = _tempFilePath + "/" + _which + "/" + _fileSubPath
        print("正在写入临时文件 : " + _filePath)
        # 写入文件
        writeFileWithStr(_filePath,
                         _outputStr.encode('UTF-8', 'ignore').decode('UTF-8'))
    # 生成的文件列表
    _filePathList = getFilterFilesInPath(_tempFilePath + "/" + _which + "/")

    print("正在建立 HDFS 客户端")
    # 链接hdfs 将临时文件拷贝到 目标路径,那个用户执行这个脚本,就是哪个用户
    _client = getClient(_hdfsUrl, None)
    for _filePath in _filePathList:
        _fileSubPath = _filePath.split(_tempFilePath)[1]
        _hdfsTargetFilePath = _hdfsTargetFolder + _fileSubPath
        print("正在将临时文件拷贝到 hdfs 中 : " + _hdfsTargetFilePath)
        # 覆盖掉原有的文件 overwrite
        _client.copy_from_local(_filePath, _hdfsTargetFilePath, overwrite=True)

    print("正在删除临时文件 : " + _tempFilePath + "/" + _which + "/")
    # 删除临时文件
    folderUtils.removeTree(_tempFilePath + "/" + _which + "/")