示例#1
0
    def _installReleaseInternal(self, projectName, packageRoot, releaseInfo, releaseSource, suppressPrompts = False):

        if not self._sys.directoryExists(packageRoot):
            self._sys.createDirectory(packageRoot)

        with self._log.heading("Installing release '{0}' (version {1})", releaseInfo.name, releaseInfo.version):
            installDirName = None
            for folderInfo in self._packageManager.getAllPackageFolderInfos(projectName):
                for packageInfo in folderInfo.packages:
                    installInfo = packageInfo.installInfo

                    if installInfo and installInfo.releaseInfo and installInfo.releaseInfo.id == releaseInfo.id:
                        if installInfo.releaseInfo.versionCode == releaseInfo.versionCode:
                            if not suppressPrompts:
                                shouldContinue = MiscUtil.confirmChoice(
                                    "Release '{0}' (version {1}) is already installed.  Would you like to re-install anyway?  Note that this will overwrite any local changes you've made to it.".format(releaseInfo.name, releaseInfo.version))

                                assertThat(shouldContinue, 'User aborted')
                        else:
                            self._log.info("Found release '{0}' already installed with version '{1}'", installInfo.releaseInfo.name, installInfo.releaseInfo.version)

                            installDirection = 'UPGRADE' if releaseInfo.versionCode > installInfo.releaseInfo.versionCode else 'DOWNGRADE'

                            if not suppressPrompts:
                                shouldContinue = MiscUtil.confirmChoice("Are you sure you want to {0} '{1}' from version '{2}' to version '{3}'? (y/n)".format(installDirection, releaseInfo.name, installInfo.releaseInfo.version, releaseInfo.version))
                                assertThat(shouldContinue, 'User aborted')

                        existingDir = self._varMgr.expand(os.path.join(folderInfo.path, packageInfo.name))

                        self._sys.deleteDirectory(existingDir)

                        # Retain original directory name in case it is referenced by other packages
                        installDirName = packageInfo.name

            installDirName = releaseSource.installRelease(packageRoot, releaseInfo, installDirName)

            destDir = self._varMgr.expand(os.path.join(packageRoot, installDirName))

            assertThat(self._sys.directoryExists(destDir), 'Expected dir "{0}" to exist', destDir)

            newInstallInfo = PackageInstallInfo()
            newInstallInfo.releaseInfo = releaseInfo
            newInstallInfo.installDate = datetime.utcnow()

            yamlStr = YamlSerializer.serialize(newInstallInfo)
            self._sys.writeFileAsText(os.path.join(destDir, InstallInfoFileName), yamlStr)

            self._log.info("Successfully installed '{0}' (version {1})", releaseInfo.name, releaseInfo.version)
示例#2
0
    def _runPreBuild(self):

        if self._args.deleteProject:
            if not self._args.suppressPrompts:
                if not MiscUtil.confirmChoice(
                        "Are you sure you want to delete project '{0}'? (y/n)  \nNote that this will only delete your unity project settings and the {1} for this project.  \nThe rest of the content for your project will remain in the UnityPackages folder  "
                        .format(self._args.project, ProjectConfigFileName)):
                    assertThat(False, "User aborted operation")
            self._packageMgr.deleteProject(self._args.project)

        if self._args.createProject:
            self._packageMgr.createProject(self._args.project)

        if self._args.projectAddPackageAssets:
            self._projectConfigChanger.addPackage(
                self._args.project, self._args.projectAddPackageAssets, True)

        if self._args.projectAddPackagePlugins:
            self._projectConfigChanger.addPackage(
                self._args.project, self._args.projectAddPackagePlugins, False)

        if self._args.openDocumentation:
            self._openDocumentation()

        if self._args.clearProjectGeneratedFiles:
            self._packageMgr.clearProjectGeneratedFiles(self._args.project)

        if self._args.clearAllProjectGeneratedFiles:
            self._packageMgr.clearAllProjectGeneratedFiles()

        if self._args.deleteAllLinks:
            self._packageMgr.deleteAllLinks()

        if self._args.buildPrebuild:
            self.buildPrebuildProjects()

        if self._args.init:
            self._packageMgr.updateLinksForAllProjects()

        if self._args.initLinks:
            self._packageMgr.checkProjectInitialized(self._args.project,
                                                     self._platform)

        if self._args.updateLinks:
            self._packageMgr.updateProjectJunctions(self._args.project,
                                                    self._platform)

        if self._args.updateUnitySolution:
            self._projVsHelper.updateUnitySolution(self._args.project,
                                                   self._platform)

        if self._args.updateCustomSolution:
            self._projVsHelper.updateCustomSolution(self._args.project,
                                                    self._platform)
