mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Fix Mypy warnings
CURA-6983
This commit is contained in:
parent
6aba835c1c
commit
53115dc3b2
4 changed files with 11 additions and 9 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from cura import ApplicationMetadata, UltimakerCloudAuthentication
|
from cura import ApplicationMetadata, UltimakerCloudAuthentication
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class DownloadPresenter:
|
||||||
self._scope = UltimakerCloudScope(app)
|
self._scope = UltimakerCloudScope(app)
|
||||||
|
|
||||||
self._started = False
|
self._started = False
|
||||||
self._progress_message = None # type: Optional[Message]
|
self._progress_message = self._createProgressMessage()
|
||||||
self._progress = {} # type: Dict[str, Dict[str, Any]] # package_id, Dict
|
self._progress = {} # type: Dict[str, Dict[str, Any]] # package_id, Dict
|
||||||
self._error = [] # type: List[str] # package_id
|
self._error = [] # type: List[str] # package_id
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class DownloadPresenter:
|
||||||
}
|
}
|
||||||
|
|
||||||
self._started = True
|
self._started = True
|
||||||
self._showProgressMessage()
|
self._progress_message.show()
|
||||||
|
|
||||||
def abort(self):
|
def abort(self):
|
||||||
manager = HttpRequestManager.getInstance()
|
manager = HttpRequestManager.getInstance()
|
||||||
|
@ -70,15 +70,14 @@ class DownloadPresenter:
|
||||||
self.done.disconnectAll()
|
self.done.disconnectAll()
|
||||||
return DownloadPresenter(self._app)
|
return DownloadPresenter(self._app)
|
||||||
|
|
||||||
def _showProgressMessage(self):
|
def _createProgressMessage(self) -> Message:
|
||||||
self._progress_message = Message(i18n_catalog.i18nc(
|
return Message(i18n_catalog.i18nc(
|
||||||
"@info:generic",
|
"@info:generic",
|
||||||
"\nSyncing..."),
|
"\nSyncing..."),
|
||||||
lifetime = 0,
|
lifetime = 0,
|
||||||
use_inactivity_timer=False,
|
use_inactivity_timer=False,
|
||||||
progress = 0.0,
|
progress = 0.0,
|
||||||
title = i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
|
title = i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
|
||||||
self._progress_message.show()
|
|
||||||
|
|
||||||
def _onFinished(self, package_id: str, reply: QNetworkReply):
|
def _onFinished(self, package_id: str, reply: QNetworkReply):
|
||||||
self._progress[package_id]["received"] = self._progress[package_id]["total"]
|
self._progress[package_id]["received"] = self._progress[package_id]["total"]
|
||||||
|
@ -110,7 +109,7 @@ class DownloadPresenter:
|
||||||
|
|
||||||
self._progress_message.setProgress(100.0 * (received / total)) # [0 .. 100] %
|
self._progress_message.setProgress(100.0 * (received / total)) # [0 .. 100] %
|
||||||
|
|
||||||
def _onError(self, package_id: str):
|
def _onError(self, package_id: str) -> None:
|
||||||
self._progress.pop(package_id)
|
self._progress.pop(package_id)
|
||||||
self._error.append(package_id)
|
self._error.append(package_id)
|
||||||
self._checkDone()
|
self._checkDone()
|
||||||
|
@ -125,3 +124,4 @@ class DownloadPresenter:
|
||||||
|
|
||||||
self._progress_message.hide()
|
self._progress_message.hide()
|
||||||
self.done.emit(success_items, error_items)
|
self.done.emit(success_items, error_items)
|
||||||
|
return True
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional, List
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtSlot
|
from PyQt5.QtCore import QObject, pyqtSlot
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class LicensePresenter(QObject):
|
||||||
self.licenseAnswers = Signal()
|
self.licenseAnswers = Signal()
|
||||||
|
|
||||||
self._current_package_idx = 0
|
self._current_package_idx = 0
|
||||||
self._package_models = None # type: Optional[Dict]
|
self._package_models = [] # type: List[Dict]
|
||||||
self._license_model = LicenseModel() # type: LicenseModel
|
self._license_model = LicenseModel() # type: LicenseModel
|
||||||
|
|
||||||
self._app = app
|
self._app = app
|
||||||
|
|
|
@ -70,7 +70,7 @@ class SyncOrchestrator(Extension):
|
||||||
self._license_presenter.present(plugin_path, success_items)
|
self._license_presenter.present(plugin_path, success_items)
|
||||||
|
|
||||||
# Called when user has accepted / declined all licenses for the downloaded packages
|
# Called when user has accepted / declined all licenses for the downloaded packages
|
||||||
def _onLicenseAnswers(self, answers: [Dict[str, Any]]):
|
def _onLicenseAnswers(self, answers: List[Dict[str, Any]]):
|
||||||
Logger.debug("Got license answers: {}", answers)
|
Logger.debug("Got license answers: {}", answers)
|
||||||
|
|
||||||
has_changes = False # True when at least one package is installed
|
has_changes = False # True when at least one package is installed
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue