Пример #1
0
    def SFTP(self, dParameters_: dict):
        # 本地路径 和 上传路径
        _localFolderPath = sysUtils.folderPathFixEnd(dParameters_["localFolderPath"])
        _upToFolderPath = sysUtils.folderPathFixEnd(dParameters_["upToFolderPath"])

        # 传送对象
        _transport = paramiko.Transport(
            (dParameters_["ip"], int(dParameters_["port"]))  # 这个括号不能拆
        )

        # 链接
        _transport.connect(
            username=dParameters_["username"],
            pkey=paramiko.RSAKey.from_private_key_file(dParameters_["pKeyFilePath"])
        )
        # 创建sftp
        _sftp = paramiko.SFTPClient.from_transport(_transport)

        # 遍历本地路径,获取文件列表
        _filePathList = folderUtils.getFileListInFolder(
            _localFolderPath,
            dParameters_["filters"]
        )
        # 依次发送到FTP
        for _idx in range(len(_filePathList)):
            _filePath = _filePathList[_idx]
            _upToFilePath = fileUtils.getNewNameKeepFolderStructure(
                _localFolderPath, _upToFolderPath, _filePath
            )
            _sftp.put(_filePath, _upToFilePath, confirm=True)
            print(_filePath + " -> " + _upToFilePath)
Пример #2
0
 def syncLogUtils(self, luaRootPath_: str):
     _logUtilsFilePath = sysUtils.folderPathFixEnd(
         self.resPath) + "LogUtils.lua"
     _targetLogUtilsFilePath = sysUtils.folderPathFixEnd(
         luaRootPath_) + "LogUtils.lua"
     # 没有日志文件就拷贝过去
     if not os.path.exists(_targetLogUtilsFilePath):
         shutil.copy(_logUtilsFilePath, _targetLogUtilsFilePath)
Пример #3
0
 def Replace(self, dParameters_: dict):
     _sourceFolderPath = sysUtils.folderPathFixEnd(dParameters_["sourceFolder"])
     _targetFolderPath = sysUtils.folderPathFixEnd(dParameters_["targetFolder"])
     _filters = dParameters_["filters"]  # 过滤项
     _filePathDict = folderUtils.getFilePathKeyValue(_sourceFolderPath, _filters)
     for _, _filePath in _filePathDict.items():  # 存在文件,才拷贝
         _shortPath = _filePath.split(_sourceFolderPath)[1]
         _tarfilePath = _targetFolderPath + _shortPath
         _sourcefilePath = _sourceFolderPath + _shortPath
         if os.path.exists(_tarfilePath):
             print('        copy to : ' + str(_tarfilePath))
             shutil.copy(_sourcefilePath, _tarfilePath)
         else:
             print('x-      pass : ' + str(_sourcefilePath))
Пример #4
0
 def changeGameJson(self, buildFolderPath_: str):
     # game.json 的内容
     # {
     #     "deviceOrientation": "portrait",
     #     "networkTimeout": {
     #         "request": 5000,
     #         "connectSocket": 5000,
     #         "uploadFile": 5000,
     #         "downloadFile": 5000
     #     },
     #     "subpackages": []
     # }
     # 修改构建之后的 game.json 的内容
     # print('buildFolderPath_ = ' + str(buildFolderPath_))
     _gameJsonPath = sysUtils.folderPathFixEnd(
         buildFolderPath_) + "game.json"
     # print('_gameJsonPath = ' + str(_gameJsonPath))
     _gameJsonDict = fileUtils.dictFromJsonFile(_gameJsonPath)
     _gameJsonDict["networkTimeout"]["request"] = 60000
     _gameJsonDict["networkTimeout"]["connectSocket"] = 60000
     _gameJsonDict["networkTimeout"]["uploadFile"] = 60000
     _gameJsonDict["networkTimeout"]["downloadFile"] = 60000
     _jsonStr = str(
         json.dumps(_gameJsonDict,
                    indent=4,
                    sort_keys=False,
                    ensure_ascii=False))
     fileUtils.writeFileWithStr(_gameJsonPath, _jsonStr)
