def remove_boards_gui(hwpack=""): """remove boards by GUI.""" if not hwpack: if len(hwpack_names()) > 1: hwpack = psidialogs.choice(hwpack_names(), "select hardware package to select board from!", title="select") else: hwpack = hwpack_names()[0] print("%s selected" % hwpack) if hwpack: sel = psidialogs.multi_choice( board_names(hwpack), "select boards to remove from %s!" % boards_txt(hwpack), title="remove boards" ) print("%s selected" % sel) if sel: for x in sel: remove_board(x) print("%s was removed" % x)
def install_board(board_id, board_options, hwpack='arduino', replace_existing=False): """install board in boards.txt. :param board_id: string identifier :param board_options: dict like :param replace_existing: bool :rtype: None """ doaction = 0 if board_id in boards(hwpack).keys(): log.debug('board already exists: %s', board_id) if replace_existing: log.debug('remove board: %s' , board_id) remove_board(board_id) doaction = 1 else: doaction = 1 if doaction: lines = bunch2properties(board_id, board_options) boards_txt().write_lines([''] + lines, append=1)
def remove_boards_gui(hwpack=''): """remove boards by GUI.""" if not hwpack: if len(hwpack_names()) > 1: hwpack = psidialogs.choice( hwpack_names(), 'select hardware package to select board from!', title='select') else: hwpack = hwpack_names()[0] print('%s selected' % hwpack) if hwpack: sel = psidialogs.multi_choice(board_names(hwpack), 'select boards to remove from %s!' % boards_txt(hwpack), title='remove boards') print('%s selected' % sel) if sel: for x in sel: remove_board(x) print('%s was removed' % x)
def test_boards(self): d = tmpdir(suffix='_test') os.environ['ARDUINO_HOME'] = d boards_txt = d / 'hardware' / 'arduino' / 'boards.txt' boards_txt.parent.makedirs() boards_txt.write_text('') eq_(board_names(), []) check_keys(boards().keys(), []) # invalid board boards_txt.write_text(''' brd.x3=foo ''') eq_(board_names(), []) boards_txt.write_text(''' brd.name=foo brd.build=foo brd.x3=foo ''') eq_(board_names(), ['brd']) check_keys(boards().keys(), ['brd']) # invalid install_board('ardu', dict(x1='hi')) eq_(board_names(), ['brd']) install_board('ardu', dict(name='hi', build=1)) eq_(set(board_names()), set(['brd', 'ardu'])) install_board('ardu', dict(x1='hi')) eq_(set(board_names()), set(['brd', 'ardu'])) remove_board('brd') eq_(board_names(), ['ardu'])