Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP implement offline mode for installer #213

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions cacheDownloadSizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def customPrint(*args, **kwargs):

return [x for x in allURLsSet.keys() if x is not None]

def generateCachedDownloadSizes():
def generateCachedInstallerFiles():
#setup globals necessary for download
common.Globals.scanForExecutables()

Expand All @@ -69,6 +69,7 @@ def queryAndPrint(url):
return url, res

# Only works on python 3
urlToListOfExtractableItemAsDict = {} # type: dict[str, list[dict[str, typing.Any]]]
urlToFileSizeDict = {}
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
results = executor.map(queryAndPrint, allURLs)
Expand All @@ -80,9 +81,30 @@ def queryAndPrint(url):
urlToFileSizeDict[url] = totalSize
print(url, extractableItemList)

# Convert extractable item list to a custom list of dicts
listOfExtractableItemAsDict = [] # type: list[dict[str, typing.Any]]
for extractableItem in extractableItemList:
extractableItemAsDict = {
"f" : extractableItem.filename,
"l" : extractableItem.length,
"m" : extractableItem.fromMetaLink,
"r" : extractableItem.remoteLastModified,
}

if extractableItem.fileURL != url:
extractableItemAsDict["u"] = extractableItem.fileURL

listOfExtractableItemAsDict.append(extractableItemAsDict)

urlToListOfExtractableItemAsDict[url] = listOfExtractableItemAsDict

with io.open('cachedDownloadSizes.json', 'w', encoding='utf-8') as file:
file.write(json.dumps(urlToFileSizeDict, indent=4, sort_keys=True))
file.write(json.dumps(urlToFileSizeDict, indent=0, sort_keys=True))

with io.open('cachedExtractableItems.json', 'w', encoding='utf-8') as file:
file.write(json.dumps(urlToListOfExtractableItemAsDict, indent=0, sort_keys=True))

if __name__ == '__main__':
generateCachedDownloadSizes()
# test = getAllExtractableItemsFromJSON("test extract path")
# print('hello')
generateCachedInstallerFiles()
422 changes: 211 additions & 211 deletions cachedDownloadSizes.json

Large diffs are not rendered by default.

Loading