Exemple #1
0
def import_devices():
    with open("devices.json", "r") as f:
        data = json.load(f)
        for device in data:
            d = Device.objects(model=device['model'])
            if d:
                d.update(**device)
            else:
                Device(**device).save()
    if os.path.isfile("devices_local.json"):
        with open("devices_local.json", "r") as f:
            data = json.load(f)
            for device in data:
                d = Device.objects(model=device['model'])
                if d:
                    d.update(**device)
                else:
                    Device(**device).save()
Exemple #2
0
def web_device(device):
    devices = sorted([x for x in Device.get_devices() if x['model'] in Rom.get_devices()], key=lambda device: device['name'])
    oems = sorted(list(set([x['oem'] for x in devices])))

    roms = Rom.get_roms(device=device, before=app.config['BUILD_SYNC_TIME'])

    active_oem = [x['oem'] for x in devices if x['model'] == device]
    active_oem = active_oem[0] if active_oem else None

    active_device = Device.objects(model=device).first()

    return render_template("device.html", active_oem=active_oem, active_device=active_device, oems=oems, devices=devices, roms=roms, get_timestamp=get_timestamp)
Exemple #3
0
def check_builds():
    for d in Device.objects():
        if requests.head(d.url).status_code == 404:
            print "Rom.objects(filename={}).delete()".format(d.filename)