예제 #1
0
def validate_products(db):
    usedproducts = gather_products(db)
    knownproducts = update_products.load_products()
    for product in usedproducts:
        if knownproducts.get(product, None) is None:
            print(
                "WARN: Model %s is used in DataBase but not present in Products!"
                % product)
            continue
        if knownproducts[product][
                update_products.KEY_STATUS] != update_products.STATUS_OK:
            print(
                "WARN: Model %s is used in DataBase but not valid in Products!"
                % product)
            continue

    to_add = {}

    for product in knownproducts:
        if knownproducts[product][
                update_products.KEY_STATUS] != update_products.STATUS_OK:
            continue

        name = knownproducts[product][update_products.KEY_NAME]
        if name.find('Mac') < 0 and name.find('Xserve') < 0:
            continue

        if product not in usedproducts:
            print("WARN: Model %s (%s) is known but is not used in DataBase!" %
                  (product, name))

            if to_add.get(name, None) is None:
                to_add[name] = []
            to_add[name].append(product)
            continue

    if len(to_add) > 0:
        for sysname in to_add:
            for info in db:
                if sysname in info['Specifications']['SystemReportName']:
                    print("New AppleModelCode for {}:".format(
                        info['SystemProductName']))
                    for model in to_add[sysname]:
                        print("  - \"{}\"".format(model))
예제 #2
0
def export_mlb_boards(db, boards):
    l = {}
    for info in db:
        if len(info['SystemSerialNumber']) == 12:
            models = [info['BoardProduct']] if not isinstance(
                info['BoardProduct'], list) else info['BoardProduct']

            for model in models:
                if info['MaximumOSVersion'] is None:
                    l[model] = 'latest'
                else:
                    l[model] = info['MaximumOSVersion']

    with open(boards, 'w') as fh:
        json.dump(l, fh, indent=1)


if __name__ == '__main__':
    db = load_db('DataBase')
    dbpd = update_products.load_products()
    # Run test phase to validate the library
    validate_products(db, dbpd)
    export_db_macinfolib(db, os.devnull)
    export_db_macserial(db, dbpd, os.devnull)
    # Export new models
    export_db_macinfolib(db, '../Library/OcMacInfoLib/AutoGenerated.c')
    export_db_macserial(db, dbpd, '../Utilities/macserial/modelinfo_autogen.h')
    # Export MLB models
    export_mlb_boards(db, '../Utilities/macrecovery/boards.json')