Don't compare with None
This commit is contained in:
1 parent
9a1bd8af87
commit
14ef17163f
3 files changed
+9
-10
No files matched your search
@@ -17,7 +17,7 @@ class Stk500v2(ispBase.IspBase):
|
||||
self.progressCallback = None
|
||||
|
||||
def connect(self, port = 'COM22', speed = 115200):
|
||||
if self.serial != None:
|
||||
if self.serial is not None:
|
||||
self.close()
|
||||
try:
|
||||
self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000)
|
||||
@@ -39,14 +39,14 @@ class Stk500v2(ispBase.IspBase):
|
||||
raise ispBase.IspError("Failed to enter programming mode")
|
||||
|
||||
def close(self):
|
||||
if self.serial != None:
|
||||
if self.serial is not None:
|
||||
self.serial.close()
|
||||
self.serial = None
|
||||
|
||||
#Leave ISP does not reset the serial port, only resets the device, and returns the serial port after disconnecting it from the programming interface.
|
||||
# This allows you to use the serial port without opening it again.
|
||||
def leaveISP(self):
|
||||
if self.serial != None:
|
||||
if self.serial is not None:
|
||||
if self.sendMessage([0x11]) != [0x11, 0x00]:
|
||||
raise ispBase.IspError("Failed to leave programming mode")
|
||||
ret = self.serial
|
||||
@@ -55,7 +55,7 @@ class Stk500v2(ispBase.IspBase):
|
||||
return None
|
||||
|
||||
def isConnected(self):
|
||||
return self.serial != None
|
||||
return self.serial is not None
|
||||
|
||||
def sendISP(self, data):
|
||||
recv = self.sendMessage([0x1D, 4, 4, 0, data[0], data[1], data[2], data[3]])
|
||||
@@ -73,7 +73,7 @@ class Stk500v2(ispBase.IspBase):
|
||||
loadCount = (len(flashData) + pageSize - 1) // pageSize
|
||||
for i in range(0, loadCount):
|
||||
recv = self.sendMessage([0x13, pageSize >> 8, pageSize & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flashData[(i * pageSize):(i * pageSize + pageSize)])
|
||||
if self.progressCallback != None:
|
||||
if self.progressCallback is not None:
|
||||
self.progressCallback(i + 1, loadCount*2)
|
||||
|
||||
def verifyFlash(self, flashData):
|
||||
@@ -87,7 +87,7 @@ class Stk500v2(ispBase.IspBase):
|
||||
loadCount = (len(flashData) + 0xFF) // 0x100
|
||||
for i in range(0, loadCount):
|
||||
recv = self.sendMessage([0x14, 0x01, 0x00, 0x20])[2:0x102]
|
||||
if self.progressCallback != None:
|
||||
if self.progressCallback is not None:
|
||||
self.progressCallback(loadCount + i + 1, loadCount*2)
|
||||
for j in range(0, 0x100):
|
||||
if i * 0x100 + j < len(flashData) and flashData[i * 0x100 + j] != recv[j]:
|
||||
|
||||
@@ -371,15 +371,15 @@ class MachineCom(object):
|
||||
self._serialLogger = logging.getLogger("SERIAL")
|
||||
self._phaseLogger = logging.getLogger(__name__ + ".command_phases")
|
||||
|
||||
if port == None:
|
||||
if port is None:
|
||||
port = settings().get(["serial", "port"])
|
||||
if baudrate == None:
|
||||
if baudrate is None:
|
||||
settingsBaudrate = settings().getInt(["serial", "baudrate"])
|
||||
if settingsBaudrate is None:
|
||||
baudrate = 0
|
||||
else:
|
||||
baudrate = settingsBaudrate
|
||||
if callbackObject == None:
|
||||
if callbackObject is None:
|
||||
callbackObject = MachineComPrintCallback()
|
||||
|
||||
self._port = port
|
||||
|
||||
@@ -9,7 +9,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
import io
|
||||
import unittest
|
||||
import mock
|
||||
import six
|
||||
|
||||
import octoprint.filemanager
|
||||
import octoprint.filemanager.util
|
||||
|
||||
Reference in new issue
Block a user