mirror of
https://github.com/timsutton/brigadier.git
synced 2024-09-18 18:58:45 -04:00
Requests for 7zip (#76)
* Add option in downloadFile to use requests, so it'll pull in certifi * Add requirements for requests, freeze all deps
This commit is contained in:
parent
35b074b451
commit
0db4e9dbf0
3 changed files with 28 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2.5
|
||||
0.2.6
|
||||
|
|
16
brigadier
16
brigadier
|
@ -11,12 +11,13 @@ import shutil
|
|||
import optparse
|
||||
import datetime
|
||||
import platform
|
||||
import requests
|
||||
|
||||
from pprint import pprint
|
||||
from urllib import urlretrieve
|
||||
from xml.dom import minidom
|
||||
|
||||
VERSION = '0.2.5'
|
||||
VERSION = '0.2.6'
|
||||
SUCATALOG_URL = 'https://swscan.apple.com/content/catalogs/others/index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog'
|
||||
# 7-Zip MSI (15.14)
|
||||
SEVENZIP_URL = 'https://www.7-zip.org/a/7z2201-x64.msi'
|
||||
|
@ -45,7 +46,7 @@ def getMachineModel():
|
|||
model = plist[0]['_items'][0]['machine_model']
|
||||
return model
|
||||
|
||||
def downloadFile(url, filename):
|
||||
def downloadFile(url, filename, use_requests=False):
|
||||
# http://stackoverflow.com/questions/13881092/
|
||||
# download-progressbar-for-python-3/13895723#13895723
|
||||
def reporthook(blocknum, blocksize, totalsize):
|
||||
|
@ -60,6 +61,15 @@ def downloadFile(url, filename):
|
|||
else: # total size is unknown
|
||||
sys.stderr.write("read %d\n" % (readsofar,))
|
||||
|
||||
if use_requests:
|
||||
resp = requests.get(url, stream=True)
|
||||
with open(filename, 'wb') as fd:
|
||||
for chunk in resp.iter_content(chunk_size=1024):
|
||||
fd.write(chunk)
|
||||
return
|
||||
|
||||
# urlretrieve method will likely just go away soon, and we'll use only requests
|
||||
# with some kind of report/progress output
|
||||
urlretrieve(url, filename, reporthook=reporthook)
|
||||
|
||||
def sevenzipExtract(arcfile, command='e', out_dir=None):
|
||||
|
@ -287,7 +297,7 @@ when running the installer out of 'system32'." % output_dir)
|
|||
if not os.path.exists(sevenzip_binary):
|
||||
tempdir = tempfile.mkdtemp()
|
||||
sevenzip_msi_dl_path = os.path.join(tempdir, SEVENZIP_URL.split('/')[-1])
|
||||
downloadFile(SEVENZIP_URL, sevenzip_msi_dl_path)
|
||||
downloadFile(SEVENZIP_URL, sevenzip_msi_dl_path, use_requests=True)
|
||||
status("Downloaded 7-zip to %s." % sevenzip_msi_dl_path)
|
||||
status("We need to install 7-Zip..")
|
||||
retcode = subprocess.call(['msiexec', '/qn', '/i', sevenzip_msi_dl_path])
|
||||
|
|
|
@ -1 +1,14 @@
|
|||
pyinstaller==3.6
|
||||
# pyinstaller
|
||||
altgraph==0.17.3
|
||||
dis3==0.1.3
|
||||
future==0.18.2
|
||||
pefile==2019.4.18
|
||||
PyInstaller==3.6
|
||||
pywin32-ctypes==0.2.0
|
||||
|
||||
# requests
|
||||
certifi==2021.10.8
|
||||
chardet==4.0.0
|
||||
idna==2.10
|
||||
requests==2.27.1
|
||||
urllib3==1.26.12
|
||||
|
|
Loading…
Reference in a new issue