예제 #1
0
def Run() -> bool:
    for modNamespace in Mods.GetAllModNames():  # type: str
        Mods.BuildModRebuild(modNamespace)

    print("All mods built. " + datetime.datetime.now().strftime("%I:%M %p"))

    return True
예제 #2
0
def VerifyStripping() -> None:
    print("Verifying stripping.")

    print("Verifying environment file stripping.")

    environmentIncludedPaths = GetIncludedPaths(
        Paths.StrippingEnvironmentFilePath,
        Paths.RootPath)  # type: typing.List[str]
    _VerifyStripped(Paths.RootPath, environmentIncludedPaths)

    for modName in Mods.GetAllModNames():  # type: str
        print("Verifying mod '" + modName + "' file stripping.")

        modPath = Mods.GetModPath(modName)  # type: str
        modIncludedPaths = GetIncludedPaths(Paths.StrippingModsFilePath,
                                            modPath)
        _VerifyStripped(modPath, modIncludedPaths)

    for siteName in Sites.GetAllSiteNames():  # type: str
        print("Verifying site '" + siteName + "' file stripping.")

        sitePath = Sites.GetSitePath(siteName)  # type: str
        siteIncludedPaths = GetIncludedPaths(Paths.StrippingSitesFilePath,
                                             sitePath)

        _VerifyStripped(sitePath, siteIncludedPaths)
예제 #3
0
def Run() -> bool:
    namespace = "NeonOcean.S4.Cycle"  # type: str

    Mods.BuildMod(namespace)
    Mods.BuildPublishing(namespace)
    Publishing.PublishModPreview(namespace)

    return True
def Run() -> bool:
    namespace = "NeonOcean.S4.Choreography"  # type: str

    Mods.BuildMod(namespace)
    Mods.BuildPublishing(namespace)
    Publishing.PublishModRelease(namespace)

    return True
예제 #5
0
def VerifyCollisions () -> None:
	print("Verifying STBL collisions.")

	staticKeys = list()  # type: typing.List[int]

	for keysFileName in os.listdir(Paths.STBLCollisionsPath):  # type: str
		keysFilePath = os.path.join(Paths.STBLCollisionsPath, keysFileName)  # type: str

		with open(keysFilePath) as keysFile:
			for staticKey in keysFile.readlines():
				staticKeys.append(int(staticKey))

	modEntries = list()  # type: typing.List[typing.Tuple[str, int]]

	for modNamespace in Mods.GetAllModNames():  # type: str
		try:
			stblModule = importlib.import_module("Mod_" + modNamespace.replace(".", "_") + ".STBL")
		except:
			continue

		modEntries.extend(stblModule.GetEntries())

	for entryIdentifier, entryKey in modEntries:  # type: str, int
		if entryKey in staticKeys:
			print("Colliding STBL key for entry '" + entryIdentifier + "'. Entry key: " + str(entryKey) + " (" + ConvertIntegerToHexadecimal(entryKey, minimumLength = 8) + ")", file = sys.stderr)

	for entryIndex, entry in enumerate(modEntries):  # type: int, typing.Tuple[str, int]
		for checkingEntryIndex, checkingEntry in enumerate(modEntries):  # type: int, typing.Tuple[str, int]
			if entryIndex == checkingEntryIndex:
				continue

			if entry[1] == checkingEntry[1]:
				print("Colliding STBL key between entry '" + entry[0] + "'. and '" + checkingEntry[0] + "' Entry key: " + str(entry[1]) + " (" + ConvertIntegerToHexadecimal(entry[1], minimumLength = 8) + ")", file = sys.stderr)
예제 #6
0
    def __init__(self, modFilePath: str):
        self.LoadModDictionary(modFilePath)

        from Automation import Mods

        self.Mod = Mods.GetMod(self.Namespace)  # type: Mods.Mod
예제 #7
0
def _BuildModDownloads () -> None:
	from Automation import Distribution, Mods

	with open(os.path.join(Paths.TemplatesPath, "DownloadInstaller.html")) as downloadTemplateFile:
		downloadInstallerTemplate = downloadTemplateFile.read()

	with open(os.path.join(Paths.TemplatesPath, "DownloadInstallerAge.html")) as downloadTemplateFile:
		downloadInstallerAgeTemplate = downloadTemplateFile.read()

	with open(os.path.join(Paths.TemplatesPath, "DownloadFiles.html")) as downloadTemplateFile:
		downloadFilesTemplate = downloadTemplateFile.read()

	with open(os.path.join(Paths.TemplatesPath, "DownloadFilesAge.html")) as downloadTemplateFile:
		downloadFilesAgeTemplate = downloadTemplateFile.read()

	with open(os.path.join(Paths.TemplatesPath, "DownloadSources.html")) as downloadTemplateFile:
		downloadSourcesTemplate = downloadTemplateFile.read()

	with open(os.path.join(Paths.TemplatesPath, "DownloadSourcesAge.html")) as downloadTemplateFile:
		downloadSourcesAgeTemplate = downloadTemplateFile.read()

	for modNamespace, modVersions in Distribution.Releases.items():  # type: str, typing.List[Distribution.ModVersion]
		modBuildPath = os.path.join(Paths.DownloadsBuildPath, "mods", modNamespace.lower())  # type: str

		licensePath = os.path.join(modBuildPath.replace(Paths.DownloadsBuildPath + os.path.sep, ""), _licenseName)  # type: str
		licensePath = licensePath.replace("\\", "/")

		with open(os.path.join(Paths.DownloadsSourcesPath, "mods", modNamespace + ".json")) as modInformationFile:
			modInformation = decoder.JSONDecoder().decode(modInformationFile.read())  # type: dict

		if not modInformation["Mod"]["Age"]:
			modInstallerTemplate = downloadInstallerTemplate  # type: str
			modFilesTemplate = downloadFilesTemplate  # type: str
		else:
			modInstallerTemplate = downloadInstallerAgeTemplate  # type: str
			modFilesTemplate = downloadFilesAgeTemplate  # type: str

		if not modInformation["Sources"]["Age"]:
			sourcesTemplate = downloadSourcesTemplate  # type: str
		else:
			sourcesTemplate = downloadSourcesAgeTemplate  # type: str

		mod = Mods.GetMod(modNamespace)  # type: Mods.Mod
		modLatestVersion = mod.ReleaseLatest  # type: Distribution.ModVersion

		modName = mod.GetName()  # type: typing.Optional[str]

		if modName is None:
			modName = modNamespace

		latestBasePath = os.path.relpath(Paths.DownloadsBuildPath, modBuildPath).replace("\\", "/") + "/.."  # type: str
		latestInstallerPath = os.path.join(modBuildPath, "installer/index.html")  # type: str
		latestInstallerURL = modLatestVersion.InstallerURL  # type: str
		latestFilesPath = os.path.join(modBuildPath, "files/index.html")  # type: str
		latestFilesRelativePath = os.path.relpath(latestFilesPath, Paths.DownloadsBuildPath)  # type: str
		latestFilesURL = modLatestVersion.FilesURL # type: str
		latestSourcesPath = os.path.join(modBuildPath, "sources/index.html")  # type: str
		latestSourcesURL = modLatestVersion.SourcesURL  # type: str

		_WriteDownload(latestInstallerPath, modInstallerTemplate, latestBasePath,
					   modName, str(modLatestVersion.Version), _typeInstaller, str(modLatestVersion.GameVersion), modLatestVersion.ReleaseDate,
					   latestFilesRelativePath, licensePath, latestInstallerURL)

		_WriteDownload(latestFilesPath, modFilesTemplate, latestBasePath,
					   modName, str(modLatestVersion.Version), _typeFiles, str(modLatestVersion.GameVersion), modLatestVersion.ReleaseDate,
					   latestFilesRelativePath, licensePath, latestFilesURL)


		_WriteDownload(latestSourcesPath, sourcesTemplate, latestBasePath,
					   modName, str(modLatestVersion.Version), _typeSources, str(modLatestVersion.GameVersion), modLatestVersion.ReleaseDate,
					   latestFilesRelativePath, licensePath, latestSourcesURL)

		for modVersion in modVersions:  # type: Distribution.ModVersion
			versionBuildPath = os.path.join(modBuildPath, str(modVersion.Version))

			basePath = os.path.relpath(Paths.DownloadsBuildPath, versionBuildPath).replace("\\", "/") + "/.."  # type: str
			installerPath = os.path.join(versionBuildPath, "installer/index.html")  # type: str
			installerURL = modVersion.InstallerURL  # type: str
			filesPath = os.path.join(versionBuildPath, "files/index.html")  # type: str
			filesRelativePath = os.path.relpath(filesPath, Paths.DownloadsBuildPath)  # type: str
			filesURL = modVersion.FilesURL  # type: str
			sourcesPath = os.path.join(versionBuildPath, "sources/index.html")  # type: str
			sourcesURL = modVersion.SourcesURL  # type: str

			_WriteDownload(installerPath, modInstallerTemplate, basePath,
						   modName, str(modVersion.Version), _typeInstaller, str(modLatestVersion.GameVersion), modLatestVersion.ReleaseDate,
						   filesRelativePath, licensePath, installerURL)


			_WriteDownload(filesPath, modFilesTemplate, basePath,
						   modName, str(modVersion.Version), _typeFiles, str(modVersion.GameVersion), modVersion.ReleaseDate,
						   filesRelativePath, licensePath, filesURL)


			_WriteDownload(sourcesPath, sourcesTemplate, basePath,
						   modName, str(modVersion.Version), _typeSources, str(modVersion.GameVersion), modVersion.ReleaseDate,
						   filesRelativePath, licensePath, sourcesURL)

	for modNamespace, modVersions in Distribution.Previews.items():  # type: str, typing.List[Distribution.ModVersion]
		modBuildPath = os.path.join(Paths.DownloadsBuildPath, "Mods", modNamespace)  # type: str

		licensePath = os.path.join(modBuildPath.replace(Paths.DownloadsBuildPath + os.path.sep, ""), _licenseName)  # type: str
		licensePath = licensePath.replace("\\", "/")

		with open(os.path.join(Paths.DownloadsSourcesPath, "mods", modNamespace + ".json")) as modInformationFile:
			modInformation = decoder.JSONDecoder().decode(modInformationFile.read())  # type: dict

		if not modInformation["Mod"]["Age"]:
			modInstallerTemplate = downloadInstallerTemplate  # type: str
			modFilesTemplate = downloadFilesTemplate  # type: str
		else:
			modInstallerTemplate = downloadInstallerAgeTemplate  # type: str
			modFilesTemplate = downloadFilesAgeTemplate  # type: str

		if not modInformation["Sources"]["Age"]:
			sourcesTemplate = downloadSourcesTemplate  # type: str
		else:
			sourcesTemplate = downloadSourcesAgeTemplate  # type: str

		mod = Mods.GetMod(modNamespace)  # type: Mods.Mod
		modName = mod.GetName()  # type: typing.Optional[str]

		for modVersion in modVersions:  # type: Distribution.ModVersion
			versionBuildPath = os.path.join(modBuildPath, str(modVersion.Version), modVersion.ConcealerFolderName)

			basePath = os.path.relpath(Paths.DownloadsBuildPath, versionBuildPath).replace("\\", "/") + "/.."  # type: str
			installerPath = os.path.join(versionBuildPath, "installer/index.html")  # type: str
			installerURL = modVersion.InstallerURL  # type: str
			filesPath = os.path.join(versionBuildPath, "files/index.html")  # type: str
			filesRelativePath = os.path.relpath(filesPath, Paths.DownloadsBuildPath)  # type: str
			filesURL = modVersion.FilesURL  # type: str
			sourcesPath = os.path.join(versionBuildPath, "sources/index.html")  # type: str
			sourcesURL = modVersion.SourcesURL  # type: str

			_WriteDownload(installerPath, modInstallerTemplate, basePath,
						   modName, str(modVersion.Version), _typeFiles, str(modVersion.GameVersion), modVersion.ReleaseDate,
						   filesRelativePath, licensePath, installerURL)


			_WriteDownload(filesPath, modFilesTemplate, basePath,
						   modName, str(modVersion.Version), _typeFiles, str(modVersion.GameVersion), modVersion.ReleaseDate,
						   filesRelativePath, licensePath, filesURL)


			_WriteDownload(sourcesPath, sourcesTemplate, basePath,
						   modName, str(modVersion.Version), _typeSources, str(modVersion.GameVersion), modVersion.ReleaseDate,
						   filesRelativePath, licensePath, sourcesURL)
