More fixes
Some checks failed
Test and docs / test (3.10) (push) Has been cancelled
Test and docs / test (3.11) (push) Has been cancelled
Test and docs / test (3.12) (push) Has been cancelled
Test and docs / test (3.7) (push) Has been cancelled
Test and docs / test (3.8) (push) Has been cancelled
Test and docs / test (3.9) (push) Has been cancelled
Test and docs / build-docs (push) Has been cancelled
Some checks failed
Test and docs / test (3.10) (push) Has been cancelled
Test and docs / test (3.11) (push) Has been cancelled
Test and docs / test (3.12) (push) Has been cancelled
Test and docs / test (3.7) (push) Has been cancelled
Test and docs / test (3.8) (push) Has been cancelled
Test and docs / test (3.9) (push) Has been cancelled
Test and docs / build-docs (push) Has been cancelled
This commit is contained in:
parent
f0136b89f1
commit
f4b1b41431
2
setup.py
2
setup.py
@ -1,7 +1,7 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(name="updater",
|
||||
version="0.3.1",
|
||||
version="0.3.2",
|
||||
author="MCVSoftware",
|
||||
author_email="support@mcvsoftware.com",
|
||||
url="https://github.com/mcvsoftware/updater",
|
||||
|
@ -98,11 +98,18 @@ class UpdaterCore(object):
|
||||
:returns: The update file path in the system.
|
||||
:rtype: str
|
||||
"""
|
||||
def _download_callback(transferred_blocks, block_size, total_size):
|
||||
total_downloaded = transferred_blocks*block_size
|
||||
pub.sendMessage("updater.update-progress", total_downloaded=total_downloaded, total_size=total_size)
|
||||
request = urllib.request.Request(update_url, headers={"User-Agent": f"{self.app_name}/{self.current_version}"})
|
||||
filename, headers = urllib.request.urlretrieve(request, update_destination, _download_callback)
|
||||
with urllib.request.urlopen(request) as response:
|
||||
total_size = int(response.headers.get("Content-Length", -1))
|
||||
downloaded_size = 0
|
||||
with open(update_destination, "wb") as out_file:
|
||||
while True:
|
||||
chunk = response.read(chunk_size)
|
||||
if not chunk:
|
||||
break
|
||||
out_file.write(chunk)
|
||||
downloaded_size += len(chunk)
|
||||
pub.sendMessage("updater.update-progress", total_downloaded=downloaded_size, total_size=total_size)
|
||||
log.debug("Update downloaded")
|
||||
return update_destination
|
||||
|
||||
|
@ -131,7 +131,7 @@ class WXUpdater(core.UpdaterCore):
|
||||
if total_downloaded == total_size:
|
||||
self.progress_dialog.Destroy()
|
||||
else:
|
||||
self.progress_dialog.Update((total_downloaded*100)/total_size, self.update_progress_msg.format(total_downloaded=utils.convert_bytes(total_downloaded), total_size=utils.convert_bytes(total_size)))
|
||||
self.progress_dialog.Update(int((total_downloaded*100)/total_size), self.update_progress_msg.format(total_downloaded=utils.convert_bytes(total_downloaded), total_size=utils.convert_bytes(total_size)))
|
||||
self.progress_dialog.SetTitle(self.update_progress_msg.format(total_downloaded=utils.convert_bytes(total_downloaded), total_size=utils.convert_bytes(total_size)))
|
||||
|
||||
def on_update_almost_complete(self) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user