Some style fixing, and added a test script to test for the major style violations.

This commit is contained in:
daid 2015-04-24 17:07:32 +02:00
parent 4a965e04b4
commit 83c367cdf4
4 changed files with 21 additions and 15 deletions

View file

@ -150,7 +150,6 @@ class PrinterConnection(SignalEmitter):
self._firmware_file_name = file_name
self._update_firmware_thread.start()
## Private connect function run by thread. Can be started by calling connect.
def _connect(self):
self._is_connecting = True
@ -378,6 +377,7 @@ class PrinterConnection(SignalEmitter):
self.sendCommand("M105 T%d" % self._temperature_requested_extruder_index)
else:
self.sendCommand("M105")
## Send next Gcode in the gcode list
def _sendNextGcodeLine(self):
if self._gcode_position >= len(self._gcode):

View file

@ -19,6 +19,7 @@ from UM.i18n import i18nCatalog
i18n_catalog = i18nCatalog('plugins')
class USBPrinterManager(QObject, SignalEmitter, Extension):
def __init__(self, parent = None):
super().__init__(parent)
@ -48,26 +49,25 @@ class USBPrinterManager(QObject, SignalEmitter, Extension):
self._firmware_view.show()
def spawnControlInterface(self,serial_port):
def spawnControlInterface(self, serial_port):
if self._control_view is None:
self._control_view = QQuickView()
self._control_view.engine().rootContext().setContextProperty('manager',self)
self._control_view.setSource(QUrl("plugins/USBPrinting/ControlWindow.qml"))
self._control_view.show()
processingProgress = pyqtSignal(float, arguments = ['amount'])
@pyqtProperty(float,notify = processingProgress)
@pyqtProperty(float, notify=processingProgress)
def progress(self):
return self._progress
pyqtExtruderTemperature = pyqtSignal(float, arguments = ['amount'])
@pyqtProperty(float,notify = pyqtExtruderTemperature)
@pyqtProperty(float, notify=pyqtExtruderTemperature)
def extruderTemperature(self):
return self._extruder_temp
pyqtBedTemperature = pyqtSignal(float, arguments = ['amount'])
@pyqtProperty(float,notify = pyqtBedTemperature)
@pyqtProperty(float, notify=pyqtBedTemperature)
def bedTemperature(self):
return self._bed_temp
@ -268,15 +268,15 @@ class USBPrinterManager(QObject, SignalEmitter, Extension):
i=0
while True:
values = winreg.EnumValue(key, i)
if not base_list or 'USBSER' in values[0]:
base_list+=[values[1]]
if 'USBSER' in values[0]:
base_list += [values[1]]
i+=1
except:
pass
if base_list:
base_list = base_list + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.usb*")
base_list = filter(lambda s: not 'Bluetooth' in s, base_list) #Filter because mac sometimes puts them in the list
base_list = filter(lambda s: 'Bluetooth' not in s, base_list) #Filter because mac sometimes puts them in the list
#prev = profile.getMachineSetting('serial_port_auto')
#if prev in base_list:
# base_list.remove(prev)

View file

@ -57,8 +57,10 @@ class IspBase():
"""
raise IspError("Called undefined verifyFlash")
class IspError(BaseException):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)

View file

@ -3,7 +3,10 @@ STK500v2 protocol implementation for programming AVR chips.
The STK500v2 protocol is used by the ArduinoMega2560 and a few other Arduino platforms to load firmware.
This is a python 3 conversion of the code created by David Braam for the Cura project.
"""
import os, struct, sys, time
import os
import struct
import sys
import time
from serial import Serial
from serial import SerialException
@ -11,6 +14,7 @@ from serial import SerialTimeoutException
from . import ispBase, intelHex
class Stk500v2(ispBase.IspBase):
def __init__(self):
self.serial = None