Fix tilda_tools test not working in Windows

Fixes for hard coded '/'s.
andrejusk/bday
Lex Robinson 2018-08-29 23:17:54 +01:00
parent a888d5a86a
commit 98e53077b6
No known key found for this signature in database
GPG Key ID: 75D524B43F863B4A
2 changed files with 16 additions and 4 deletions

View File

@ -61,10 +61,21 @@ def soft_reset(args, verbose = True):
raise PyboardError('could not soft reboot')
def find_tty():
# Todo: find solution for windows, test in linux
# Todo: test in linux, let user pick if multiple ports are available
for pattern in ['/dev/ttyACM*', '/dev/tty.usbmodemTiLDA*', '/dev/tty.usbmodem*']:
for path in glob.glob(pattern):
return path
if sys.platform.startswith('win'):
import serial
for port in ['COM%s' % (i + 1) for i in range(256)]:
try:
s = serial.Serial(port)
s.close()
return port
except (OSError, serial.SerialException):
pass
print("Couldn't find badge tty - Please make it's plugged in and reset it if necessary")
sys.exit(1)

View File

@ -135,7 +135,7 @@ def add_metadata(path, resources):
for resource in resources.values():
file = None
if resource['type'] == "app":
file = next(f for f in resource['files'] if "/main.py" in f)
file = next(f for f in resource['files'] if os.path.basename(f) == "main.py")
elif resource['type'] == "lib":
file = next(iter(resource['files'].keys()))
@ -166,6 +166,7 @@ def resolve_dependencies(resources):
to_add = resource['dependencies'].copy()
while len(to_add):
r = to_add.pop()
r = os.path.normpath(r)
if r in already_added:
continue
if r not in resources:
@ -244,6 +245,6 @@ def pretty_print_resources(resources):
def normalize_dependency(dependency):
"""lib dependencies can be shortened to just their module name"""
if "." in dependency or "/" in dependency or "upip:" in dependency:
if "." in dependency or os.pathsep in dependency or "upip:" in dependency:
return dependency
return "lib/%s.py" % dependency
return os.path.join("lib", "%s.py" % dependency)