From 0f00895a97430d7db89440f186ad0d14609ed8a9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Jun 2017 14:57:19 +0200 Subject: [PATCH] Code cleanup CURA-3858 --- plugins/SliceInfoPlugin/SliceInfoJob.py | 29 +++++++++---------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfoJob.py b/plugins/SliceInfoPlugin/SliceInfoJob.py index 9944bc9e50..0ef390d058 100644 --- a/plugins/SliceInfoPlugin/SliceInfoJob.py +++ b/plugins/SliceInfoPlugin/SliceInfoJob.py @@ -1,7 +1,5 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. - - from UM.Job import Job from UM.Logger import Logger from UM.Platform import Platform @@ -10,38 +8,31 @@ import ssl import urllib.request import urllib.error -from typing import Any - class SliceInfoJob(Job): - data = None # type: Any - url = None # type: str - def __init__(self, url, data): super().__init__() - self.url = url - self.data = data + self._url = url + self._data = data def run(self): - if not self.url or not self.data: + if not self._url or not self._data: Logger.log("e", "URL or DATA for sending slice info was not set!") return # Submit data - kwoptions = {"data" : self.data, - "timeout" : 5 - } + kwoptions = {"data" : self._data, "timeout" : 5} if Platform.isOSX(): kwoptions["context"] = ssl._create_unverified_context() - Logger.log("d", "Sending anonymous slice info to [%s]...", self.url) + Logger.log("i", "Sending anonymous slice info to [%s]...", self._url) try: - f = urllib.request.urlopen(self.url, **kwoptions) + f = urllib.request.urlopen(self._url, **kwoptions) Logger.log("i", "Sent anonymous slice info.") f.close() - except urllib.error.HTTPError as http_exception: - Logger.log("e", "An HTTP error occurred while trying to send slice information: %s" % http_exception) - except Exception as e: # We don't want any exception to cause problems - Logger.log("e", "An exception occurred while trying to send slice information: %s" % e) \ No newline at end of file + except urllib.error.HTTPError: + Logger.logException("e", "An HTTP error occurred while trying to send slice information") + except Exception: # We don't want any exception to cause problems + Logger.logException("e", "An exception occurred while trying to send slice information") \ No newline at end of file