Пример #5
0
def getNewNameKeepFolderStructure(
        sourceFolderPath_: str,
        targetFolderPath_: str,
        filePath_: str,
        targetSuffix_: str = None  # 需要转换后缀时,填写后缀名
):
    _sourceFolderPath = sysUtils.folderPathFixEnd(sourceFolderPath_)
    _targetFolderPath = sysUtils.folderPathFixEnd(targetFolderPath_)
    if targetSuffix_ == "" or targetSuffix_:  # 有后缀的话,就改一下
        _newFilePath = pathWithOutSuffix(filePath_).split(_sourceFolderPath)[1] + targetSuffix_
    else:  # 无后缀变换的需求,就直接用了
        _newFilePath = filePath_.split(_sourceFolderPath)[1]
    return os.path.join(
        _targetFolderPath,
        _newFilePath
    )
Пример #6
0
    def PbCreator(self, dParameters_: dict):
        _protoFolderPath = sysUtils.folderPathFixEnd(dParameters_["protoFolderPath"])
        _pbFolderPath = sysUtils.folderPathFixEnd(dParameters_["pbFolderPath"])
        _filePathDict = folderUtils.getFilePathKeyValue(_protoFolderPath, [".proto"])
        for _, _protoPath in _filePathDict.items():  # 每一个proto文件
            _protoShortPath = _protoPath.split(_protoFolderPath)[1]
            _pbShortPath = _protoShortPath.split(".proto")[0] + ".pb"
            _cmd = "protoc --descriptor_set_out ./{0} ./{1}".format(_pbShortPath, _protoShortPath)
            cmdUtils.doStrAsCmd(
                _cmd,
                _protoFolderPath,
                True
            )

        # 将生成出来的.pb文件拷贝到目标文件一份
        fileCopyUtils.copyFilesInFolderTo([".pb"], _protoFolderPath, _pbFolderPath, "include", True)
        folderUtils.removeFileByFilter(_protoFolderPath, [".pb"])  # 再删除刚拷贝过的.pb文件
Пример #7
0
 def ReCreateTag(self, dParameters_):
     _gitFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["gitFolderPath"])
     _tag = dParameters_["tag"]
     _repo = git.Repo.init(_gitFolderPath)
     if _tag in _repo.tags:
         _repo.delete_tag(_tag)  # 删除已有的
     _repo.create_tag(_tag)  # 创建新的
Пример #8
0
 def Build(self, dParameters_):
     dParameters_["projectFolderPath"] = sysUtils.folderPathFixEnd(dParameters_["projectFolderPath"])
     _cmd = "{cocosCreatorAppPath} " \
            "--path {projectFolderPath}  " \
            "--build \"configPath={projectFolderPath}WeChatGameConfig.json\""
     _cmd = _cmd.format(**dParameters_)
     print('Execute : \n    ' + str(_cmd))
     cmdUtils.doStrAsCmd(_cmd, dParameters_["projectFolderPath"], True)
Пример #9
0
 def Folder(self, dParameters_: dict):
     _sourceFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["sourceFolder"])  # 确保路径正确
     _targetFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["targetFolder"])
     _xlsxFilePathList = folderUtils.getFileListInFolder(
         _sourceFolderPath, [".xlsx"])
     for _idx in range(len(_xlsxFilePathList)):
         _xlsxFilePath = _xlsxFilePathList[_idx]
         # # 变更执行权限
         # cmdUtils.showXattr(os.path.dirname(_xlsxFilePath))  # Operation not permitted 时放开注释,查阅信息
         # sysUtils.chmod("666","["com.apple.quarantine"]", _xlsxFilePath)
         # xlsx文件 -> 文件夹,包含了将要生成json文件。
         _xlsxFolderPath = fileUtils.getNewNameKeepFolderStructure(
             _sourceFolderPath, _targetFolderPath, _xlsxFilePath, "")
         _currentWorkBook = WorkBook.WorkBook()  # 解析WorkBook
         _currentWorkBook.initWithWorkBook(_xlsxFilePath)
         _currentWorkBook.toJsonFile(_xlsxFolderPath)  # 内容解析成json,写入给定文件夹