示例#3
0
    def _runPreBuild(self):

        if self._args.deleteProject:
            if not self._args.suppressPrompts:
                if not MiscUtil.confirmChoice(
                    "Are you sure you want to delete project '{0}'? (y/n)  \nNote that this will only delete your unity project settings and the {1} for this project.  \nThe rest of the content for your project will remain in the UnityPackages folder  ".format(
                        self._args.project, ProjectConfigFileName
                    )
                ):
                    assertThat(False, "User aborted operation")
            self._packageMgr.deleteProject(self._args.project)

        if self._args.createProject:
            self._packageMgr.createProject(self._args.project)

        if self._args.projectAddPackageAssets:
            self._projectConfigChanger.addPackage(self._args.project, self._args.projectAddPackageAssets, True)

        if self._args.projectAddPackagePlugins:
            self._projectConfigChanger.addPackage(self._args.project, self._args.projectAddPackagePlugins, False)

        if self._args.openDocumentation:
            self._openDocumentation()

        if self._args.clearProjectGeneratedFiles:
            self._packageMgr.clearProjectGeneratedFiles(self._args.project)

        if self._args.clearAllProjectGeneratedFiles:
            self._packageMgr.clearAllProjectGeneratedFiles()

        if self._args.deleteAllLinks:
            self._packageMgr.deleteAllLinks()

        if self._args.buildPrebuild:
            self.buildPrebuildProjects()

        if self._args.init:
            self._packageMgr.updateLinksForAllProjects()

        if self._args.initLinks:
            self._packageMgr.checkProjectInitialized(self._args.project, self._platform)

        if self._args.updateLinks:
            self._packageMgr.updateProjectJunctions(self._args.project, self._platform)

        if self._args.updateUnitySolution:
            self._projVsHelper.updateUnitySolution(self._args.project, self._platform)

        if self._args.updateCustomSolution:
            self._projVsHelper.updateCustomSolution(self._args.project, self._platform)
示例#4
0
    def _installReleaseInternal(self,
                                projectName,
                                packageRoot,
                                releaseInfo,
                                releaseSource,
                                suppressPrompts=False):

        if not self._sys.directoryExists(packageRoot):
            self._sys.createDirectory(packageRoot)

        with self._log.heading("Installing release '{0}' (version {1})",
                               releaseInfo.name, releaseInfo.version):
            installDirName = None
            for folderInfo in self._packageManager.getAllPackageFolderInfos(
                    projectName):
                for packageInfo in folderInfo.packages:
                    installInfo = packageInfo.installInfo

                    if installInfo and installInfo.releaseInfo and installInfo.releaseInfo.id == releaseInfo.id:
                        if installInfo.releaseInfo.versionCode == releaseInfo.versionCode:
                            if not suppressPrompts:
                                shouldContinue = MiscUtil.confirmChoice(
                                    "Release '{0}' (version {1}) is already installed.  Would you like to re-install anyway?  Note that this will overwrite any local changes you've made to it."
                                    .format(releaseInfo.name,
                                            releaseInfo.version))

                                assertThat(shouldContinue, 'User aborted')
                        else:
                            self._log.info(
                                "Found release '{0}' already installed with version '{1}'",
                                installInfo.releaseInfo.name,
                                installInfo.releaseInfo.version)

                            installDirection = 'UPGRADE' if releaseInfo.versionCode > installInfo.releaseInfo.versionCode else 'DOWNGRADE'

                            if not suppressPrompts:
                                shouldContinue = MiscUtil.confirmChoice(
                                    "Are you sure you want to {0} '{1}' from version '{2}' to version '{3}'? (y/n)"
                                    .format(installDirection, releaseInfo.name,
                                            installInfo.releaseInfo.version,
                                            releaseInfo.version))
                                assertThat(shouldContinue, 'User aborted')

                        existingDir = self._varMgr.expand(
                            os.path.join(folderInfo.path, packageInfo.name))

                        self._sys.deleteDirectory(existingDir)

                        # Retain original directory name in case it is referenced by other packages
                        installDirName = packageInfo.name

            installDirName = releaseSource.installRelease(
                packageRoot, releaseInfo, installDirName)

            destDir = self._varMgr.expand(
                os.path.join(packageRoot, installDirName))

            assertThat(self._sys.directoryExists(destDir),
                       'Expected dir "{0}" to exist', destDir)

            newInstallInfo = PackageInstallInfo()
            newInstallInfo.releaseInfo = releaseInfo
            newInstallInfo.installDate = datetime.utcnow()

            yamlStr = YamlSerializer.serialize(newInstallInfo)
            self._sys.writeFileAsText(
                os.path.join(destDir, InstallInfoFileName), yamlStr)

            self._log.info("Successfully installed '{0}' (version {1})",
                           releaseInfo.name, releaseInfo.version)