Skip to content

Commit

Permalink
Suppress most printing on 'validateOnly' installs to avoid confusing …
Browse files Browse the repository at this point in the history
…log messages
  • Loading branch information
drojf committed Sep 5, 2020
1 parent beda9cd commit 5ec0812
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 27 deletions.
23 changes: 14 additions & 9 deletions fileVersionManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def userDidPartialReinstall(self, gameInstallTimeProbePath):
Could possibly return True if user has been messing/copying their game folder around
"""
if not os.path.exists(self.localVersionFilePath) or not os.path.exists(gameInstallTimeProbePath):
print("userDidPartialReinstall: localVersionFilePath or gameInstallTimeProbePath was missing - assuming no partial reinstall")
if self.verbosePrinting:
print("userDidPartialReinstall: localVersionFilePath or gameInstallTimeProbePath was missing - assuming no partial reinstall")
return False

# If the game was installed AFTER when the mod was applied, user has probably partially re-installed the game
Expand All @@ -41,8 +42,9 @@ def userDidPartialReinstall(self, gameInstallTimeProbePath):
# For the version file, the "modified" date is when the game mod was last applied
return os.path.getctime(gameInstallTimeProbePath) > os.path.getmtime(self.localVersionFilePath)

def __init__(self, subMod, modFileList, localVersionFolder, _testRemoteSubModVersion=None):
#type: (installConfiguration.SubModConfig, List[installConfiguration.ModFile], str, Optional[SubModVersionInfo]) -> None
def __init__(self, subMod, modFileList, localVersionFolder, _testRemoteSubModVersion=None, verbosePrinting=True):
#type: (installConfiguration.SubModConfig, List[installConfiguration.ModFile], str, Optional[SubModVersionInfo], bool) -> None
self.verbosePrinting = verbosePrinting
self.targetID = subMod.modName + '/' + subMod.subModName
self.unfilteredModFileList = modFileList
self.localVersionFilePath = os.path.join(localVersionFolder, VersionManager.localVersionFileName)
Expand All @@ -64,8 +66,9 @@ def __init__(self, subMod, modFileList, localVersionFolder, _testRemoteSubModVer
self.remoteVersionInfo = None
print("VersionManager: Error while retrieving remote version information {}".format(error))

logger.printNoTerminal("\nLocal Version: {}".format(self.localVersionInfo))
logger.printNoTerminal("Remote Version: {}".format(self.remoteVersionInfo))
if verbosePrinting:
logger.printNoTerminal("\nLocal Version: {}".format(self.localVersionInfo))
logger.printNoTerminal("Remote Version: {}".format(self.remoteVersionInfo))

# If can't retrieve version info, mark everything as needing update
if self.localVersionInfo is None:
Expand All @@ -80,15 +83,17 @@ def __init__(self, subMod, modFileList, localVersionFolder, _testRemoteSubModVer
# Mark files which need update
self.updatesRequiredDict = getFilesNeedingUpdate(self.unfilteredModFileList, self.localVersionInfo, self.remoteVersionInfo)

print("\nInstaller Update Information:")
for fileID, (needsUpdate, updateReason) in self.updatesRequiredDict.items():
print("[{}]: status: [{}] because [{}]".format(fileID, needsUpdate, updateReason))
if verbosePrinting:
print("\nInstaller Update Information:")
for fileID, (needsUpdate, updateReason) in self.updatesRequiredDict.items():
print("[{}]: status: [{}] because [{}]".format(fileID, needsUpdate, updateReason))

# Check how many updates are required
updatesRequiredList = self.updatesRequiredDict.values()
self.totalNumUpdates = len(updatesRequiredList)
self.numUpdatesRequired = sum([needsUpdate for (needsUpdate, _) in updatesRequiredList])
print("Full Update: {} ({}/{}) excluding mod options".format(self.fullUpdateRequired(), self.numUpdatesRequired, self.totalNumUpdates))
if verbosePrinting:
print("Full Update: {} ({}/{}) excluding mod options".format(self.fullUpdateRequired(), self.numUpdatesRequired, self.totalNumUpdates))

def fullUpdateRequired(self):
return self.numUpdatesRequired == self.totalNumUpdates
Expand Down
23 changes: 14 additions & 9 deletions httpGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ def updateModOptionsFromWebFormat(modOptionsToUpdate, webFormatModOptions):
for checkBoxID in modOptionGroup['selectedCheckBoxes']:
modOptions[checkBoxID].value = True

def getDownloadPreview(fullInstallConfig):
#type: (installConfiguration.FullInstallConfiguration) -> Any
def getDownloadPreview(fullInstallConfig, verbosePrinting=True):
#type: (installConfiguration.FullInstallConfiguration, bool) -> Any
####### Preview which files are going to be downloaded #######

# Higurashi installer needs datadirectory set to determine unity version
Expand All @@ -444,11 +444,13 @@ def getDownloadPreview(fullInstallConfig):
dataDirectory = os.path.join(fullInstallConfig.installPath, fullInstallConfig.subModConfig.dataName)

modFileList = fullInstallConfig.buildFileListSorted(
datadir=dataDirectory) # type: List[installConfiguration.ModFile]
datadir=dataDirectory,
verbosePrinting=verbosePrinting) # type: List[installConfiguration.ModFile]
fileVersionManager = fileVersionManagement.VersionManager(
subMod=fullInstallConfig.subModConfig,
modFileList=modFileList,
localVersionFolder=fullInstallConfig.installPath)
localVersionFolder=fullInstallConfig.installPath,
verbosePrinting=False)

# Check for partial re-install (see https://github.com/07th-mod/python-patcher/issues/93)
if fullInstallConfig.subModConfig.family == 'higurashi':
Expand Down Expand Up @@ -477,7 +479,7 @@ def getDownloadPreview(fullInstallConfig):
scriptNeedsUpdate = True

# Generate rows for the mod option files
parser = installConfiguration.ModOptionParser(fullInstallConfig)
parser = installConfiguration.ModOptionParser(fullInstallConfig, verbosePrinting=False)
for option in parser.downloadAndExtractOptionsByPriority:
downloadSize = common.Globals.URL_FILE_SIZE_LOOKUP_TABLE.get(option.url)
downloadItemsPreview.append((option.name, downloadSize, True, 'Mod options are always downloaded'))
Expand Down Expand Up @@ -754,10 +756,13 @@ def startInstallHandler(requestData):

subMod = self.idToSubMod[id]


updateModOptionsFromWebFormat(subMod.modOptions, webModOptionGroups)
logger.printNoTerminal("\nUser selected options for install:")
for modOption in subMod.modOptions:
logger.printNoTerminal(modOption)

if not validateOnly:
logger.printNoTerminal("\nUser selected options for install:")
for modOption in subMod.modOptions:
logger.printNoTerminal(modOption)

installPath = requestData.get('installPath', None)

Expand All @@ -782,7 +787,7 @@ def startInstallHandler(requestData):
if deleteVersionInformation:
fileVersionManagement.VersionManager.tryDeleteLocalVersionFile(fullInstallConfiguration.installPath)

downloadItemsPreview, totalDownloadSize, numUpdatesRequired, fullUpdateRequired, partialReinstallDetected, scriptNeedsUpdate = getDownloadPreview(fullInstallConfiguration)
downloadItemsPreview, totalDownloadSize, numUpdatesRequired, fullUpdateRequired, partialReinstallDetected, scriptNeedsUpdate = getDownloadPreview(fullInstallConfiguration, verbosePrinting=not allowCache)
haveEnoughFreeSpace, freeSpaceAdvisoryString = common.checkFreeSpace(
installPath = fullInstallConfiguration.installPath,
recommendedFreeSpaceBytes = totalDownloadSize * common.Globals.DOWNLOAD_TO_EXTRACTION_SCALING
Expand Down
22 changes: 13 additions & 9 deletions installConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
pass # Just needed for pycharm comments


def getUnityVersion(datadir):
# type: (str) -> str
def getUnityVersion(datadir, verbosePrinting=True):
# type: (str, bool) -> str
"""
Given the datadir of a Higurashi game (like 'HigurashiEp0X_Data'), returns the unity version of the game
Raises an exeption if:
Expand All @@ -25,7 +25,8 @@ def getUnityVersion(datadir):

