add installer downloader by version or url

This commit is contained in:
reloxx13
2022-05-24 23:34:22 +02:00
parent ac97e5647f
commit df3d32ee96
4 changed files with 194 additions and 0 deletions

View File

@@ -105,3 +105,11 @@ venv.bak/
# mypy
.mypy_cache/
# APP
# dont commit 7zip files 7z.dll 7z.exe
7z.*
temp
!.gitempty

View File

@@ -13,6 +13,14 @@ Note: when command line options with multiple possible arguments supplied (like
* Python 3.2+
* 7zip CLI utility
* 7z.exe and 7z.dll are required, next to autopatch.py or set path with parameter
## Examples
```
python.exe autopatch.py temp/512.95-desktop-win10-win11-64bit-international-dch-whql.exe
python.exe autopatch.py https://international.download.nvidia.com/Windows/512.95/512.95-desktop-win10-win11-64bit-international-dch-whql.exe
python.exe autopatch.py 512.95
```
## Synopsys

View File

@@ -9,6 +9,7 @@ from binascii import unhexlify
import xml.etree.ElementTree as ET
import itertools
import functools
import urllib.request
CRLF = b"\x0d\x0a"
@@ -193,6 +194,21 @@ def patch_flow(installer_file, search, replacement, target, target_name, patch_n
replacement = unhexlify(replacement)
assert len(search) == len(replacement), "len() of search and replacement"\
" is not equal"
# check if installer file exists or try to download
if not os.path.isfile(installer_file): #installer file does not exists, get url for download
if not installer_file.startswith("http"): #installer_file is a version, parse to url
filename = installer_file+"-desktop-win10-win11-64bit-international-dch-whql.exe"
installer_file = "https://international.download.nvidia.com/Windows/"+installer_file+"/"+filename
else: # installer_file is an url
filename = os.path.basename(installer_file)
# download installer and save in .temp
print(f"Downloading... ( {installer_file} TO {os.path.join('temp', filename)} )")
print("This may take a while (~800MB)")
urllib.request.urlretrieve(installer_file, os.path.join('temp', filename))
installer_file = os.path.join('temp', filename)
patch = make_patch(installer_file,
arch_tgt=target,
search=search,