diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index e9b90e3a61..143b2fefbb 100644 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -1,11 +1,9 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from UM.View.Renderer import Renderer from UM.Scene.SceneNode import SceneNode from UM.Application import Application from UM.Resources import Resources -from UM.Mesh.MeshData import MeshData from UM.Mesh.MeshBuilder import MeshBuilder from UM.Math.Vector import Vector from UM.Math.Color import Color diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index 7f0f87ade5..b99e80fcff 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -9,8 +9,6 @@ from UM.Mesh.MeshBuilder import MeshBuilder #To create a mesh to display the con from UM.View.GL.OpenGL import OpenGL -import numpy - class ConvexHullNode(SceneNode): def __init__(self, node, hull, parent = None): super().__init__(parent) diff --git a/cura/CuraActions.py b/cura/CuraActions.py index e585b261d0..36bf32fdd7 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -1,11 +1,9 @@ -from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl +from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, QUrl from PyQt5.QtGui import QDesktopServices from UM.Event import CallFunctionEvent from UM.Application import Application -import webbrowser - class CuraActions(QObject): def __init__(self, parent = None): super().__init__(parent) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 1b41cdda2f..0f35a3dd98 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1,8 +1,6 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -import platform - from UM.Qt.QtApplication import QtApplication from UM.Scene.SceneNode import SceneNode from UM.Scene.Camera import Camera @@ -49,7 +47,6 @@ from PyQt5.QtQml import qmlRegisterUncreatableType import platform import sys -import os import os.path import numpy import copy diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index df841bd71d..f660d68f34 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -19,8 +19,6 @@ from . import PlatformPhysicsOperation from . import ConvexHullJob from . import ZOffsetDecorator -import time -import threading import copy class PlatformPhysics: @@ -132,7 +130,7 @@ class PlatformPhysics: else: overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull")) except: - overlap = None #It can sometimes occur that the caclulated convex hull has no size, in which case there is no overlap. + overlap = None #It can sometimes occur that the calculated convex hull has no size, in which case there is no overlap. if overlap is None: continue diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index a3a2bb2948..73dde53437 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -10,18 +10,18 @@ from UM.Qt.Duration import Duration import math -## A class for processing and calculating minimum, currrent and maximum print time. +## A class for processing and calculating minimum, current and maximum print time. # # This class contains all the logic relating to calculation and slicing for the # time/quality slider concept. It is a rather tricky combination of event handling # and state management. The logic behind this is as follows: # -# - A scene change or settting change event happens. +# - A scene change or setting change event happens. # We track what the source was of the change, either a scene change, a setting change, an active machine change or something else. # - This triggers a new slice with the current settings - this is the "current settings pass". # - When the slice is done, we update the current print time and material amount. # - If the source of the slice was not a Setting change, we start the second slice pass, the "low quality settings pass". Otherwise we stop here. -# - When that is done, we update the minimum print time and start the final slcice pass, the "high quality settings pass". +# - When that is done, we update the minimum print time and start the final slice pass, the "high quality settings pass". # - When the high quality pass is done, we update the maximum print time. # class PrintInformation(QObject): diff --git a/cura_app.py b/cura_app.py index e19147c5e5..853edabd5e 100755 --- a/cura_app.py +++ b/cura_app.py @@ -4,11 +4,10 @@ # Cura is released under the terms of the AGPLv3 or higher. import sys -import os -def exceptHook(type, value, traceback): +def exceptHook(hook_type, value, traceback): import cura.CrashHandler - cura.CrashHandler.show(type, value, traceback) + cura.CrashHandler.show(hook_type, value, traceback) sys.excepthook = exceptHook @@ -16,7 +15,7 @@ sys.excepthook = exceptHook # is a race condition between Arcus and PyQt. Importing Arcus # first seems to prevent Sip from going into a state where it # tries to create PyQt objects on a non-main thread. -import Arcus +import Arcus #@UnusedImport import cura.CuraApplication if sys.platform == "win32" and hasattr(sys, "frozen"): diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index ee86f720d8..fc748f61db 100644 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -12,10 +12,7 @@ from UM.Math.Quaternion import Quaternion from UM.Job import Job -import os -import struct import math -from os import listdir import zipfile import xml.etree.ElementTree as ET @@ -32,8 +29,6 @@ class ThreeMFReader(MeshReader): } def read(self, file_name): - result = None - result = SceneNode() # The base object of 3mf is a zipped archive. archive = zipfile.ZipFile(file_name, "r") @@ -46,16 +41,16 @@ class ThreeMFReader(MeshReader): Logger.log("w", "No objects found in 3MF file %s, either the file is corrupt or you are using an outdated format", file_name) return None - for object in objects: + for entry in objects: mesh = MeshData() node = SceneNode() vertex_list = [] - #for vertex in object.mesh.vertices.vertex: - for vertex in object.findall(".//3mf:vertex", self._namespaces): + #for vertex in entry.mesh.vertices.vertex: + for vertex in entry.findall(".//3mf:vertex", self._namespaces): vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")]) Job.yieldThread() - triangles = object.findall(".//3mf:triangle", self._namespaces) + triangles = entry.findall(".//3mf:triangle", self._namespaces) mesh.reserveFaceCount(len(triangles)) @@ -72,7 +67,7 @@ class ThreeMFReader(MeshReader): node.setMeshData(mesh) node.setSelectable(True) - transformation = root.findall("./3mf:build/3mf:item[@objectid='{0}']".format(object.get("id")), self._namespaces) + transformation = root.findall("./3mf:build/3mf:item[@objectid='{0}']".format(entry.get("id")), self._namespaces) if transformation: transformation = transformation[0] diff --git a/plugins/LayerView/LayerView.py b/plugins/LayerView/LayerView.py index 9f65a8e783..eb9c3bc91e 100644 --- a/plugins/LayerView/LayerView.py +++ b/plugins/LayerView/LayerView.py @@ -2,7 +2,6 @@ # Cura is released under the terms of the AGPLv3 or higher. from UM.View.View import View -from UM.View.Renderer import Renderer from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Resources import Resources from UM.Event import Event, KeyEvent @@ -11,7 +10,6 @@ from UM.Scene.Selection import Selection from UM.Math.Color import Color from UM.Mesh.MeshData import MeshData from UM.Job import Job -from UM.Message import Message from UM.View.RenderBatch import RenderBatch from UM.View.GL.OpenGL import OpenGL @@ -23,7 +21,6 @@ from PyQt5.QtWidgets import QApplication from . import LayerViewProxy -import time from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") @@ -139,7 +136,7 @@ class LayerView(View): def calculateMaxLayers(self): scene = self.getController().getScene() - renderer = self.getRenderer() + renderer = self.getRenderer() # TODO: Unused variable self._activity = True self._old_max_layers = self._max_layers diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 661646bf64..3daf360ee6 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -51,10 +51,10 @@ class LegacyProfileReader(ProfileReader): # \return A set of local variables, one for each setting in the legacy # profile. def prepareLocals(self, config_parser, config_section, defaults): - locals = defaults.copy() #Don't edit the original! + copied_locals = defaults.copy() #Don't edit the original! for option in config_parser.options(config_section): - locals[option] = config_parser.get(config_section, option) - return locals + copied_locals[option] = config_parser.get(config_section, option) + return copied_locals ## Reads a legacy Cura profile from a file and returns it. # diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 70b3d8bbe8..dc65725839 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -4,7 +4,6 @@ from UM.Tool import Tool from UM.Scene.Selection import Selection from UM.Application import Application -from UM.Qt.ListModel import ListModel from UM.Preferences import Preferences from . import PerObjectSettingsModel diff --git a/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py b/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py index ce948c472b..46e3dafb71 100644 --- a/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py +++ b/plugins/RemovableDriveOutputDevice/LinuxRemovableDrivePlugin.py @@ -4,6 +4,8 @@ from . import RemovableDrivePlugin +from UM.Logger import Logger + import glob import os import subprocess @@ -33,6 +35,7 @@ class LinuxRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin): def performEjectDevice(self, device): p = subprocess.Popen(["umount", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = p.communicate() + Logger.log("d", "umount returned: %s.", repr(output)) return_code = p.wait() if return_code != 0: diff --git a/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py b/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py index e02e0d65b6..4b65ce024d 100644 --- a/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py +++ b/plugins/RemovableDriveOutputDevice/OSXRemovableDrivePlugin.py @@ -4,10 +4,9 @@ from . import RemovableDrivePlugin -import threading +from UM.Logger import Logger import subprocess -import time import os import plistlib @@ -44,8 +43,9 @@ class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin): return drives def performEjectDevice(self, device): - p = subprocess.Popen(["diskutil", "eject", path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(["diskutil", "eject", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = p.communicate() + Logger.log("d", "umount returned: %s.", repr(output)) return_code = p.wait() if return_code != 0: diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 78d0c7cec0..ed018f7d89 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -66,7 +66,7 @@ class SliceInfo(Extension): break - profile_values = settings.getChangedSettings() + profile_values = settings.getChangedSettings() # TODO: Unused variable # Get total material used (in mm^3) print_information = Application.getInstance().getPrintInformation() diff --git a/plugins/USBPrinting/PrinterConnection.py b/plugins/USBPrinting/PrinterConnection.py index c19603c945..d28324b71c 100644 --- a/plugins/USBPrinting/PrinterConnection.py +++ b/plugins/USBPrinting/PrinterConnection.py @@ -8,7 +8,6 @@ import time import queue import re import functools -import os import os.path from UM.Application import Application diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index fcb61c3365..fbcd6201d7 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -19,7 +19,6 @@ import threading import platform import glob import time -import os import os.path import sys from UM.Extension import Extension @@ -60,7 +59,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): @pyqtProperty(float, notify = progressChanged) def progress(self): progress = 0 - for name, connection in self._printer_connections.items(): + for printer_name, connection in self._printer_connections.items(): progress += connection.progress return progress / len(self._printer_connections)