Dictate.
This commit is contained in:
parent
3f27b496fd
commit
f551ff7bbd
|
|
@ -15,6 +15,13 @@ srcDir = os.path.join(rootDir, 'src')
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class Dict(dict):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.__dict__ = self
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
class Arduino:
|
class Arduino:
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
binary = '/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub'
|
binary = '/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub'
|
||||||
|
|
@ -31,11 +38,28 @@ class Arduino:
|
||||||
|
|
||||||
libraryDir = os.path.join(home, 'libraries')
|
libraryDir = os.path.join(home, 'libraries')
|
||||||
|
|
||||||
boards = {
|
boards = [
|
||||||
'Uno': 'arduino:avr:uno',
|
Dict({
|
||||||
'Leonardo': 'arduino:avr:leonardo',
|
'name': 'Uno',
|
||||||
'Mega': 'arduino:avr:mega',
|
'id': 'arduino:avr:uno',
|
||||||
}
|
'port': None,
|
||||||
|
}),
|
||||||
|
Dict({
|
||||||
|
'name': 'Leonardo',
|
||||||
|
'id': 'arduino:avr:leonardo',
|
||||||
|
'port': None,
|
||||||
|
}),
|
||||||
|
Dict({
|
||||||
|
'name': 'Mega',
|
||||||
|
'id': 'arduino:avr:mega',
|
||||||
|
'port': None,
|
||||||
|
}),
|
||||||
|
Dict({
|
||||||
|
'name': 'Due',
|
||||||
|
'id': 'arduino:sam:due',
|
||||||
|
'port': None,
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
def checkReturnCode(code):
|
def checkReturnCode(code):
|
||||||
if code == 0:
|
if code == 0:
|
||||||
|
|
@ -48,11 +72,11 @@ class Arduino:
|
||||||
print('Invalid argument')
|
print('Invalid argument')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def verify(sketch, board):
|
def verify(sketch, boardId):
|
||||||
return Arduino.checkReturnCode(subprocess.call([
|
return Arduino.checkReturnCode(subprocess.call([
|
||||||
Arduino.binary,
|
Arduino.binary,
|
||||||
'--verify', sketch,
|
'--verify', sketch,
|
||||||
'--board', board,
|
'--board', boardId,
|
||||||
#'--verbose-build',
|
#'--verbose-build',
|
||||||
], stdout = open(os.devnull, 'wb')))
|
], stdout = open(os.devnull, 'wb')))
|
||||||
|
|
||||||
|
|
@ -97,11 +121,11 @@ class ArduinoMidiLibrary:
|
||||||
return [os.path.join(exDir, x, x + '.ino') for x in os.listdir(exDir)]
|
return [os.path.join(exDir, x, x + '.ino') for x in os.listdir(exDir)]
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for boardName, boardId in Arduino.boards.items():
|
for board in Arduino.boards:
|
||||||
# Validate examples
|
# Validate examples
|
||||||
print('Validation for Arduino %s' % boardName)
|
print('Validation for Arduino %s' % board.name)
|
||||||
for example in self.getInstalledExamples():
|
for example in self.getInstalledExamples():
|
||||||
if not Arduino.verify(example, boardId):
|
if not Arduino.verify(example, board.id):
|
||||||
print('{0:40} {1}'.format(os.path.basename(example), 'FAILED'))
|
print('{0:40} {1}'.format(os.path.basename(example), 'FAILED'))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue