Skip to content

Commit

Permalink
Merge branch 'base/more-styling-work' of https://github.com/zanderbro…
Browse files Browse the repository at this point in the history
…wn/mu into base/more-styling-work
  • Loading branch information
ZanderBrown committed Jul 9, 2018
2 parents 18beb30 + c2ddcc4 commit d91180b
Show file tree
Hide file tree
Showing 22 changed files with 15,029 additions and 14,380 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ install:
- cmd: make win64
- ps: Rename-Item -path .\build upload64
- cmd: dir upload64\nsis
- ps: Rename-Item .\upload64\nsis\mu_1.0.0b16.exe mu_$(get-date -f yyyy-MM-dd_HH_mm)_$($env:APPVEYOR_REPO_BRANCH)_$($env:APPVEYOR_REPO_COMMIT.subString(0,7))_64bit.exe
- ps: Rename-Item .\upload64\nsis\mu_1.0.0b17.exe mu_$(get-date -f yyyy-MM-dd_HH_mm)_$($env:APPVEYOR_REPO_BRANCH)_$($env:APPVEYOR_REPO_COMMIT.subString(0,7))_64bit.exe
# 32bit
- cmd: make win32
- ps: Rename-Item -path .\build upload32
- cmd: dir upload32\nsis
- ps: Rename-Item .\upload32\nsis\mu_1.0.0b16.exe mu_$(get-date -f yyyy-MM-dd_HH_mm)_$($env:APPVEYOR_REPO_BRANCH)_$($env:APPVEYOR_REPO_COMMIT.subString(0,7))_32bit.exe
- ps: Rename-Item .\upload32\nsis\mu_1.0.0b17.exe mu_$(get-date -f yyyy-MM-dd_HH_mm)_$($env:APPVEYOR_REPO_BRANCH)_$($env:APPVEYOR_REPO_COMMIT.subString(0,7))_32bit.exe

# Not a project with an msbuild file, build done at install.
build: None
Expand Down
26 changes: 26 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
Release History
---------------

1.0.0.beta.17
=============

* Update to the latest version of uflash with the latest version of MicroPython
for the BBC micro:bit.
* Change flashing the BBC micro:bit to become more efficient (based on the
copying of files to the boards small "fake" filesystem, rather than
re-flashing the whole device in one go).
* Ensure user agrees to GPL3 license when installing on OSX.
* Fix Windows "make" file to correctly report errors thanks to Tim Golden.
* The debugger in Python mode now correctly handles user-generated exceptions.
* The debugger in Python mode updates the stack when no breakpoints are set.
* Major update of the OSX based automated build system.
* Modal dialog boxes should behave better on GTK based desktops thanks to
Zander Brown.
* Right click to access context menu in file panes in micro:bit mode so local
files can be opened in Mu.
* Fix bug where REPL, Files and Plotter buttons got into a bad state on
mode change.
* Update to use PyQt 5.11.
* On save, check for shadow modules (i.e. user's are not allowed to save
code whose filename would override an existing module name).
* Automatic comment toggling via Ctrl-K shortcut.
* A simple find and replace diaolog is now available via the Ctrl-F shortcut.
* Various minor bugs and niggles have been squashed.

1.0.0.beta.16
=============

Expand Down
24 changes: 18 additions & 6 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,17 @@ def check():
"""Run all the checkers and tests
"""
print("\nCheck")
clean()
pyflakes()
pycodestyle()
coverage()
funcs = [
clean,
pyflakes,
pycodestyle,
coverage
]
for func in funcs:
return_code = func()
if return_code != 0:
return return_code
return 0


@export
Expand All @@ -185,6 +192,7 @@ def clean():
_rmtree("lib")
_rmtree("pynsist_pkgs")
_rmfiles(".", "*.pyc")
return 0


@export
Expand Down Expand Up @@ -226,7 +234,7 @@ def run():
if not os.environ.get("VIRTUAL_ENV"):
raise RuntimeError("Cannot run Mu;"
"your Python virtualenv is not activated")
subprocess.run(["python", "-m", "mu"]).returncode
return subprocess.run(["python", "-m", "mu"]).returncode


