Example #1
0
def add_build():
    data = request.get_json()
    validate = {
        "filename": "str",
        "device": "str",
        "version": "str",
        "md5sum": "str",
        "url": "str",
        "romtype": "str"
    }

    #bad data sent
    if not data:
        return jsonify(validate), 400
    #validate keys all exist
    for key in validate.keys():
        if key not in data:
            return jsonify(validate), 406

    # validate types
    for key in validate.keys():
        try:
            locate(validate[key])(data[key])
        except:
            return jsonify({
                "error":
                "{} must be parseable by python's {} class".format(
                    key, validate[key])
            }), 406
    rom = Rom(**data)
    rom.save()
    return "ok", 200
Example #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)
Example #3
0
def get_build_types(device, romtype, after, version, incrementalversion):
    roms = []

    roms = Incremental.get_incrementals(device=device, romtype=romtype, before=app.config['BUILD_SYNC_TIME'], incremental=incrementalversion)

    if not len(roms):
        roms = Rom.get_roms(device=device, romtype=romtype, before=app.config['BUILD_SYNC_TIME'])

    if after:
        roms = roms(datetime__gt=after)
    if version:
        roms = roms(version=version)

    roms = roms.order_by('datetime')
    data = []

    for rom in roms:
        data.append({
            "id": str(rom.id),
            "url": rom.url,
            "romtype": rom.romtype,
            "datetime": int(time.mktime(rom.datetime.timetuple())),
            "version": rom.version,
            "filesize": rom.romsize,
            "filename": rom.filename
        })
    return jsonify({'response': data})
Example #4
0
def addrom(filename, device, version, datetime, romtype, md5sum, url):
    Rom(filename=filename,
        datetime=datetime,
        device=device,
        version=version,
        romtype=romtype,
        md5sum=md5sum,
        url=url).save()
Example #5
0
def web_extras():
    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])))

    return render_template("extras.html",
                           active_device=None,
                           oems=oems,
                           devices=devices,
                           extras=True)
Example #6
0
def show_changelog(device='all', before=-1):
    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])))
    return render_template('changes.html',
                           active_device=None,
                           oems=oems,
                           devices=devices,
                           device=device,
                           before=before,
                           changelog=True)
Example #7
0
def addrom(filename,
           device,
           version,
           datetime,
           romtype,
           md5sum,
           size,
           url,
           hasbootimg=False,
           sticky=False):
    Rom(filename=filename,
        datetime=datetime,
        device=device,
        version=version,
        romtype=romtype,
        md5sum=md5sum,
        romsize=size,
        url=url,
        hasbootimg=hasbootimg,
        sticky=sticky).save()
Example #8
0
def delrom(filename):
    Rom.objects(filename=filename).delete()
Example #9
0
def api_v1_delete_file(filename):
    Rom.objects(filename=filename).delete()
    return '', 200
Example #10
0
def api_v1_devices():
    return jsonify(Rom.get_current_devices_by_version())
Example #11
0
def get_types(device):
    types = set(["nightly"])
    for rtype in Rom.get_types(device):
        types.add(rtype)
    return jsonify({'response': list(types)})
Example #12
0
def check_builds():
    for r in Rom.objects():
        if requests.head(r.url).status_code == 404:
            print("Rom.objects(filename=\"{}\").delete()".format(r.filename))
Example #13
0
def changes(device='all', before=-1):
    if device == 'all':
        device = None
    return jsonify(get_changes(gerrit, device, before, Rom.get_device_version(device), app.config.get('STATUS_URL', '#')))
Example #14
0
def changes(device='all', before=-1):
    if device == 'all':
        device = None
    return jsonify(get_changes(gerrit, device, before, Rom.get_device_version(device)))