def discover(self): self.e.find_arduino_file( 'version.txt', ['lib'], human_name='Arduino lib version file (version.txt)') if 'arduino_lib_version' not in self.e: with open(self.e['version.txt']) as f: print 'Detecting Arduino software version ... ', v_string = f.read().strip() v = Version.parse(v_string) self.e['arduino_lib_version'] = v print colorize("%s (%s)" % (v, v_string), 'green') self.e.find_arduino_dir('arduino_core_dir', [ 'hardware', 'arduino', 'cores', 'arduino' ], ['Arduino.h'] if self.e.arduino_lib_version.major else 'WProgram.h', 'Arduino core library') self.e.find_arduino_dir('arduino_libraries_dir', ['libraries'], human_name='Arduino standard libraries') if self.e.arduino_lib_version.major: self.e.find_arduino_dir('arduino_variants_dir', ['hardware', 'arduino', 'variants'], human_name='Arduino variants directory') toolset = [ ('cc', 'avr-gcc'), ('cxx', 'avr-g++'), ('ar', 'avr-ar'), ('objcopy', 'avr-objcopy'), ] # Linux has system-wide avr gcc toolset # other platforms are bundled with it as a part of Arduino Software system_wide = platform.system() == 'Linux' for tool_key, tool_binary in toolset: if system_wide: self.e.find_tool(tool_key, [tool_binary], human_name=tool_binary) else: self.e.find_arduino_tool(tool_key, ['hardware', 'tools', 'avr', 'bin'], items=[tool_binary], human_name=tool_binary)
def discover(self): self.e.find_arduino_file('version.txt', ['lib'], human_name='Arduino lib version file (version.txt)') if 'arduino_lib_version' not in self.e: with open(self.e['version.txt']) as f: print 'Detecting Arduino software version ... ', v_string = f.read().strip() v = Version.parse(v_string) self.e['arduino_lib_version'] = v print colorize("%s (%s)" % (v, v_string), 'green') self.e.find_arduino_dir('arduino_core_dir', ['hardware', 'arduino', 'cores', 'arduino'], ['Arduino.h'] if self.e.arduino_lib_version.major else 'WProgram.h', 'Arduino core library') self.e.find_arduino_dir('arduino_libraries_dir', ['libraries'], human_name='Arduino standard libraries') if self.e.arduino_lib_version.major: self.e.find_arduino_dir('arduino_variants_dir', ['hardware', 'arduino', 'variants'], human_name='Arduino variants directory') toolset = [ ('cc', 'avr-gcc'), ('cxx', 'avr-g++'), ('ar', 'avr-ar'), ('objcopy', 'avr-objcopy'), ] # Linux has system-wide avr gcc toolset # other platforms are bundled with it as a part of Arduino Software system_wide = platform.system() == 'Linux' for tool_key, tool_binary in toolset: if system_wide: self.e.find_tool(tool_key, [tool_binary], human_name=tool_binary) else: self.e.find_arduino_tool(tool_key, ['hardware', 'tools', 'avr', 'bin'], items=[tool_binary], human_name=tool_binary)
def test_parsing(self): assert_equal(Version.parse('0022'), (0, 22, 0)) assert_equal(Version.parse('0022ubuntu0.1'), (0, 22, 0)) assert_equal(Version.parse('0022-macosx-20110822'), (0, 22, 0)) assert_equal(Version.parse('1.0'), (1, 0, 0)) assert_equal(Version.parse('1:1.0.5+dfsg2-1'), (1, 0, 5))
def test_int_conversion(self): assert_equal(Version(0, 22, 0).as_int(), 22) assert_equal(Version(1, 0, 0).as_int(), 100) assert_equal(Version(1, 0, 5).as_int(), 105) assert_equal(Version(1, 5, 1).as_int(), 151)