Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 3 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
os: [macos-11, windows-2019]
os: [macos-13, windows-2022]
fail-fast: false
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.os }}
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
- name: Display Python info
run: |
python -c "import sys; print(sys.version)"
Expand All @@ -46,44 +46,8 @@ jobs:
make macos
mv dist/*.dmg upload/
- name: Upload Mu installer
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mu-editor-${{ runner.os }}-${{ github.sha }}
path: upload

build-linux:
runs-on: ubuntu-latest
container:
image: ghcr.io/mu-editor/mu-appimage:2022.05.01
name: Build AppImage
steps:
- uses: actions/checkout@v3
- name: Display system info
run: |
uname -a
cat /etc/lsb-release
python -c "import sys; print(sys.version)"
python -c "import platform, struct; print(platform.machine(), struct.calcsize('P') * 8)"
python -c "import sys; print(sys.executable)"
python -m pip --version
pip --version
pip list --verbose
- name: Install Mu test dependencies
run: |
pip install .[tests]
pip list
- run: mkdir upload
- name: Build Linux AppImage
run: QT_QPA_PLATFORM=offscreen make linux
# GitHub actions upload artifact breaks permissions, workaround using tar
# https://github.com/actions/upload-artifact/issues/38
- name: Tar AppImage to maintain permissions
run: |
cd dist/
tar -cvf Mu_Editor-AppImage-x86_64-${{ github.sha }}.tar *.AppImage
ls -la .
- name: Upload Mu AppImage
uses: actions/upload-artifact@v3
with:
name: mu-editor-${{ runner.os }}-${{ github.sha }}
path: dist/Mu_Editor-AppImage-x86_64-${{ github.sha }}.tar
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
# macos-13 is the latest release on x86, and macos-14 is arm64
os: [ubuntu-20.04, ubuntu-latest, macos-11, macos-13, macos-14, windows-2019, windows-latest]
os: [macos-14, windows-latest]
python-version: ['3.10', '3.11', '3.12']
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion mu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__title__ = "mu-editor"
__description__ = "A simple Python editor for beginner programmers."

__version__ = "1.3.3"
__version__ = "1.3.4"

__license__ = "GPL3"
__url__ = "https://github.com/mu-editor/mu"
Expand Down
19 changes: 16 additions & 3 deletions mu/contrib/microfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,20 @@ def flush_to_msg(serial, msg):

def flush(serial):
"""Flush all rx input without relying on serial.flushInput()."""
n = serial.inWaiting()
try:
n = serial.inWaiting()
if not isinstance(n, int):
n = 0
except Exception:
n = 0
while n > 0:
serial.read(n)
n = serial.inWaiting()
try:
n = serial.inWaiting()
if not isinstance(n, int):
n = 0
except Exception:
n = 0

raw_repl_msg = b"raw REPL; CTRL-B to exit\r\n>"

Expand Down Expand Up @@ -162,7 +172,10 @@ def execute(commands, serial=None, show_progress=False, callback=None):
serial.write(b"\x04") # Execute with CTRL-D

old_timeout = serial.timeout
serial.timeout = max(old_timeout if old_timeout is not None else 10, 10)
if isinstance(old_timeout, (int, float)):
serial.timeout = max(old_timeout, 10)
else:
serial.timeout = 10
try:
response = serial.read_until(b"\x04>") # Read until prompt.
finally:
Expand Down
14 changes: 13 additions & 1 deletion mu/modes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,20 @@ def execute(self, commands):
logger.info("Sending command {}".format(command))
self.write(command)
remainder = commands[1:]

# Determine adaptive delay based on control commands
delay = 2 # default 2ms
if command == KEYBOARD_INTERRUPT:
delay = 50
elif command == ENTER_RAW_MODE:
delay = 50
elif command == SOFT_REBOOT:
delay = 300 # Give virtual machine time to reboot
elif command == EXIT_RAW_MODE:
delay = 50

remaining_task = lambda commands=remainder: self.execute(commands)
QTimer.singleShot(2, remaining_task)
QTimer.singleShot(delay, remaining_task)

def send_commands(self, commands):
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import random
from unittest import mock

import pytest
Expand Down
16 changes: 9 additions & 7 deletions tests/modes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def test_micropython_mode_add_repl_no_port():
mm = MicroPythonMode(editor, view)
mm.add_repl()
assert view.show_message.call_count == 1
message = "Could not find an attached device."
message = _("Could not find an attached device.")
assert view.show_message.call_args[0][0] == message


Expand Down Expand Up @@ -632,7 +632,7 @@ def test_micropython_mode_add_plotter_no_port():
mm = MicroPythonMode(editor, view)
mm.add_plotter()
assert view.show_message.call_count == 1
message = "Could not find an attached device."
message = _("Could not find an attached device.")
assert view.show_message.call_args[0][0] == message


Expand Down Expand Up @@ -811,10 +811,12 @@ def test_FileManager_ls():
fm = FileManager("/dev/ttyUSB0")
fm.serial = mock.MagicMock()
fm.on_list_files = mock.MagicMock()
mock_ls = mock.MagicMock(return_value=["foo.py", "bar.py"])
with mock.patch("mu.modes.base.microfs.ls", mock_ls):
mock_ls = mock.MagicMock(return_value=[("foo.py", False), ("bar.py", False)])
with mock.patch("mu.modes.base.microfs.ls_with_types", mock_ls):
fm.ls()
fm.on_list_files.emit.assert_called_once_with(("foo.py", "bar.py"))
fm.on_list_files.emit.assert_called_once_with(
("foo.py", "bar.py"), frozenset(), None, "./"
)


def test_FileManager_ls_fail():
Expand All @@ -839,7 +841,7 @@ def test_fileManager_get():
mock_get = mock.MagicMock()
with mock.patch("mu.modes.base.microfs.get", mock_get):
fm.get("foo.py", "bar.py")
mock_get.assert_called_once_with("foo.py", "bar.py", serial=fm.serial)
mock_get.assert_called_once_with(fm, "foo.py", "bar.py", serial=fm.serial)
fm.on_get_file.emit.assert_called_once_with("foo.py")


Expand Down Expand Up @@ -868,7 +870,7 @@ def test_FileManager_put():
path = os.path.join("directory", "foo.py")
with mock.patch("mu.modes.base.microfs.put", mock_put):
fm.put(path)
mock_put.assert_called_once_with(path, target=None, serial=fm.serial)
mock_put.assert_called_once_with(fm, path, target=None, serial=fm.serial)
fm.on_put_file.emit.assert_called_once_with("foo.py")


Expand Down
Loading