Skip to content

Commit 45d07e3

Browse files
committed
updated qt wizard
1 parent 302bcc6 commit 45d07e3

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

‎src/ffmpeg_downloader/qt/wizard.py‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
logger = logging.getLogger(__name__)
44
logger.addHandler(logging.NullHandler())
55

6-
from tempfile import mkdtemp
6+
from os import path
77
from shutil import rmtree
8+
from tempfile import mkdtemp
9+
from typing import Any, Optional
10+
11+
from PyQt6.QtWidgets import QWizard
812
from tqdm.utils import CallbackIOWrapper
9-
from typing import Optional, Any
10-
from os import path
1113

1214
from .. import _backend as ffdl
13-
from .qt_compat import QtCore, QtWidgets, QtGui
14-
15-
from PyQt6.QtWidgets import QWizard
15+
from .qt_compat import QtCore, QtGui, QtWidgets
1616

1717
QObject = QtCore.QObject
1818
QThread = QtCore.QThread
@@ -52,7 +52,7 @@ def update(self, nread):
5252
self.progress.emit(self.last)
5353

5454
def done(self):
55-
logger.debug(f"progress: done")
55+
logger.debug("progress: done")
5656
self.progress.emit(self.size)
5757

5858

@@ -64,7 +64,7 @@ def io_wrapper(self, fi):
6464
class FFmpegInstaller(QObject):
6565
found_installed_version = pyqtSignal(str, bool)
6666
"""version/done"""
67-
found_latest_version = pyqtSignal(tuple, bool)
67+
found_latest_version = pyqtSignal(str, bool)
6868
"""version/done, if bool=False, wait for response via queue"""
6969
server_error = pyqtSignal(str)
7070
"""str-exception message"""
@@ -101,10 +101,10 @@ def search(self, upgrade: bool, request_kws: dict[str, Any]):
101101
return
102102

103103
try:
104-
version = ffdl.search(
104+
build = ffdl.search(
105105
version_spec=None, auto_select=True, force=True, **request_kws
106106
)
107-
if version is None:
107+
if build is None:
108108
raise RuntimeError("Could not find a suitable FFMpeg version.")
109109
except Exception as e:
110110
self.server_error.emit(str(e))
@@ -113,20 +113,20 @@ def search(self, upgrade: bool, request_kws: dict[str, Any]):
113113

114114
# check for a need to update
115115
already_exists = current_version is not None and (
116-
current_version[0] == version[0]
116+
current_version[0] == build.version
117117
)
118118

119-
self.found_latest_version.emit(version, already_exists)
119+
self.found_latest_version.emit(str(build.version), already_exists)
120120
if already_exists:
121121
self.finished.emit()
122122

123-
@pyqtSlot(tuple, bool, dict)
124-
def install(self, version: tuple, exists: bool, request_kws: dict):
123+
@pyqtSlot(str, bool, dict)
124+
def install(self, version: str, exists: bool, request_kws: dict):
125125
# import debugpy
126126
# debugpy.debug_this_thread()
127127
logger.debug(f"install: begin installing v{version[0]}")
128128

129-
download_info = ffdl.gather_download_info(*version, no_cache_dir=True)
129+
download_info = ffdl.search(f"={version}", auto_select=True)
130130

131131
dl_mon = DownloadProgress(self, False, self.download_progress)
132132
in_mon = InstallProgress(self, True, self.install_progress)
@@ -173,7 +173,7 @@ def installProgress(sz):
173173

174174
class InstallFFmpegWizard(QWizard):
175175
req_search = pyqtSignal(bool, dict)
176-
req_install = pyqtSignal(tuple, bool, dict)
176+
req_install = pyqtSignal(str, bool, dict)
177177

178178
default_labels = {
179179
"search_current": "Searching for a local copy of the FFmpeg, a multimedia processing library...",
@@ -219,7 +219,7 @@ def __init__(
219219
"timeout": timeout,
220220
}
221221
self.old_ver_exists: bool = False
222-
self.version: tuple = None # set by Page1, used by Page2
222+
self.version: str = None # set by Page1, used by Page2
223223
self.install_finished: bool = False
224224

225225
self.setWindowTitle(window_title or "FFmpeg Download & Install Wizard")
@@ -288,8 +288,8 @@ def _found_installed_version(self, ver: str, done: bool):
288288
if done:
289289
self.install_finished = True
290290

291-
@pyqtSlot(tuple, bool)
292-
def _found_latest_version(self, ver: tuple, done: bool):
291+
@pyqtSlot(str, bool)
292+
def _found_latest_version(self, ver: str, done: bool):
293293
self.version = ver
294294
if done:
295295
self.install_finished = True
@@ -370,7 +370,7 @@ def _found_installed_version(self, ver, done):
370370
else:
371371
self.latest_ver_label.setText(self.labels["search_latest"])
372372

373-
@pyqtSlot(tuple, bool)
373+
@pyqtSlot(str, bool)
374374
def _found_latest_version(self, ver, done):
375375
self.complete = True
376376
self.latest_ver_label.setText(self.labels["latest_ver"].format(ver[0]))

0 commit comments

Comments
 (0)