Example #1
0
def cpu_name_from_data(data):
    """Returns the CPU name from the given data if it exists."""
    device = DeviceContextType.primary_value_for_data(data)
    if device:
        arch = device.get('arch')
        if isinstance(arch, six.string_types):
            return arch

    # TODO: kill this here.  we want to not support that going forward
    unique_cpu_name = None
    images = (data.get('debug_meta') or {}).get('images') or []
    for img in images:
        if img.get('arch') and arch_is_known(img['arch']):
            cpu_name = img['arch']
        elif img.get('cpu_type') is not None \
                and img.get('cpu_subtype') is not None:
            cpu_name = arch_from_macho(img['cpu_type'], img['cpu_subtype'])
        else:
            cpu_name = None
        if unique_cpu_name is None:
            unique_cpu_name = cpu_name
        elif unique_cpu_name != cpu_name:
            unique_cpu_name = None
            break

    return unique_cpu_name
Example #2
0
def cpu_name_from_data(data):
    """Returns the CPU name from the given data if it exists."""
    device = DeviceContextType.primary_value_for_data(data)
    if device:
        arch = device.get('arch')
        if isinstance(arch, six.string_types):
            return arch

    # TODO: kill this here.  we want to not support that going forward
    unique_cpu_name = None
    images = (data.get('debug_meta') or {}).get('images') or []
    for img in images:
        if img.get('arch') and arch_is_known(img['arch']):
            cpu_name = img['arch']
        elif img.get('cpu_type') is not None \
                and img.get('cpu_subtype') is not None:
            cpu_name = arch_from_macho(img['cpu_type'], img['cpu_subtype'])
        else:
            cpu_name = None
        if unique_cpu_name is None:
            unique_cpu_name = cpu_name
        elif unique_cpu_name != cpu_name:
            unique_cpu_name = None
            break

    return unique_cpu_name
Example #3
0
def cpu_name_from_data(data):
    """Returns the CPU name from the given data if it exists."""
    device = DeviceContextType.primary_value_for_data(data)
    if device and device.get('arch'):
        return device['arch']

    # TODO: kill this here.  we want to not support that going forward
    unique_cpu_name = None
    for img in get_path(data, 'debug_meta', 'images', filter=True, default=()):
        if img.get('arch') and arch_is_known(img['arch']):
            cpu_name = img['arch']
        elif img.get('cpu_type') is not None \
                and img.get('cpu_subtype') is not None:
            cpu_name = arch_from_macho(img['cpu_type'], img['cpu_subtype'])
        else:
            cpu_name = None
        if unique_cpu_name is None:
            unique_cpu_name = cpu_name
        elif unique_cpu_name != cpu_name:
            unique_cpu_name = None
            break

    return unique_cpu_name
Example #4
0
def cpu_name_from_data(data):
    """Returns the CPU name from the given data if it exists."""
    device = DeviceContextType.primary_value_for_data(data)
    if device and device.get('arch'):
        return device['arch']

    # TODO: kill this here.  we want to not support that going forward
    unique_cpu_name = None
    for img in get_path(data, 'debug_meta', 'images', filter=True, default=()):
        if img.get('arch') and arch_is_known(img['arch']):
            cpu_name = img['arch']
        elif img.get('cpu_type') is not None \
                and img.get('cpu_subtype') is not None:
            cpu_name = arch_from_macho(img['cpu_type'], img['cpu_subtype'])
        else:
            cpu_name = None
        if unique_cpu_name is None:
            unique_cpu_name = cpu_name
        elif unique_cpu_name != cpu_name:
            unique_cpu_name = None
            break

    return unique_cpu_name