def test_valid_arduino_sdk_version(self):
        sdk_folder = self.new_tmp_folder()
        if platform.system() == 'Darwin':
            sdk_folder = os.path.join(sdk_folder, "Arduino.app/Contents/Resources/Java")

        lib_folder = os.path.join(sdk_folder, "lib")
        os.makedirs(lib_folder)
        with open(os.path.join(lib_folder, "version.txt"), "w") as versiontxt:
            versiontxt.write("1.0.6")

        self.assertEquals("1.0.6", valid_arduino_sdk_version(sdk_folder))

        # Delete SDK
        shutil.rmtree(os.path.join(lib_folder))
        self.assertIsNone(valid_arduino_sdk_version(sdk_folder))
示例#2
0
    def test_valid_arduino_sdk_version(self):
        sdk_folder = self.new_tmp_folder()
        if platform.system() == 'Darwin':
            sdk_folder = os.path.join(sdk_folder,
                                      "Arduino.app/Contents/Resources/Java")

        lib_folder = os.path.join(sdk_folder, "lib")
        os.makedirs(lib_folder)
        with open(os.path.join(lib_folder, "version.txt"), "w") as versiontxt:
            versiontxt.write("1.0.6")

        self.assertEquals("1.0.6", valid_arduino_sdk_version(sdk_folder))

        # Delete SDK
        shutil.rmtree(os.path.join(lib_folder))
        self.assertIsNone(valid_arduino_sdk_version(sdk_folder))
def arduino_settings_args(user_io, args, settings):
    ''' Method to select (without any wizard) from command line your SDK,
        port, board and automatic reset.
        Port and SDK arguments support "default" option to make automatically
        the setting selection
    '''
    if settings.arduino is None:
        settings.arduino = ArduinoSettings()
    if not args.sdk and not settings.arduino.sdk:
        _, default_sdk = get_valid_sdks(user_io, settings.arduino)
        user_io.out.success("Your default SDK is: %s" % default_sdk)
        settings.arduino.sdk = default_sdk
    else:
        settings.arduino.sdk = args.sdk or settings.arduino.sdk
    try:
        valid_version = valid_arduino_sdk_version(settings.arduino.sdk)
    except:
        valid_version = None
    if not valid_version:
        raise BiiException("No valid Arduino SDK version could be found."
                           " Check if /your_SDK_path/lib/version.txt file exists")
    settings.arduino.version = valid_version
    if args.need_reset:
        settings.arduino.automatic_reset = True if args.need_reset == 'true' else None
    if (not args.port and not settings.arduino.port) or args.port == 'auto':
        settings.arduino.port = refresh_port(user_io,
                                             settings.arduino.port,
                                             reset=settings.arduino.automatic_reset,
                                             wizard=False)
    else:
        settings.arduino.port = args.port or settings.arduino.port
    settings.arduino.board = args.board or settings.arduino.board
示例#4
0
def _arduino_sdk_wizard(user_io, arduino_settings):
    ''' User'll set his Arduino SDK path or will select the
        auto-detection of the Arduino SDK path located in
        biicode_env folder.
    '''
    sdks, default_sdk = get_valid_sdks(user_io, arduino_settings)
    sdk_path = user_io.request_string("Enter SDK number or type path",
                                      default_sdk)
    sdk_path = sdk_path or default_sdk or "None"
    try:
        number = int(sdk_path)
    except ValueError:
        selected_sdk = sdk_path
        selected_version = valid_arduino_sdk_version(sdk_path, user_io.out)
        if not selected_version:
            user_io.out.error("SDK not valid: %s" % sdk_path)
            selected_version = "None"
    else:
        try:
            selected_sdk, selected_version = sdks[number]
        except IndexError:
            raise BiiException(
                "Bad Index %d, please select number or type path" % number)

    arduino_settings.sdk = selected_sdk.replace('\\', '/')
    arduino_settings.version = selected_version
示例#5
0
def arduino_settings_args(user_io, args, settings):
    ''' Method to select (without any wizard) from command line your SDK,
        port, board and automatic reset.
        Port and SDK arguments support "default" option to make automatically
        the setting selection
    '''
    if settings.arduino is None:
        settings.arduino = ArduinoSettings()
    if not args.sdk and not settings.arduino.sdk:
        _, default_sdk = get_valid_sdks(user_io, settings.arduino)
        user_io.out.success("Your default SDK is: %s" % default_sdk)
        settings.arduino.sdk = default_sdk
    else:
        settings.arduino.sdk = args.sdk or settings.arduino.sdk
    try:
        valid_version = valid_arduino_sdk_version(settings.arduino.sdk)
    except:
        valid_version = None
    if not valid_version:
        raise BiiException(
            "No valid Arduino SDK version could be found."
            " Check if /your_SDK_path/lib/version.txt file exists")
    settings.arduino.version = valid_version
    if args.need_reset:
        settings.arduino.automatic_reset = True if args.need_reset == 'true' else None
    if (not args.port and not settings.arduino.port) or args.port == 'auto':
        settings.arduino.port = refresh_port(
            user_io,
            settings.arduino.port,
            reset=settings.arduino.automatic_reset,
            wizard=False)
    else:
        settings.arduino.port = args.port or settings.arduino.port
    settings.arduino.board = args.board or settings.arduino.board
def _arduino_sdk_wizard(user_io, arduino_settings):
    ''' User'll set his Arduino SDK path or will select the
        auto-detection of the Arduino SDK path located in
        biicode_env folder.
    '''
    sdks, default_sdk = get_valid_sdks(user_io, arduino_settings)
    sdk_path = user_io.request_string("Enter SDK number or type path", default_sdk)
    sdk_path = sdk_path or default_sdk or "None"
    try:
        number = int(sdk_path)
    except ValueError:
        selected_sdk = sdk_path
        selected_version = valid_arduino_sdk_version(sdk_path, user_io.out)
        if not selected_version:
            user_io.out.error("SDK not valid: %s" % sdk_path)
            selected_version = "None"
    else:
        try:
            selected_sdk, selected_version = sdks[number]
        except IndexError:
            raise BiiException("Bad Index %d, please select number or type path" % number)

    arduino_settings.sdk = selected_sdk.replace('\\', '/')
    arduino_settings.version = selected_version