Пример #10
0
def createPuml(csFoderPath_: str, pumlFolderPath_: str):
    csFoderPath_ = sysUtils.folderPathFixEnd(csFoderPath_)
    folderUtils.makeSureDirIsExists(pumlFolderPath_)
    pumlFolderPath_ = sysUtils.folderPathFixEnd(pumlFolderPath_)
    # 生成 puml 文本文件,cs文件和puml文件一一对应
    _umlDocCMD = "puml-gen " + csFoderPath_ + " " + pumlFolderPath_ + " -dir"
    cmdUtils.doStrAsCmd(_umlDocCMD, pumlFolderPath_, True)
    # puml-gen 会生成一个 include.puml 文件,用来整合所有的文件
    _pumlList = folderUtils.getFileListInFolder(pumlFolderPath_, [".puml"])
    # include.puml 的内容格式和最新的plantuml不匹配,我们手动生成一个
    _includeContent = "@startuml\n"
    # 先打印最外层文件
    for _i in range(len(_pumlList)):
        _includeContent += "!include " + _pumlList[_i] + "\n"
    _includeContent += "@enduml"
    # 覆盖掉原有的 include.puml
    fileUtils.writeFileWithStr(os.path.join(pumlFolderPath_, "include.puml"),
                               _includeContent)
Пример #11
0
 def ClearCreateJpg(self, dParameters_):
     _createJpgFolderPath = sysUtils.folderPathFixEnd(dParameters_["createJpgFolder"])
     _jpgPathList = folderUtils.getFilterFilesInPath(_createJpgFolderPath, [".jpg"])
     for _i in range(len(_jpgPathList)):
         _jpgPath = _jpgPathList[_i]
         _jpgName = os.path.basename(_jpgPath)
         _jpgResult = re.search(r'(\d+).jpg', _jpgName)  # 纯数字名称,满足条件就删除
         if _jpgResult:
             fileUtils.removeExistFile(_jpgPath)
Пример #12
0
 def OSS(self, dParameters_: dict):
     _localFilePath = sysUtils.folderPathFixEnd(dParameters_["localFolderPath"])
     _remoteFolderPath = sysUtils.folderPathFixEnd(dParameters_["remoteFolderPath"])
     _bucket = oss2.Bucket(
         oss2.Auth(
             dParameters_["accessKeyId"],
             dParameters_["accessKeySecret"]
         ),
         dParameters_["endPoint"],
         bucket_name=dParameters_["bucketName"]
     )
     self.uploadDirToOSS(
         _localFilePath,
         _localFilePath,
         _bucket,
         _remoteFolderPath,
         dParameters_["filters"]
     )
Пример #13
0
    def IconResize(self, dParameters_):
        _sourceFolder = sysUtils.folderPathFixEnd(dParameters_["sourceFolder"])
        _targetFolder = sysUtils.folderPathFixEnd(dParameters_["targetFolder"])
        _sizeList = dParameters_["sizeList"]
        _targetType = dParameters_["type"]
        _sourcePicList = folderUtils.getFilterFilesInPath(
            _sourceFolder, [".jpg", ".png"])

        _imList = []  # image信息列表
        for _sourcePicPath in _sourcePicList:  # 要放缩的Icon
            _im = Image.open(_sourcePicPath)  # 加载内存,方便获取信息
            _sizeCompareValue = _im.width / _im.height
            if _sizeCompareValue > 1.1 or _sizeCompareValue < 0.9:  # 校验宽高比,差太多提示一下
                self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                                _sourcePicPath + " 作为图标,宽高比相差有点儿大")
            _imList.append(_im)
        _imList.sort(key=lambda _im: _im.width, reverse=True)  # 按照由大到小的顺序
        _sizeList.sort(key=lambda _size: _size, reverse=True)  # 由大到小

        if _sizeList[0] > _imList[0].width:
            self.raiseError(
                pyUtils.getCurrentRunningFunctionName(),
                "索取大小的最大值(" + str(_sizeList[0]) + ")大于给与大小的最大值(" +
                str(_imList[0].width) + ")")

        # Image实例.thumbnail((宽, 高))会改变Image实例本身,所以,又大到小进行逐步变化。
        # 由大到小的,将每一个小于自己尺寸的ICON生成一遍。小的会覆盖大的生成的ICON,最后达到想要的结果。
        for _im in _imList:  # 先比大的,后比小的,小于等于最接近的会最后成为目标图片
            for _size in _sizeList:  # 放缩的目标值
                if _size <= _im.width:  # 目标值小于当前图片的大小。就使用者张图
                    _targetIconPath = os.path.join(
                        _targetFolder, 'Icon-' + str(_size) + _targetType)
                    _im.thumbnail(
                        (_size, _size)
                    )  # target Image 在内存内存中大小会变小,下一个循环比他要小。所以,_sizeList必须是倒叙的
                    if _targetType == ".png":
                        _im.save(_targetIconPath)
                    elif _targetType == ".jpg":
                        _im.save(_targetIconPath, quality=95, subsampling=0)
                    else:
                        self.raiseError(
                            pyUtils.getCurrentRunningFunctionName(),
                            _targetType + " 格式无效,目标格式,只能是.png和.jpg中的一种")
Пример #14
0
 def File(self, dParameters_: dict):
     _xlsxFilePath = dParameters_["xlsxPath"]
     _targetFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["targetFolder"])
     # # 变更执行权限
     # cmdUtils.showXattr(os.path.dirname(_xlsxFilePath))  # Operation not permitted 时放开注释,查阅信息
     # sysUtils.chmod("666","["com.apple.quarantine"]", _xlsxFilePath)
     _currentWorkBook = WorkBook.WorkBook()  # 解析WorkBook
     _currentWorkBook.initWithWorkBook(_xlsxFilePath)
     _currentWorkBook.toJsonFile(_targetFolderPath)  # 内容解析成json,写入给定文件夹
Пример #15
0
 def FTP(self, dParameters_: dict):
     _localFilePath = sysUtils.folderPathFixEnd(dParameters_["localFolderPath"])
     _ftpSync = ftpUtils.getFTPSync(
         dParameters_["ftpHost"],
         dParameters_["ftpUserName"],
         dParameters_["ftpPassWord"],
         dParameters_["ftpFolder"]
     )
     ftpUtils.uploadFolder(
         _ftpSync,
         _localFilePath,
         dParameters_["ftpSubFolder"]
     )
Пример #16
0
 def EncodeFolder(self, dParameters_):
     _folderPath = sysUtils.folderPathFixEnd(dParameters_["folderPath"])
     _type = dParameters_["type"].strip().lower()
     _filePathList = folderUtils.getFileListInFolder(
         _folderPath, dParameters_["filters"])
     _createHashDictFilePath = dParameters_["createHashDictFilePath"]
     _hashDict = {}
     for _i in range(len(_filePathList)):
         _filePath = _filePathList[_i]
         _hashDict[_filePath.split(_folderPath)[1]] = self.fileEncode(
             _filePath, _type)
     fileUtils.writeFileWithStr(
         _createHashDictFilePath,
         str(
             json.dumps(_hashDict,
                        indent=4,
                        sort_keys=False,
                        ensure_ascii=False)))
Пример #17
0
def addStackLog(svr_: UnityLuaAnalyse):
    _logFolderList = [
        # "Framework/Network/",
        # "Game/Common/",
        # "Game/Scene/",
        # "Game/Stage/",
        "Game/Module/logic/",
        "Game/Module/data/",
        "Game/Module/service/",
        "Game/Module/util/",
        "net/",  # net/protobuflua/ 文件夹需要通过 Git 还原
        "ui/framework",
        "ui/page",
        "ui/util",
    ]
    for _i in range(len(_logFolderList)):
        _folderPath = sysUtils.folderPathFixEnd(os.path.join(luaPath, _logFolderList[_i]))
        print('_folderPath = ' + str(_folderPath))
        svr_.addRunningStackLog(_folderPath)
Пример #18
0
 def ToolsInSystem(self, dParameters_: dict):
     _toolPathOrTooName = str(
         dParameters_["toolPathOrTooName"])  # 工具路径,或者是全局已经配置好的名称
     _execFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["execFolderPath"])  # 路径需要确保后面有/
     _cmdStr = _toolPathOrTooName + " "
     # 列表形式的参数需求
     if "parameterList" in dParameters_:
         _parameterList = dParameters_["parameterList"]
         for _i in range(len(_parameterList)):
             _parameterElement = _parameterList[_i]
             if isinstance(_parameterElement, dict):  # 键值对形式的参数
                 _cmdStr += "--" + _parameterElement[
                     "key"] + " '" + _parameterElement["value"] + "' "
             else:  # 列表形式的参数
                 _cmdStr += "'" + str(_parameterElement) + "' "
     else:
         self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                         "必须有 parameterList 参数")
     cmdUtils.doStrAsCmd(_cmdStr, _execFolderPath, True)
