Fix update_3rdparty on windows
You cannot open a file twice on windows, so the call to urllib.request.urlretrieve was invalid, since we already opened the temporary file. urlretrieve without a filename will automatically create and return a temp-file, so we're fine.
This commit is contained in:
parent
384a9ad923
commit
a072cf0175
@ -47,14 +47,15 @@ def update_pdfjs():
|
||||
version, url = get_latest_pdfjs_url()
|
||||
target_path = os.path.join('qutebrowser', '3rdparty', 'pdfjs')
|
||||
print("=> Downloading pdf.js {}".format(version))
|
||||
with tempfile.NamedTemporaryFile(prefix='qute-pdfjs-') as archive:
|
||||
urllib.request.urlretrieve(url, archive.name)
|
||||
if os.path.isdir(target_path):
|
||||
print("Removing old version in {}".format(target_path))
|
||||
shutil.rmtree(target_path)
|
||||
os.makedirs(target_path)
|
||||
print("Extracting new version")
|
||||
(archive_path, _headers) = urllib.request.urlretrieve(url)
|
||||
if os.path.isdir(target_path):
|
||||
print("Removing old version in {}".format(target_path))
|
||||
shutil.rmtree(target_path)
|
||||
os.makedirs(target_path)
|
||||
print("Extracting new version")
|
||||
with open(archive_path, 'rb') as archive:
|
||||
shutil.unpack_archive(archive, target_path, 'zip')
|
||||
urllib.request.urlcleanup()
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user