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

        self._log.heading("Installing release '{0}' (version {1})",
                          releaseInfo.name, releaseInfo.version)

        installDirName = None

        for packageInfo in self._packageManager.getAllPackageInfos():
            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:
                    print(
                        "\nFound release '{0}' already installed with version '{1}'"
                        .format(releaseInfo.name, releaseInfo.version),
                        end='')

                    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')

                self._packageManager.deletePackage(packageInfo.name)
                # Retain original directory name in case it is referenced by other packages
                installDirName = packageInfo.name

        installDirName = releaseSource.installRelease(releaseInfo,
                                                      installDirName)

        destDir = self._varMgr.expand(
            '[UnityPackagesDir]/{0}'.format(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 _installReleaseInternal(self, releaseInfo, releaseSource, suppressPrompts = False):

        self._log.heading("Installing release '{0}' (version {1})", releaseInfo.name, releaseInfo.version)

        installDirName = None

        for packageInfo in self._packageManager.getAllPackageInfos():
            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:
                    print("\nFound release '{0}' already installed with version '{1}'".format(releaseInfo.name, releaseInfo.version), end='')

                    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')

                self._packageManager.deletePackage(packageInfo.name)
                # Retain original directory name in case it is referenced by other packages
                installDirName = packageInfo.name

        installDirName = releaseSource.installRelease(releaseInfo, installDirName)

        destDir = self._varMgr.expand('[UnityPackagesDir]/{0}'.format(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)
示例#3
0
    def _runPreBuild(self):
        if self._args.openDocumentation:
            self._openDocumentation()

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

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

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

        if self._args.deletePackage:
            if not self._args.suppressPrompts:
                if not MiscUtil.confirmChoice("Are you sure you want to delete package '{0}'? (y/n)  \nNote that this change is non-recoverable!  (unless you are using source control)  ".format(self._args.deletePackage)):
                    assertThat(False, "User aborted operation")

            self._packageMgr.deletePackage(self._args.deletePackage)

        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.deleteProject, ProjectConfigFileName)):
                    assertThat(False, "User aborted operation")
            self._packageMgr.deleteProject(self._args.deleteProject)

        if self._args.installRelease:
            releaseName, releaseVersion = self._args.installRelease
            self._releaseSourceManager.installReleaseByName(releaseName, releaseVersion)

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

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

        if self._args.updateUnitySolution:
            self._vsSolutionHelper.updateUnitySolution(self._project, self._platform)

        if self._args.updateCustomSolution:
            self._vsSolutionHelper.updateCustomSolution(self._project, self._platform)