mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Code cleanup
CURA-3858
This commit is contained in:
parent
abae2cc28c
commit
0f00895a97
1 changed files with 10 additions and 19 deletions
|
@ -1,7 +1,5 @@
|
||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
|
||||||
from UM.Job import Job
|
from UM.Job import Job
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Platform import Platform
|
from UM.Platform import Platform
|
||||||
|
@ -10,38 +8,31 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
class SliceInfoJob(Job):
|
class SliceInfoJob(Job):
|
||||||
data = None # type: Any
|
|
||||||
url = None # type: str
|
|
||||||
|
|
||||||
def __init__(self, url, data):
|
def __init__(self, url, data):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.url = url
|
self._url = url
|
||||||
self.data = data
|
self._data = data
|
||||||
|
|
||||||
def run(self):
|
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!")
|
Logger.log("e", "URL or DATA for sending slice info was not set!")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Submit data
|
# Submit data
|
||||||
kwoptions = {"data" : self.data,
|
kwoptions = {"data" : self._data, "timeout" : 5}
|
||||||
"timeout" : 5
|
|
||||||
}
|
|
||||||
|
|
||||||
if Platform.isOSX():
|
if Platform.isOSX():
|
||||||
kwoptions["context"] = ssl._create_unverified_context()
|
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:
|
try:
|
||||||
f = urllib.request.urlopen(self.url, **kwoptions)
|
f = urllib.request.urlopen(self._url, **kwoptions)
|
||||||
Logger.log("i", "Sent anonymous slice info.")
|
Logger.log("i", "Sent anonymous slice info.")
|
||||||
f.close()
|
f.close()
|
||||||
except urllib.error.HTTPError as http_exception:
|
except urllib.error.HTTPError:
|
||||||
Logger.log("e", "An HTTP error occurred while trying to send slice information: %s" % http_exception)
|
Logger.logException("e", "An HTTP error occurred while trying to send slice information")
|
||||||
except Exception as e: # We don't want any exception to cause problems
|
except Exception: # We don't want any exception to cause problems
|
||||||
Logger.log("e", "An exception occurred while trying to send slice information: %s" % e)
|
Logger.logException("e", "An exception occurred while trying to send slice information")
|
Loading…
Add table
Add a link
Reference in a new issue