Beispiel #1
0
def script_list():
    result = []
    s = Script(title="Check GMail every 1 minute", text="script contents", auto_start=True)
    result.append(s.to_dict())
    # with script_store.cursor() as cur:
    #    for k in cur.iternext(keys=True, values=True):
    #        rec = cur.value()
    #        result.append(rec[0])
    return dict(status=D.SUCCESS, data=result)
Beispiel #2
0
def script_update(script_id):
    script_store = stores.get_store('scripts')
    rec = script_store.get(script_id)
    if rec is None:
        return _not_found_error("Script not found")

    script = Script(**rec[0])
    script.update(request.json)
    script_store[script.id] = [script.to_dict(), clock.tick()]

    return dict(status=defines.SUCCESS, data=script_id)
Beispiel #3
0
def script_update(script_id):
    script_store = stores.get_store('scripts')
    rec = script_store.get(script_id)
    if rec is None:
        return _not_found_error("Script not found")

    script = Script(**rec[0])
    script.update(request.json)
    script_store[script.id] = [script.to_dict(), clock.tick()]

    return dict(status=defines.SUCCESS, data=script_id)
Beispiel #4
0
def script_list():
    result = []
    s = Script(title="Check GMail every 1 minute",
               text="script contents",
               auto_start=True)
    result.append(s.to_dict())
    # with script_store.cursor() as cur:
    #    for k in cur.iternext(keys=True, values=True):
    #        rec = cur.value()
    #        result.append(rec[0])
    return dict(status=defines.SUCCESS, data=result)
Beispiel #5
0
def script_create():
    script_store = stores.get_store('scripts')
    d = request.json

    if d.get('id') is not None:
        response.status = defines.HTTP_STATUS_BAD_REQUEST
        return dict(status=defines.ERROR, reason="Invalid data.")

    script = Script(**d)
    assert script.id is not None
    with script_store.cursor(readonly=False) as cur:
        cur.put(script.id, [script.to_dict(), clock.tick()])

    return dict(status=defines.SUCCESS, data=script.id)
Beispiel #6
0
def script_create():
    script_store = stores.get_store('scripts')
    d = request.json

    if d.get('id') is not None:
        response.status = defines.HTTP_STATUS_BAD_REQUEST
        return dict(status=defines.ERROR, reason="Invalid data.")

    script = Script(**d)
    assert script.id is not None
    with script_store.cursor(readonly=False) as cur:
        cur.put(script.id, [script.to_dict(), clock.tick()])

    return dict(status=defines.SUCCESS, data=script.id)