Skip to content

Commit 546c180

Browse files
committed
Improve steamgrid extraction
- do not attempt to extract to files, only folders (previously a file called 'config' would attempt to be extracted to) - continue extracting to each user data folder, even if an exception occurs on one folder - make log output more clear and log more data
1 parent 3afc5b6 commit 546c180

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

steamGridExtractor.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,60 @@ def getSteamPath():
3636
def getUserDataFolders():
3737
steamPath = getSteamPath()
3838

39-
print("steamGridExtractor: Attempting to install steamgrid icons to [{}]".format(steamPath))
39+
print("steamGridExtractor.getUserDataFolders: Looking for user data folders inside [{}]".format(steamPath))
4040

4141
if steamPath:
4242
if not os.path.exists(steamPath):
43-
print("steamGridExtractor: WARNING: steamPath [{}] does not exist! steamGrid extraction will probably fail!".format(steamPath))
43+
print("steamGridExtractor.getUserDataFolders: WARNING: steamPath [{}] does not exist! steamGrid extraction will probably fail!".format(steamPath))
4444

45-
return glob.glob(
45+
maybePaths = glob.glob(
4646
os.path.join(steamPath, "userdata", "**", "config"), recursive=True
4747
)
48+
49+
# Only return folders, not files called 'config'
50+
return list(filter(os.path.isdir, maybePaths))
4851
else:
4952
return None
5053

5154

5255
def extractSteamGrid(downloadDir):
56+
commandLineParser.printSeventhModStatusUpdate(98, "Downloading and Extracting Steam Grid")
57+
58+
# Try to find/guess the steam user data folder where the steam grid assets should be extracted
59+
userDataFolders = None
5360
try:
5461
userDataFolders = getUserDataFolders()
62+
except Exception as e:
63+
print("steamGridExtractor.extractSteamGrid: Failed to get Steam User Data folders (where steamgrid extracted): {}".format(e))
5564

56-
commandLineParser.printSeventhModStatusUpdate(98, "Downloading and Extracting Steam Grid")
57-
print("Downloading and Extracting Steam Grid Icons to {}".format(userDataFolders))
65+
if not userDataFolders:
66+
print("steamGridExtractor.extractSteamGrid: WARNING: not extracting steamgrid icons as no steam user data folders found")
67+
return
5868

69+
print("steamGridExtractor.extractSteamGrid: Found {} Steam User Data folders: {}".format(len(userDataFolders), userDataFolders))
70+
71+
# Download the steamgrid assets
72+
try:
73+
steamGridURL = "https://github.com/07th-mod/patch-releases/releases/download/mod-common-v1.0/higumi-steamgrid.zip"
74+
75+
print("steamGridExtractor.extractSteamGrid: Downloading Steam Grid Icons from [{}]...".format(steamGridURL))
5976
downloaderAndExtractor = common.DownloaderAndExtractor(modFileList=[],
6077
downloadTempDir=downloadDir,
6178
extractionDir=downloadDir,
6279
supressDownloadStatus=True)
63-
downloaderAndExtractor.addItemManually(url="https://github.com/07th-mod/patch-releases/releases/download/mod-common-v1.0/higumi-steamgrid.zip",
80+
downloaderAndExtractor.addItemManually(url=steamGridURL,
6481
extractionDir=downloadDir)
6582
downloaderAndExtractor.download()
83+
except Exception as e:
84+
print("steamGridExtractor.extractSteamGrid: Steamgrid Installation - Failed to download steamgrid assets zip file: {}".format(e))
6685

67-
# Extract to each steam user's data folder (steam has one folder per user)
68-
if userDataFolders:
69-
for i in userDataFolders:
70-
shutil.unpack_archive(os.path.join(downloadDir, "higumi-steamgrid.zip"), i)
71-
else:
72-
print("steamGridExtractor: WARNING: not extracting steamgrid icons as no steam user data folders found")
86+
# Extract to each found user's data folder (steam has one folder per user)
87+
for i in userDataFolders:
88+
try:
89+
print("steamGridExtractor.extractSteamGrid: Extracting Steam Grid Icons to [{}]...".format(i), end="")
90+
print("OK")
91+
shutil.unpack_archive(os.path.join(downloadDir, "higumi-steamgrid.zip"), i)
92+
except Exception as e:
93+
print("ERROR")
94+
print("steamGridExtractor.extractSteamGrid: Warning - failed to extract to [{}], but other paths may work. Error: {}".format(i, e))
7395

74-
except Exception as e:
75-
print("Steamgrid Installation Failed: {}".format(e))

0 commit comments

Comments
 (0)