Пример #19
0
    def CheckOut(self, dParameters_):
        _gitFolderPath = sysUtils.folderPathFixEnd(
            dParameters_["gitFolderPath"])
        _branch = dParameters_["branch"]
        _path = dParameters_["path"]

        # 本地没有的时候,将远程的迁出到本地。本地和远端同名
        _localBranchName = _branch.split("/")[-1]  # 本地该叫什么名
        _branchStrList = cmdUtils.doStrAsCmd('git branch', _gitFolderPath,
                                             True)  # 输出本地有什么
        _localBranchNameList = []
        _currentLocalBranchName = ""
        for _i in range(len(_branchStrList)):
            _currentBranchName = _branchStrList[_i][2:]
            _localBranchNameList.append(_currentBranchName)  # 记录本地名列表
            if _branchStrList[_i].startswith("* "):  # 当前所在那个本地分支
                _currentLocalBranchName = _currentBranchName

        # 不在指定名称分支内
        if not _currentLocalBranchName == _localBranchName:
            # 本地没有这个名称的分支
            if not _localBranchName in _localBranchNameList:
                # 在当前git所在目录,检出分支,指定其名称
                cmdUtils.doStrAsCmd(
                    "git checkout " + _branch + " -b " + _localBranchName,
                    _gitFolderPath, True)
            else:
                # 本地,有分支,只需要检出
                cmdUtils.doStrAsCmd("git checkout " + _localBranchName,
                                    _gitFolderPath, True)

        # 路径整理
        if _path.startswith("\\") or _path.startswith("/"):
            self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                            "path 不能以 \\ 或 / 开头")
        _path = str(Path(_path))  # "" 会被转换成 "."
        if _path == ".":
            cmdUtils.doStrAsCmd('git checkout .', _gitFolderPath, True)
        else:
            cmdUtils.doStrAsCmd('git checkout -- ' + _path, _gitFolderPath,
                                True)
Пример #20
0
    def BuildIOS(self, dParameters_):
        _unityPathPath = dParameters_["unityPath"]
        _projectPath = sysUtils.folderPathFixEnd(dParameters_["projectPath"])
        _version = dParameters_["version"]
        _bundle = dParameters_["bundle"]
        _platform = dParameters_["platform"]
        _logFile = dParameters_["logFile"]
        _executeMethod = None

        if _platform == "iOS":
            _executeMethod = "platformBuild.BuildIOS"
        else:
            self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                            " platform 不支持")
        _cmdStr = _unityPathPath + " -quit -batchmode -projectPath " + _projectPath + " -executeMethod " + _executeMethod + " " + _version + " " + _bundle + " -buildTarget " + _platform + " -logFile " + _logFile

        # 执行命令
        cmdUtils.doStrAsCmd(_cmdStr, _projectPath, False)

        # Unity 工具
        "/Volumes/18604037792/Applications/Unity2018.4.11f1/Unity.app/Contents/MacOS/Unity"
Пример #21
0
def createUML(plantUmlJarPath_: str, pumlPath_: str, umlFolderPath_: str):
    # 判断其存在性
    if not os.path.exists(pumlPath_):
        print("ERROR : puml文件错误")
    # 确保文件夹正确性
    folderUtils.makeSureDirIsExists(umlFolderPath_)
    umlFolderPath_ = sysUtils.folderPathFixEnd(umlFolderPath_)
    # 获取 puml 所在文件夹
    _pumlFolderPath = os.path.dirname(pumlPath_)
    _justName = os.path.splitext(os.path.split(pumlPath_)[1])[0]
    # 通过 puml  生成 uml 图
    _umlPicCMD = "java -jar " + plantUmlJarPath_ + " -tsvg " + pumlPath_
    cmdUtils.doStrAsCmd(_umlPicCMD, _pumlFolderPath, True)
    # 将生成的 puml 转移到指定文件夹内
    _umpPath = os.path.join(_pumlFolderPath, _justName + ".svg")
    if os.path.exists(_umpPath):
        shutil.copy(_umpPath, os.path.join(umlFolderPath_, _justName + ".svg"))
        os.remove(pumlPath_)
        os.remove(_umpPath)
    else:
        print("ERROR : UML图创建错误")
