def get_unique_tools_with_greatest_version(tools): ''' We only want to test each tool once. Lists of tools from across a sandbox might repeat the identical tool more than once, or might name a tool with different versions or different platforms. Reduce the specified list to the smaller set of just what we should test. ''' t = [] for tx in tools: append = True # Look for dups for j in range(len(t)): if tx.tool == t[j].tool: unioned_platforms = None # If platforms intersect instead of being disjoint, then the # tools are considered a match and should be merged. tx_implied = buildinfo.get_implied_platform_variants( tx.platforms) tj_implied = buildinfo.get_implied_platform_variants( t[j].platforms) intersection = set(tx_implied) & set(tj_implied) if intersection: #print('intersection for %s on %s' % (tx.tool, str(intersection))) append = False unioned_platforms = set(tx.platforms) | set(t[j].platforms) if tx.version > t[j].version: t[j] = tx if unioned_platforms: t[j].platforms = unioned_platforms break if append: t.append(tx) t.sort(key=lambda x: x.tool) return t
def get_unique_tools_with_greatest_version(tools): ''' We only want to test each tool once. Lists of tools from across a sandbox might repeat the identical tool more than once, or might name a tool with different versions or different platforms. Reduce the specified list to the smaller set of just what we should test. ''' t = [] for tx in tools: append = True # Look for dups for j in range(len(t)): if tx.tool == t[j].tool: unioned_platforms = None # If platforms intersect instead of being disjoint, then the # tools are considered a match and should be merged. tx_implied = buildinfo.get_implied_platform_variants(tx.platforms) tj_implied = buildinfo.get_implied_platform_variants(t[j].platforms) intersection = set(tx_implied) & set(tj_implied) if intersection: #print('intersection for %s on %s' % (tx.tool, str(intersection))) append = False unioned_platforms = set(tx.platforms) | set(t[j].platforms) if tx.version > t[j].version: t[j] = tx if unioned_platforms: t[j].platforms = unioned_platforms break if append: t.append(tx) t.sort(key=lambda x:x.tool) return t
def check_tools(required_tools, targeted_platform_variant=None, quiet=False): exitcode = 0 # Only test the highest version of each tool -- and only do so once per tool. required_tools = get_unique_tools_with_greatest_version(required_tools) required_tools_name_width = 10 if required_tools: required_tools_name_width = max( [len(tool.tool) for tool in required_tools]) + 1 if not targeted_platform_variant: targeted_platform_variant = buildinfo.get_natural_platform_variant() else: targeted_platform_variant = buildinfo.fuzzy_match_platform_variant( targeted_platform_variant) if required_tools: for tool in required_tools: if tool.platforms is None and tool.verify is None: if not quiet: eprintc( '''No information for %s. Please provide information to be able to verify that %s is properly set up on this machine.''' % (tool.tool, tool.tool), ERROR_COLOR) exitcode = 1 else: platforms = buildinfo.get_implied_platform_variants( tool.platforms) #print('tool %s has implied platforms %s; looking for %s' % (tool.tool, '|'.join(platforms), targeted_platform_variant)) if targeted_platform_variant in platforms: if verify_command_in_path(tool, required_tools_name_width, quiet=quiet): exitcode = 1 if os.name == 'nt': if os.path.exists(os.path.join(os.getcwd(), 'TempWmicBatchFile.bat')): os.remove(os.path.join(os.getcwd(), 'TempWmicBatchFile.bat')) return exitcode
def check_tools(required_tools, targeted_platform_variant=None, quiet=False): exitcode = 0 # Only test the highest version of each tool -- and only do so once per tool. required_tools = get_unique_tools_with_greatest_version(required_tools) required_tools_name_width = 10 if required_tools: required_tools_name_width = max([len(tool.tool) for tool in required_tools]) + 1 if not targeted_platform_variant: targeted_platform_variant = buildinfo.get_natural_platform_variant() else: targeted_platform_variant = buildinfo.fuzzy_match_platform_variant(targeted_platform_variant) if required_tools: for tool in required_tools: if tool.platforms is None and tool.verify is None: if not quiet: eprintc('''No information for %s. Please provide information to be able to verify that %s is properly set up on this machine.''' % (tool.tool, tool.tool), ERROR_COLOR) exitcode = 1 else: platforms = buildinfo.get_implied_platform_variants(tool.platforms) #print('tool %s has implied platforms %s; looking for %s' % (tool.tool, '|'.join(platforms), targeted_platform_variant)) if targeted_platform_variant in platforms: if verify_command_in_path(tool, required_tools_name_width, quiet=quiet): exitcode = 1 if os.name == 'nt': if os.path.exists(os.path.join(os.getcwd(), 'TempWmicBatchFile.bat')): os.remove(os.path.join(os.getcwd(), 'TempWmicBatchFile.bat')) return exitcode