Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclary committed Jul 31, 2024
1 parent c250527 commit 313ab69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion installers-conda/build-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies:
- constructor =3.8.1
- gitpython
- mamba
- menuinst =2.1.1
- menuinst =2.1.0
- ruamel.yaml.jinja2
- setuptools_scm
9 changes: 6 additions & 3 deletions spyder/plugins/updatemanager/widgets/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def __init__(self, parent):
self.download_thread = None
self.download_worker = None
self.progress_dialog = None
self.installer_dir = None
self.installer_paths = None

# ---- General
Expand Down Expand Up @@ -257,9 +258,11 @@ def _set_installer_paths(self):
'runtime': {'file': f'conda-runtime-{plat}-{mach}.lock'},
}

dirname = osp.join(get_temp_dir(), 'updates', self.latest_release)
self.installer_dir = osp.join(
get_temp_dir(), 'updates', self.latest_release
)
for v in self.installer_paths.values():
v['file'] = osp.join(dirname, v['file']) # Full path
v['file'] = osp.join(self.installer_dir, v['file']) # Full path
v['size'] = osp.splitext(v['file'])[0] + '-size' # Add size file

# ---- Download Update
Expand Down Expand Up @@ -332,7 +335,7 @@ def _start_download(self):
self.progress_dialog = None

self.download_worker = WorkerDownloadInstaller(
self.latest_release, self.installer_paths
self.latest_release, self.installer_dir, self.installer_paths
)

self.sig_disable_actions.emit(True)
Expand Down
12 changes: 7 additions & 5 deletions spyder/plugins/updatemanager/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,15 @@ class WorkerDownloadInstaller(BaseWorker):
Total size of the file expected to be downloaded.
"""

def __init__(self, latest_release, installer_paths):
def __init__(self, latest_release, installer_dir, installer_paths):
super().__init__()
self.latest_release = latest_release
self.installer_dir = installer_dir
self.installer_paths = installer_paths
self.error = None
self.cancelled = False
self.paused = False

self.installer_dir = osp.dirname(
next(iter(installer_paths.values()))['file']
)

def _progress_reporter(self, progress, total_size):
"""Calculate download progress and notify."""
self.sig_download_progress.emit(progress, total_size)
Expand All @@ -255,6 +252,11 @@ def _download_installer(self):
"""Donwload Spyder installer."""
os.makedirs(self.installer_dir, exist_ok=True)

# self.installer_paths is a dictionary of download types: "installer"
# or "base" and "runtime". Each download type is a dictionary of
# string paths: "file" is the download destination and "size" is the
# file in which to store the size of the downloaded file for
# verification.
for v in self.installer_paths.values():
url = (
"https://github.com/spyder-ide/spyder/releases/download/"
Expand Down

0 comments on commit 313ab69

Please sign in to comment.