Пример #22
0
    def PbStructure(self, dParameters_: dict):
        '''
        1.文件夹结构,必须是二级结构
        Folder                         [放置proto文件的文件夹]
        |____Type                      [proto根据功能模块分组的文件夹]
             |____xxRes.proto          [发送]
             |____xxReq.proto          [接收]
             |____xxSync.proto         [同步或其他]
        2.将文件夹内的proto文件结构整理成文本
            1.按照文件夹分类,也就是 Type 。
            2.按照后缀区分类型,也就是发送、接收、其他。
                请求种类
                    Req 为请求
                    Res 为相应
                    其他
                分组种类
                    有去有回 Req <-> Res
                    有去 Req ->
                    有回 Res <-
                    其他 Others
            3.嵌套结构会直接按照层级放置展开
            4.字段的类型代表
                <!> require
                <?> optional
                [*] 数组
            5.被嵌套的结构一定要先定义,再使用
        '''
        _protoFolderPath = sysUtils.folderPathFixEnd(dParameters_["protoFolderPath"])
        _structureDescriptionFilePathPath = dParameters_["structureDescriptionFilePath"]

        # 创建 Excel 工作流
        _appName = "ExcelWorkFlow"
        _baseServiceName = "ProtoStructAnalyse"
        _baseService = self.app.main.getAppWithService(_appName, _baseServiceName)

        _structureStrList = _baseService.analyseProtoStructureInFolder(_protoFolderPath)
        fileUtils.writeFileWithStr(
            _structureDescriptionFilePathPath,
            listUtils.joinListToStr(_structureStrList, "\n")
        )
Пример #23
0
def uploadFolder(
        ftpSync_,  # ftpSync 对象
        localFolderPath_,  # 本地的文件夹路径
        ftpFolderPath_=None  # ftp对应文件夹中的子文件夹
):
    _ftpConnect = ftpSync_.ftpConnect

    localFolderPath_ = sysUtils.folderPathFixEnd(localFolderPath_)  # 确保文件夹格式
    _fileList = os.listdir(localFolderPath_)  # 文件夹中的文件列表
    _lastFolder = os.path.abspath('.')  # 先记住之前在哪个工作目录中
    os.chdir(localFolderPath_)  # 然后切换到目标工作目录

    if ftpFolderPath_:
        _currentTargetFolderPath = _ftpConnect.pwd()
        try:
            _ftpConnect.mkd(ftpFolderPath_)
        except Exception:
            pass
        finally:
            _ftpConnect.cwd(
                os.path.join(_currentTargetFolderPath, ftpFolderPath_))

    for _fileName in _fileList:
        _currentTargetFolderPath = _ftpConnect.pwd()
        _currentLocal = localFolderPath_ + r'/{}'.format(_fileName)
        if os.path.isfile(_currentLocal):
            uploadFile(ftpSync_, localFolderPath_, _fileName, None)
        elif os.path.isdir(_currentLocal):
            try:
                _ftpConnect.mkd(_fileName)
            except:
                pass
            _ftpConnect.cwd("%s/%s" % (_currentTargetFolderPath, _fileName))
            uploadFolder(ftpSync_, _currentLocal)

        # 之前路径可能已经变更,需要再回复到之前的路径里
        _ftpConnect.cwd(_currentTargetFolderPath)

    os.chdir(_lastFolder)
Пример #24
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)
Пример #25
0
 def JustCMD(self, dParameters_: dict):
     _cmdStr = str(dParameters_["CMD"])
     _execFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["execFolderPath"])  # 路径需要确保后面有/
     cmdUtils.doStrAsCmd(_cmdStr, _execFolderPath, True)
