Fix typing in the FirmwareUpdateChecker plugin.

This commit is contained in:
Remco Burema 2018-10-11 21:54:27 +02:00
parent 839016d2f3
commit f2b50c748c
3 changed files with 28 additions and 21 deletions

View file

@ -1,10 +1,12 @@
# Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import json, os
import os
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QDesktopServices
from typing import List
from UM.Extension import Extension
from UM.Application import Application
from UM.Logger import Logger
@ -19,12 +21,13 @@ from .FirmwareUpdateCheckerLookup import FirmwareUpdateCheckerLookup, get_settin
i18n_catalog = i18nCatalog("cura")
## This Extension checks for new versions of the firmware based on the latest checked version number.
# The plugin is currently only usable for applications maintained by Ultimaker. But it should be relatively easy
# to change it to work for other applications.
class FirmwareUpdateChecker(Extension):
def __init__(self):
def __init__(self) -> None:
super().__init__()
# Listen to a Signal that indicates a change in the list of printers, just if the user has enabled the
@ -36,7 +39,8 @@ class FirmwareUpdateChecker(Extension):
self._late_init = True # Init some things after creation, since we need the path from the plugin-mgr.
self._download_url = None
self._check_job = None
self._name_cache = []
self._name_cache = [] # type: List[str]
self._lookups = None
## Callback for the message that is spawned when there is a new version.
def _onActionTriggered(self, message, action):
@ -46,8 +50,8 @@ class FirmwareUpdateChecker(Extension):
QDesktopServices.openUrl(QUrl(download_url))
else:
Logger.log('e', "Can't find URL for {0}".format(action))
except:
Logger.log('e', "Don't know what to do with {0}".format(action))
except Exception as ex:
Logger.log('e', "Don't know what to do with '{0}' because {1}".format(action, ex))
def _onContainerAdded(self, container):
# Only take care when a new GlobalStack was added