with open(assetsbundlePath, "rb") as assetsBundle:
unityVersion = assetsBundle.read(28)[20:].decode("utf-8").rstrip("\0")
print("Unity Version: Read [{}] from [{}]".format(unityVersion, assetsbundlePath))
if verbosePrinting:
print("Unity Version: Read [{}] from [{}]".format(unityVersion, assetsbundlePath))
if int(unityVersion.split('.')[0]) < 5:
raise OldUnityException(unityVersion)
return unityVersion
Expand All @@ -43,15 +44,15 @@ def __init__(self, subModConfig, path, isSteam):
self.installSteamGrid = False

#applies the fileOverrides to the files to
def buildFileListSorted(self, datadir=""):
# type: (str) -> List[ModFile]
def buildFileListSorted(self, datadir="", verbosePrinting=True):
# type: (str, bool) -> List[ModFile]
# convert the files list into a dict
filesDict = {}
for file in self.subModConfig.files:
filesDict[file.name] = file

if datadir:
unityVersion = getUnityVersion(datadir)
unityVersion = getUnityVersion(datadir, verbosePrinting)
else:
unityVersion = None
print("Unity Version: [{}/Not a Unity game]".format(unityVersion))
Expand Down Expand Up @@ -159,15 +160,13 @@ def __init__(self, name, description, url, relativeExtractionPath, priority):


class ModOptionParser:
def __init__(self, fullInstallConfiguration):
def __init__(self, fullInstallConfiguration, verbosePrinting=True):
self.config = fullInstallConfiguration # type: FullInstallConfiguration
self.downloadAndExtractOptionsByPriority = [] # type: List[DownloadAndExtractOption]
self.keepDownloads = False

# Sort according to priority - higher priority items will be extracted later, overwriting lower priority items.
print('MOD OPTIONS:\n')
for modOption in self.config.subModConfig.modOptions:
print(' - {}'.format(modOption))
if modOption.value:
if modOption.type == 'downloadAndExtract' and modOption.data is not None:
self.downloadAndExtractOptionsByPriority.append(
Expand All @@ -182,6 +181,11 @@ def __init__(self, fullInstallConfiguration):
elif modOption.type == 'keepDownloads':
self.keepDownloads = True

if verbosePrinting:
print('MOD OPTIONS:\n')
for modOption in self.config.subModConfig.modOptions:
print(' - {}'.format(modOption))

# Make sure download and extraction options are sorted
self.downloadAndExtractOptionsByPriority.sort(key=lambda opt: opt.priority)

Expand Down

0 comments on commit 5ec0812

Please sign in to comment.