예제 #8
0
def PublishModRelease(modNamespace: str) -> None:
    print("Publishing mod '" + modNamespace + "' as a release.")

    if Paths.DistributionReleasesPath is None:
        raise Exception(
            "No distribution release path has been specified via automation settings."
        )

    mod = Mods.GetMod(modNamespace)  # type: Mods.Mod
    modDirectoryPath = Mods.GetModPath(modNamespace)  # type: str

    version = mod.GetVersion()  # type: typing.Optional[str]

    installerFilePath = mod.GetInstallerFilePath(
    )  # type: typing.Optional[str]
    filesFilePath = mod.GetFilesFilePath()  # type: typing.Optional[str]
    sourcesFileName = mod.GetSourcesFileName()  # type: typing.Optional[str]

    if version is None:
        raise Exception(
            "Couldn't get the current version number for this mod.")

    if installerFilePath is None:
        raise Exception(
            "Couldn't get the current installer file path for this mod.")

    if filesFilePath is None:
        raise Exception(
            "Couldn't get the current files file path for this mod.")

    if sourcesFileName is None:
        raise Exception(
            "Couldn't get the current sources file name for this mod.")

    distributionVersionDirectoryPath = os.path.join(
        Paths.DistributionReleasesPath, modNamespace.lower(),
        version)  # type: str
    distributionInstallerDirectoryPath = os.path.join(
        distributionVersionDirectoryPath, "installer")  # type: str
    distributionFilesDirectoryPath = os.path.join(
        distributionVersionDirectoryPath, "files")  # type: str
    distributionSourcesDirectoryPath = os.path.join(
        distributionVersionDirectoryPath, "sources")  # type: str

    if os.path.exists(distributionVersionDirectoryPath):
        dir_util.remove_tree(distributionVersionDirectoryPath, verbose=1)

    os.makedirs(distributionInstallerDirectoryPath)
    os.makedirs(distributionFilesDirectoryPath)
    os.makedirs(distributionSourcesDirectoryPath)

    file_util.copy_file(installerFilePath,
                        distributionInstallerDirectoryPath,
                        preserve_times=0)
    file_util.copy_file(filesFilePath,
                        distributionFilesDirectoryPath,
                        preserve_times=0)

    sourcesIncludedPaths = GetIncludedPaths(
        Paths.StrippingModsFilePath,
        Mods.GetModPath(modNamespace))  # type: typing.List[str]

    archiveFile = zipfile.ZipFile(
        os.path.join(distributionSourcesDirectoryPath, sourcesFileName),
        mode="w",
        compression=zipfile.ZIP_DEFLATED)  # type: zipfile.ZipFile

    for sourcesIncludedPath in sourcesIncludedPaths:  # type: str
        archiveFile.write(os.path.join(modDirectoryPath, sourcesIncludedPath),
                          arcname=sourcesIncludedPath)

    archiveFile.close()

    with open(
            os.path.join(distributionVersionDirectoryPath, "information.json"),
            "w+") as versionInformationFile:
        versionInformationFile.write(
            encoder.JSONEncoder(indent="\t").encode({
                "Game Version":
                S4.Version,
                "Release Date":
                datetime.datetime.now().date().isoformat()
            }))