Skip to content

Commit f5769cc

Browse files
committed
Console performance fix
1 parent f77852e commit f5769cc

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

src/board.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,18 @@ def on_timer(self):
162162
self.progress.emit(msg[1])
163163

164164
if msg[0] == "exception":
165+
# output pending console data, so it isn't delayed
166+
# after the exception output
167+
if console_data:
168+
self.console.emit(console_data)
169+
console_data = b""
170+
165171
self.error.emit(msg[1][0], msg[1][1])
166172

167173
if msg[0] == "console":
168174
# console output may happen pretty fast. Writing single bytes
169-
# to the output will slow things down pretty much. So we collect data
170-
# and return the whole message
175+
# to the output will slow things down pretty much. So we
176+
# collect data and return the whole message.
171177
console_data += msg[1]
172178

173179
if msg[0] == "downloaded":

src/fileview.py

-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ def fileInputDialog(self):
530530
lineedit.setFocus()
531531
retval = ( None, False )
532532
if dlg.exec_() == QDialog.Accepted:
533-
print(type_cbox.currentData(), type_cbox.currentIndex())
534533
retval = ( lineedit.text() + "." + type_cbox.currentData(), True )
535534

536535
dlg.deleteLater()

src/upide.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
import zipfile
3131

3232
class Window(QMainWindow):
33-
def __init__(self, app, noscan):
33+
def __init__(self, app, flags):
3434
super(Window, self).__init__()
3535

36-
self.noscan = noscan
36+
self.flags = flags
3737
self.initUI()
3838
app.aboutToQuit.connect(self.on_exit)
3939
self.sysname = None
@@ -865,18 +865,27 @@ def initUI(self):
865865
self.show()
866866

867867
# scan if the user isn't suppressing this
868-
if not self.noscan:
869-
self.on_board_request(True)
870-
self.board.cmd(Board.SCAN, self.on_scan_result)
871-
else:
868+
if "noscan" in self.flags:
872869
# ask user for port
873870
self.timer = QTimer(self)
874871
self.timer.singleShot(100, self.open_port_dialog)
875-
872+
#if "pybricks_ble" in self.flags:
873+
# import pybricks_ble
874+
# self.pybricks = pybricks_ble.Pybricks()
875+
else:
876+
self.on_board_request(True)
877+
self.board.cmd(Board.SCAN, self.on_scan_result)
878+
876879
if __name__ == '__main__':
877880
# get own name. If name contains "noscan" then don't do
878881
# a automatic scan but ask for a port instead
879-
noscan = "noscan" in os.path.splitext(os.path.basename(sys.argv[0]))[0].lower()
882+
flags = [ ]
883+
if "noscan" in os.path.splitext(os.path.basename(sys.argv[0]))[0].lower():
884+
flags.append("noscan")
885+
886+
# pybricks is too limited to support it in uPIDE. It has no os modules ...
887+
# if "pybricks_ble" in os.path.splitext(os.path.basename(sys.argv[0]))[0].lower():
888+
# flags.append("pybricks_ble")
880889

881890
app = QApplication(sys.argv)
882891
app_icon = QIcon()
@@ -891,5 +900,5 @@ def initUI(self):
891900
tr.load(QLocale.system().name(), Window.resource_path("assets/i18n"))
892901
app.installTranslator(tr)
893902

894-
a = Window(app, noscan)
903+
a = Window(app, flags)
895904
sys.exit(app.exec_())

0 commit comments

Comments
 (0)