@export
Expand All @@ -235,7 +243,9 @@ def dist():
"""
check()
print("Checks pass; good to package")
subprocess.run(["python", "setup.py", "sdist", "bdist_wheel"]).returncode
return subprocess.run(
["python", "setup.py", "sdist", "bdist_wheel"]
).returncode


@export
Expand Down Expand Up @@ -285,6 +295,8 @@ def docs():
os.chdir("docs")
try:
return subprocess.run(["cmd", "/c", "make.bat", "html"]).returncode
except Exception:
return 1
finally:
os.chdir(cwd)

Expand Down
2 changes: 1 addition & 1 deletion mu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
gettext.translation('mu', localedir=localedir,
languages=[language_code], fallback=True).install()

__version__ = '1.0.0.beta.16'
__version__ = '1.0.0.beta.17'
61 changes: 54 additions & 7 deletions mu/contrib/microfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@
"""


COMMAND_LINE_FLAG = False # Indicates running from the command line.


def find_microbit():
"""
Finds the port to which the device is connected.
Returns a tuple representation of the port and serial number for a
connected micro:bit device. If no device is connected the tuple will be
(None, None).
"""
ports = list_serial_ports()
for port in ports:
if "VID:PID=0D28:0204" in port[2].upper():
return port[0]
return None
return (port[0], port.serial_number)
return (None, None)


def raw_on(serial):
Expand All @@ -72,17 +77,20 @@ def raw_on(serial):
# Flush
data = serial.read_until(b'raw REPL; CTRL-B to exit\r\n>')
if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'):
print(data)
if COMMAND_LINE_FLAG:
print(data)
raise IOError('Could not enter raw REPL.')
# Soft Reset with CTRL-D
serial.write(b'\x04')
data = serial.read_until(b'soft reboot\r\n')
if not data.endswith(b'soft reboot\r\n'):
print(data)
if COMMAND_LINE_FLAG:
print(data)
raise IOError('Could not enter raw REPL.')
data = serial.read_until(b'raw REPL; CTRL-B to exit\r\n>')
if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'):
print(data)
if COMMAND_LINE_FLAG:
print(data)
raise IOError('Could not enter raw REPL.')


Expand All @@ -98,7 +106,7 @@ def get_serial():
Detect if a micro:bit is connected and return a serial object to talk to
it.
"""
port = find_microbit()
port, serial_number = find_microbit()
if port is None:
raise IOError('Could not find micro:bit.')
return Serial(port, 115200, timeout=1, parity='N')
Expand Down Expand Up @@ -259,6 +267,43 @@ def get(filename, target=None, serial=None):
return True


def version(serial=None):
"""
Returns version information for MicroPython running on the connected
device.
If such information is not available or the device is not running
MicroPython, raise a ValueError.
If any other exception is thrown, the device was running MicroPython but
there was a problem parsing the output.
"""
try:
out, err = execute([
'import os',
'print(os.uname())',
], serial)
if err:
raise ValueError(clean_error(err))
except ValueError:
# Re-raise any errors from stderr raised in the try block.
raise
except Exception:
# Raise a value error to indicate unable to find something on the
# microbit that will return parseable information about the version.
# It doesn't matter what the error is, we just need to indicate a
# failure with the expected ValueError exception.
raise ValueError()
raw = out.decode('utf-8').strip()
raw = raw[1:-1]
items = raw.split(', ')
result = {}
for item in items:
key, value = item.split('=')
result[key] = value[1:-1]
return result


def main(argv=None):
"""
Entry point for the command line tool 'ufs'.
Expand All @@ -270,6 +315,8 @@ def main(argv=None):
if not argv:
argv = sys.argv[1:]
try:
global COMMAND_LINE_FLAG
COMMAND_LINE_FLAG = True
parser = argparse.ArgumentParser(description=_HELP_TEXT)
parser.add_argument('command', nargs='?', default=None,
help="One of 'ls', 'rm', 'put' or 'get'.")
Expand Down
Loading

0 comments on commit d91180b

Please sign in to comment.