def _runInternal(self): if self._requestId == 'updateLinks': self._packageMgr.updateProjectJunctions(self._project, self._platform) elif self._requestId == 'openUnity': self._packageMgr.checkProjectInitialized(self._project, self._platform) self._unityHelper.openUnity(self._project, self._platform) elif self._requestId == 'openPackagesFolder': os.startfile(self._varMgr.expandPath("[UnityPackagesDir]")) elif self._requestId == 'updateCustomSolution': self._vsSolutionHelper.updateCustomSolution( self._project, self._platform) elif self._requestId == 'openCustomSolution': self._vsSolutionHelper.openCustomSolution(self._project, self._platform) elif self._requestId == 'listPackages': infos = self._packageMgr.getAllPackageInfos() for packageInfo in infos: sys.stderr.write('---\n') sys.stderr.write(YamlSerializer.serialize(packageInfo) + '\n') elif self._requestId == 'listProjects': projectNames = self._packageMgr.getAllProjectNames() for projName in projectNames: sys.stderr.write(projName + '\n') elif self._requestId == 'listReleases': for release in self._releaseSourceManager.lookupAllReleases(): sys.stderr.write('---\n') sys.stderr.write(YamlSerializer.serialize(release) + '\n') elif self._requestId == 'deletePackage': self._log.info("Deleting package '{0}'", self._param1) self._packageMgr.deletePackage(self._param1) elif self._requestId == 'createPackage': self._log.info("Creating package '{0}'", self._param1) self._packageMgr.createPackage(self._param1) elif self._requestId == 'installRelease': self._log.info("Installing release '{0}' version code '{1}'", self._param1, self._param2) self._releaseSourceManager.installReleaseById( self._param1, self._param2, True) elif self._requestId == 'createProject': self._log.info("Creating new project '{0}'", self._project) self._packageMgr._createProject(self._project) else: assertThat(False, "Invalid request id '{0}'", self._requestId)
def _runInternal(self): if self._requestId == 'updateLinks': self._packageMgr.updateProjectJunctions(self._project, self._platform) elif self._requestId == 'openUnity': self._packageMgr.checkProjectInitialized(self._project, self._platform) self._unityHelper.openUnity(self._project, self._platform) elif self._requestId == 'openPackagesFolder': os.startfile(self._varMgr.expandPath("[UnityPackagesDir]")) elif self._requestId == 'updateCustomSolution': self._vsSolutionHelper.updateCustomSolution(self._project, self._platform) elif self._requestId == 'openCustomSolution': self._vsSolutionHelper.openCustomSolution(self._project, self._platform) elif self._requestId == 'listPackages': infos = self._packageMgr.getAllPackageInfos() for packageInfo in infos: sys.stderr.write('---\n') sys.stderr.write(YamlSerializer.serialize(packageInfo) + '\n') elif self._requestId == 'listProjects': projectNames = self._packageMgr.getAllProjectNames() for projName in projectNames: sys.stderr.write(projName + '\n') elif self._requestId == 'listReleases': for release in self._releaseSourceManager.lookupAllReleases(): sys.stderr.write('---\n') sys.stderr.write(YamlSerializer.serialize(release) + '\n') elif self._requestId == 'deletePackage': self._log.info("Deleting package '{0}'", self._param1) self._packageMgr.deletePackage(self._param1) elif self._requestId == 'createPackage': self._log.info("Creating package '{0}'", self._param1) self._packageMgr.createPackage(self._param1) elif self._requestId == 'installRelease': self._log.info("Installing release '{0}' version code '{1}'", self._param1, self._param2) self._releaseSourceManager.installReleaseById(self._param1, self._param2, True) elif self._requestId == 'createProject': self._log.info("Creating new project '{0}'", self._project) self._packageMgr._createProject(self._project) else: assertThat(False, "Invalid request id '{0}'", self._requestId)
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)
def init(self): self._log.heading("Initializing remote server release source") self._log.debug("Initializing remote server release source with URL '{0}'", self._manifestUrl) response = urllib.request.urlopen(self._manifestUrl) manifestData = response.read().decode('utf-8') self._log.debug("Got manifest with data: \n{0}".format(manifestData)) self._manifest = YamlSerializer.deserialize(manifestData) for info in self._manifest.releases: info.url = urllib.parse.urljoin(self._manifestUrl, info.localPath) info.localPath = None self._releaseInfos.append(info)
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)
def getAllPackageInfos(self): if not self._packageInfos: self._packageInfos = [] for name in self.getAllPackageNames(): path = self._varMgr.expandPath('[UnityPackagesDir]/{0}'.format(name)) installInfoFilePath = os.path.join(path, InstallInfoFileName) info = PackageInfo() info.name = name info.path = path if self._sys.fileExists(installInfoFilePath): installInfo = YamlSerializer.deserialize(self._sys.readFileAsText(installInfoFilePath)) info.installInfo = installInfo self._packageInfos.append(info) return self._packageInfos
def _saveManifest(self): yamlStr = YamlSerializer.serialize(self._manifest) self._sys.writeFileAsText(os.path.join(self._args.directory, ReleaseManifestFileName), yamlStr)