Merge pull request #665 from thopiekar/master-code-fixes

Fixing small issues in the code
This commit is contained in:
Ghostkeeper 2016-03-15 10:57:50 +01:00
commit e4effc1236
16 changed files with 25 additions and 45 deletions

View file

@ -1,11 +1,9 @@
# Copyright (c) 2015 Ultimaker B.V. # Copyright (c) 2015 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.View.Renderer import Renderer
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from UM.Application import Application from UM.Application import Application
from UM.Resources import Resources from UM.Resources import Resources
from UM.Mesh.MeshData import MeshData
from UM.Mesh.MeshBuilder import MeshBuilder from UM.Mesh.MeshBuilder import MeshBuilder
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
from UM.Math.Color import Color from UM.Math.Color import Color

View file

@ -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 from UM.View.GL.OpenGL import OpenGL
import numpy
class ConvexHullNode(SceneNode): class ConvexHullNode(SceneNode):
def __init__(self, node, hull, parent = None): def __init__(self, node, hull, parent = None):
super().__init__(parent) super().__init__(parent)

View file

@ -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 PyQt5.QtGui import QDesktopServices
from UM.Event import CallFunctionEvent from UM.Event import CallFunctionEvent
from UM.Application import Application from UM.Application import Application
import webbrowser
class CuraActions(QObject): class CuraActions(QObject):
def __init__(self, parent = None): def __init__(self, parent = None):
super().__init__(parent) super().__init__(parent)

View file

@ -1,8 +1,6 @@
# Copyright (c) 2015 Ultimaker B.V. # Copyright (c) 2015 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.
import platform
from UM.Qt.QtApplication import QtApplication from UM.Qt.QtApplication import QtApplication
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from UM.Scene.Camera import Camera from UM.Scene.Camera import Camera
@ -49,7 +47,6 @@ from PyQt5.QtQml import qmlRegisterUncreatableType
import platform import platform
import sys import sys
import os
import os.path import os.path
import numpy import numpy
import copy import copy

View file

@ -19,8 +19,6 @@ from . import PlatformPhysicsOperation
from . import ConvexHullJob from . import ConvexHullJob
from . import ZOffsetDecorator from . import ZOffsetDecorator
import time
import threading
import copy import copy
class PlatformPhysics: class PlatformPhysics:
@ -132,7 +130,7 @@ class PlatformPhysics:
else: else:
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull")) overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull"))
except: 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: if overlap is None:
continue continue

View file

@ -10,18 +10,18 @@ from UM.Qt.Duration import Duration
import math 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 # 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 # time/quality slider concept. It is a rather tricky combination of event handling
# and state management. The logic behind this is as follows: # 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. # 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". # - 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. # - 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. # - 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. # - When the high quality pass is done, we update the maximum print time.
# #
class PrintInformation(QObject): class PrintInformation(QObject):

View file

@ -4,11 +4,10 @@
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
import sys import sys
import os
def exceptHook(type, value, traceback): def exceptHook(hook_type, value, traceback):
import cura.CrashHandler import cura.CrashHandler
cura.CrashHandler.show(type, value, traceback) cura.CrashHandler.show(hook_type, value, traceback)
sys.excepthook = exceptHook sys.excepthook = exceptHook
@ -16,7 +15,7 @@ sys.excepthook = exceptHook
# is a race condition between Arcus and PyQt. Importing Arcus # is a race condition between Arcus and PyQt. Importing Arcus
# first seems to prevent Sip from going into a state where it # first seems to prevent Sip from going into a state where it
# tries to create PyQt objects on a non-main thread. # tries to create PyQt objects on a non-main thread.
import Arcus import Arcus #@UnusedImport
import cura.CuraApplication import cura.CuraApplication
if sys.platform == "win32" and hasattr(sys, "frozen"): if sys.platform == "win32" and hasattr(sys, "frozen"):

View file

@ -12,10 +12,7 @@ from UM.Math.Quaternion import Quaternion
from UM.Job import Job from UM.Job import Job
import os
import struct
import math import math
from os import listdir
import zipfile import zipfile
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
@ -32,8 +29,6 @@ class ThreeMFReader(MeshReader):
} }
def read(self, file_name): def read(self, file_name):
result = None
result = SceneNode() result = SceneNode()
# The base object of 3mf is a zipped archive. # The base object of 3mf is a zipped archive.
archive = zipfile.ZipFile(file_name, "r") 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) 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 return None
for object in objects: for entry in objects:
mesh = MeshData() mesh = MeshData()
node = SceneNode() node = SceneNode()
vertex_list = [] vertex_list = []
#for vertex in object.mesh.vertices.vertex: #for vertex in entry.mesh.vertices.vertex:
for vertex in object.findall(".//3mf:vertex", self._namespaces): for vertex in entry.findall(".//3mf:vertex", self._namespaces):
vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")]) vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")])
Job.yieldThread() Job.yieldThread()
triangles = object.findall(".//3mf:triangle", self._namespaces) triangles = entry.findall(".//3mf:triangle", self._namespaces)
mesh.reserveFaceCount(len(triangles)) mesh.reserveFaceCount(len(triangles))
@ -72,7 +67,7 @@ class ThreeMFReader(MeshReader):
node.setMeshData(mesh) node.setMeshData(mesh)
node.setSelectable(True) 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: if transformation:
transformation = transformation[0] transformation = transformation[0]

View file

@ -2,7 +2,6 @@
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from UM.View.View import View from UM.View.View import View
from UM.View.Renderer import Renderer
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Resources import Resources from UM.Resources import Resources
from UM.Event import Event, KeyEvent from UM.Event import Event, KeyEvent
@ -11,7 +10,6 @@ from UM.Scene.Selection import Selection
from UM.Math.Color import Color from UM.Math.Color import Color
from UM.Mesh.MeshData import MeshData from UM.Mesh.MeshData import MeshData
from UM.Job import Job from UM.Job import Job
from UM.Message import Message
from UM.View.RenderBatch import RenderBatch from UM.View.RenderBatch import RenderBatch
from UM.View.GL.OpenGL import OpenGL from UM.View.GL.OpenGL import OpenGL
@ -23,7 +21,6 @@ from PyQt5.QtWidgets import QApplication
from . import LayerViewProxy from . import LayerViewProxy
import time
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
@ -139,7 +136,7 @@ class LayerView(View):
def calculateMaxLayers(self): def calculateMaxLayers(self):
scene = self.getController().getScene() scene = self.getController().getScene()
renderer = self.getRenderer() renderer = self.getRenderer() # TODO: Unused variable
self._activity = True self._activity = True
self._old_max_layers = self._max_layers self._old_max_layers = self._max_layers

View file

@ -51,10 +51,10 @@ class LegacyProfileReader(ProfileReader):
# \return A set of local variables, one for each setting in the legacy # \return A set of local variables, one for each setting in the legacy
# profile. # profile.
def prepareLocals(self, config_parser, config_section, defaults): 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): for option in config_parser.options(config_section):
locals[option] = config_parser.get(config_section, option) copied_locals[option] = config_parser.get(config_section, option)
return locals return copied_locals
## Reads a legacy Cura profile from a file and returns it. ## Reads a legacy Cura profile from a file and returns it.
# #

View file

@ -4,7 +4,6 @@
from UM.Tool import Tool from UM.Tool import Tool
from UM.Scene.Selection import Selection from UM.Scene.Selection import Selection
from UM.Application import Application from UM.Application import Application
from UM.Qt.ListModel import ListModel
from UM.Preferences import Preferences from UM.Preferences import Preferences
from . import PerObjectSettingsModel from . import PerObjectSettingsModel

View file

@ -4,6 +4,8 @@
from . import RemovableDrivePlugin from . import RemovableDrivePlugin
from UM.Logger import Logger
import glob import glob
import os import os
import subprocess import subprocess
@ -33,6 +35,7 @@ class LinuxRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
def performEjectDevice(self, device): def performEjectDevice(self, device):
p = subprocess.Popen(["umount", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(["umount", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = p.communicate() output = p.communicate()
Logger.log("d", "umount returned: %s.", repr(output))
return_code = p.wait() return_code = p.wait()
if return_code != 0: if return_code != 0:

View file

@ -4,10 +4,9 @@
from . import RemovableDrivePlugin from . import RemovableDrivePlugin
import threading from UM.Logger import Logger
import subprocess import subprocess
import time
import os import os
import plistlib import plistlib
@ -44,8 +43,9 @@ class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
return drives return drives
def performEjectDevice(self, device): 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() output = p.communicate()
Logger.log("d", "umount returned: %s.", repr(output))
return_code = p.wait() return_code = p.wait()
if return_code != 0: if return_code != 0:

View file

@ -66,7 +66,7 @@ class SliceInfo(Extension):
break break
profile_values = settings.getChangedSettings() profile_values = settings.getChangedSettings() # TODO: Unused variable
# Get total material used (in mm^3) # Get total material used (in mm^3)
print_information = Application.getInstance().getPrintInformation() print_information = Application.getInstance().getPrintInformation()

View file

@ -8,7 +8,6 @@ import time
import queue import queue
import re import re
import functools import functools
import os
import os.path import os.path
from UM.Application import Application from UM.Application import Application

View file

@ -19,7 +19,6 @@ import threading
import platform import platform
import glob import glob
import time import time
import os
import os.path import os.path
import sys import sys
from UM.Extension import Extension from UM.Extension import Extension
@ -60,7 +59,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
@pyqtProperty(float, notify = progressChanged) @pyqtProperty(float, notify = progressChanged)
def progress(self): def progress(self):
progress = 0 progress = 0
for name, connection in self._printer_connections.items(): for printer_name, connection in self._printer_connections.items():
progress += connection.progress progress += connection.progress
return progress / len(self._printer_connections) return progress / len(self._printer_connections)