Пример #26
0
    def buildMiniClient_WeChat(self):
        # 工程路径
        _projectFolderPath = sysUtils.folderPathFixEnd(
            "/Volumes/Files/develop/loho/mini-game/miniclient/")
        _assetsFolderPath = sysUtils.folderPathFixEnd(_projectFolderPath +
                                                      "assets")
        _appConfigJsonPath = _projectFolderPath + "assets/resources/configs/AppConfig.json"
        # 打包配置路径
        _miniClientJsonPath = fileUtils.getPath(self.resPath,
                                                "WeChatGameConfig.json")
        # 打包配置内容
        _miniClientJsonDict = fileUtils.dictFromJsonFile(_miniClientJsonPath)
        # 获取构建之后的目录
        _buildFolderPath = sysUtils.folderPathFixEnd(
            _miniClientJsonDict["buildPath"]) + "wechatgame"
        # 获取构建之后的res目录
        _resFolderPath = sysUtils.folderPathFixEnd(_buildFolderPath) + "res/"

        print("请确保所有内容都已经 push 到远程,这样才能创建正确的 TAG")
        # 获取Git链接
        _repo = gitUtils.getRepo(_projectFolderPath)
        # 获取当前满足版本格式的Tag中最大的tag号
        _tagStrList = [
            str(_tagName) for _tagName in _repo.tags
            if strUtils.isVersionStr(str(_tagName))
        ]
        _tagStrList = sorted(_tagStrList,
                             key=functools.cmp_to_key(strUtils.versionCompare),
                             reverse=True)
        # 记录版本号
        _biggestTar = _tagStrList[0]
        print("当前最大 TAG : " + _biggestTar)
        # 增加最后一位的版本号
        _tagIntList = [int(_tarStr) for _tarStr in _biggestTar.split(".")]
        _tagIntList[-1] = _tagIntList[-1] + 1
        _currentTar = ".".join([str(_tarInt) for _tarInt in _tagIntList])
        # 填写到AppConfig.json中
        print("修改本地的AppConfig版本号为 : " + _currentTar)
        print("  *请注意,只是修改本地。从本地提交到微信小程序测试工具中。不通过Git Remote 推送")
        self.changeAppConfigJson(_appConfigJsonPath, _currentTar)
        # 在 Git 上创建 tag
        print("创建新 TAG : " + _currentTar)
        _repo.create_tag(_currentTar)

        # 构建工程
        _cmd = self.getBuildCmd(_projectFolderPath, _miniClientJsonPath)
        print("获取构建命令: \n" + _cmd)

        # 获取构建的LOG 并记录下来。
        _cmdLogFile = "\n".join(os.popen(_cmd).readlines())
        fileUtils.writeFileWithStr(_buildFolderPath + "buildLog.log",
                                   _cmdLogFile)

        # 修改game.json内的超时时间
        self.changeGameJson(_buildFolderPath)

        print("正在获取FTP链接")
        # 获取要上传的ftp的host
        _ftpHost = "ftp网址"
        _ftpUserName = "******"
        _ftpPassWord = "******"
        _ftpSync = ftpUtils.getFTPSync(_ftpHost, _ftpUserName, _ftpPassWord,
                                       "路径/文件夹")
        print("ftp链接获取成功,正在上传请稍后")

        # 指定目录为 res ,那么res中的内容对应同步
        ftpUtils.uploadFolder(_ftpSync, _resFolderPath)
        print("资源上传成功")

        return
Пример #27
0
 def Override(self, dParameters_: dict):
     _sourceFolderPath = sysUtils.folderPathFixEnd(dParameters_["sourceFolder"])
     _targetFolderPath = sysUtils.folderPathFixEnd(dParameters_["targetFolder"])
     _filters = dParameters_["filters"]  # 过滤项
     self.override(_sourceFolderPath, _targetFolderPath, _filters)
Пример #28
0
 def DeleteFolder(self, dParameters_):
     _deleteFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["deleteFolderPath"])
     self.checkDeleteFolder(_deleteFolderPath)
     folderUtils.removeTree(str(_deleteFolderPath))
Пример #29
0
    sys.exit(1)

    _opsDefineDict = {}
    # 执行参数必须预先定义,所以,可以通过命令行替换的参数是固定的。
    _opsDefineDict["executeType"] = '执行模式'
    _opsDefineDict["excelPath"] = 'excel路径'
    _opsDefineDict["sheetName"] = '指定执行的sheet名称,不指定就是全执行'
    # 可选项
    _opsDefineDict["__option__"] = [
        "sheetName",  # sheet名,可以不指定
        "executeType",  # 执行模式,可以不指定
    ]

    _thisFilePath = os.path.dirname(os.path.realpath(__file__))
    print("脚本路径 : " + _thisFilePath)
    _pwd = sysUtils.folderPathFixEnd(os.getcwd())
    print("执行路径 : " + _pwd)

    # 参数合并构建
    _opsDict = cmdUtils.getOps(_opsDefineDict, OptionParser())

    print("脚本参数 : ")
    for _key in _opsDict:
        print("    " + _key + " : " + _opsDict[_key])

    _main = Main()  # 创建 Excel 工作流
    _excelApp = _main.createAppByName("Excel")
    _excelApp.start()

    _excelPath = _opsDict["excelPath"]  # excel 路径
    _sheetName = _opsDict["sheetName"]  # sheetName 页名
Пример #30
0
 def DeleteFileInFolder(self, dParameters_):
     _deleteFolderPath = sysUtils.folderPathFixEnd(
         dParameters_["deleteFolderPath"])
     self.checkDeleteFolder(_deleteFolderPath)
     folderUtils.removeFileByFilter(_deleteFolderPath,
                                    dParameters_["filters"])