Style: Use "" for strings not ''

This commit is contained in:
Arjen Hiemstra 2015-05-06 18:32:54 +02:00
parent 7cc493ad91
commit 0a6562a8f1
24 changed files with 242 additions and 240 deletions

View file

@ -23,13 +23,13 @@ class CuraEngineBackend(Backend):
super().__init__()
# Find out where the engine is located, and how it is called. This depends on how Cura is packaged and which OS we are running on.
default_engine_location = '../PinkUnicornEngine/CuraEngine'
if hasattr(sys, 'frozen'):
default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), 'CuraEngine')
if sys.platform == 'win32':
default_engine_location += '.exe'
default_engine_location = "../PinkUnicornEngine/CuraEngine"
if hasattr(sys, "frozen"):
default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine")
if sys.platform == "win32":
default_engine_location += ".exe"
default_engine_location = os.path.abspath(default_engine_location)
Preferences.getInstance().addPreference('backend/location', default_engine_location)
Preferences.getInstance().addPreference("backend/location", default_engine_location)
self._scene = Application.getInstance().getController().getScene()
self._scene.sceneChanged.connect(self._onSceneChanged)
@ -59,7 +59,7 @@ class CuraEngineBackend(Backend):
self.backendConnected.connect(self._onBackendConnected)
def getEngineCommand(self):
return [Preferences.getInstance().getValue("backend/location"), '-j', Resources.getPath(Resources.SettingsLocation, 'fdmprinter.json'), '-vv', '--connect', "127.0.0.1:{0}".format(self._port)]
return [Preferences.getInstance().getValue("backend/location"), "-j", Resources.getPath(Resources.SettingsLocation, "fdmprinter.json"), "-vv", "--connect", "127.0.0.1:{0}".format(self._port)]
## Emitted when we get a message containing print duration and material amount. This also implies the slicing has finished.
# \param time The amount of time the print will take.
@ -84,13 +84,13 @@ class CuraEngineBackend(Backend):
# - report_progress: True if the slicing progress should be reported, False if not. Default is True.
def slice(self, **kwargs):
if self._slicing:
if not kwargs.get('force_restart', True):
if not kwargs.get("force_restart", True):
return
self._slicing = False
self._restart = True
if self._process is not None:
Logger.log('d', "Killing engine process")
Logger.log("d", "Killing engine process")
try:
self._process.terminate()
except: # terminating a process that is already terminating causes an exception, silently ignore this.
@ -101,7 +101,7 @@ class CuraEngineBackend(Backend):
objects = []
for node in DepthFirstIterator(self._scene.getRoot()):
if type(node) is SceneNode and node.getMeshData() and node.getMeshData().getVertices() is not None:
if not getattr(node, '_outside_buildarea', False):
if not getattr(node, "_outside_buildarea", False):
objects.append(node)
if not objects:
@ -110,22 +110,22 @@ class CuraEngineBackend(Backend):
self._slicing = True
self.slicingStarted.emit()
self._report_progress = kwargs.get('report_progress', True)
self._report_progress = kwargs.get("report_progress", True)
if self._report_progress:
self.processingProgress.emit(0.0)
self._sendSettings(kwargs.get('settings', self._settings))
self._sendSettings(kwargs.get("settings", self._settings))
self._scene.acquireLock()
# Set the gcode as an empty list. This will be filled with strings by GCodeLayer messages.
# This is done so the gcode can be fragmented in memory and does not need a continues memory space.
# (AKA. This prevents MemoryErrors)
self._save_gcode = kwargs.get('save_gcode', True)
self._save_gcode = kwargs.get("save_gcode", True)
if self._save_gcode:
setattr(self._scene, 'gcode_list', [])
setattr(self._scene, "gcode_list", [])
self._save_polygons = kwargs.get('save_polygons', True)
self._save_polygons = kwargs.get("save_polygons", True)
msg = Cura_pb2.ObjectList()
@ -194,7 +194,7 @@ class CuraEngineBackend(Backend):
def _onGCodePrefixMessage(self, message):
if self._save_gcode:
self._scene.gcode_list.insert(0, message.data.decode('utf-8', 'replace'))
self._scene.gcode_list.insert(0, message.data.decode("utf-8", "replace"))
def _onObjectPrintTimeMessage(self, message):
self.printDurationMessage.emit(message.time, message.material_amount)
@ -221,7 +221,7 @@ class CuraEngineBackend(Backend):
for setting in settings.getAllSettings(include_machine=True):
s = msg.settings.add()
s.name = setting.getKey()
s.value = str(setting.getValue()).encode('utf-8')
s.value = str(setting.getValue()).encode("utf-8")
self._socket.sendMessage(msg)

View file

@ -10,4 +10,4 @@ class ProcessGCodeLayerJob(Job):
self._message = message
def run(self):
self._scene.gcode_list.append(self._message.data.decode('utf-8', 'replace'))
self._scene.gcode_list.append(self._message.data.decode("utf-8", "replace"))

View file

@ -11,7 +11,7 @@ import struct
class ProcessSlicedObjectListJob(Job):
def __init__(self, message):
super().__init__(description = 'Processing sliced object')
super().__init__()
self._message = message
self._scene = Application.getInstance().getController().getScene()
@ -27,7 +27,7 @@ class ProcessSlicedObjectListJob(Job):
objectIdMap[id(node)] = node
settings = Application.getInstance().getActiveMachine()
layerHeight = settings.getSettingValueByKey('layer_height')
layerHeight = settings.getSettingValueByKey("layer_height")
for object in self._message.objects:
try:
@ -40,7 +40,7 @@ class ProcessSlicedObjectListJob(Job):
layerData = LayerData.LayerData()
for layer in object.layers:
for polygon in layer.polygons:
points = numpy.fromstring(polygon.points, dtype='i8') # Convert bytearray to numpy array
points = numpy.fromstring(polygon.points, dtype="i8") # Convert bytearray to numpy array
points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
points = numpy.asarray(points, dtype=numpy.float32)
points /= 1000
@ -48,11 +48,11 @@ class ProcessSlicedObjectListJob(Job):
points[:,2] *= -1
if not settings.getSettingValueByKey('machine_center_is_zero'):
center = [settings.getSettingValueByKey('machine_width') / 2, 0.0, -settings.getSettingValueByKey('machine_depth') / 2]
if not settings.getSettingValueByKey("machine_center_is_zero"):
center = [settings.getSettingValueByKey("machine_width") / 2, 0.0, -settings.getSettingValueByKey("machine_depth") / 2]
points -= numpy.array(center)
#points = numpy.pad(points, ((0,0), (0,1)), 'constant', constant_values=(0.0, 1.0))
#points = numpy.pad(points, ((0,0), (0,1)), "constant", constant_values=(0.0, 1.0))
#inverse = node.getWorldTransformation().getInverse().getData()
#points = points.dot(inverse)
#points = points[:,0:3]

View file

@ -2,15 +2,15 @@
from . import CuraEngineBackend
from UM.i18n import i18nCatalog
catalog = i18nCatalog('cura')
catalog = i18nCatalog("cura")
def getMetaData():
return {
'type': 'backend',
'plugin': {
'name': "CuraEngine Backend",
'author': 'Arjen Hiemstra',
'description': catalog.i18nc('CuraEngine backend plugin description', 'Provides the link to the CuraEngine slicing backend')
"type": "backend",
"plugin": {
"name": "CuraEngine Backend",
"author": "Arjen Hiemstra",
"description": catalog.i18nc("CuraEngine backend plugin description", "Provides the link to the CuraEngine slicing backend")
}
}