Example #1
0
def script_remove(script_id):
    store = stores.get_store('scripts')
    rec = store.get(script_id)
    if rec is None:
        return _not_found_error("Script not found")

    store.remove(script_id)
    return dict(status=defines.SUCCESS, data=script_id)
Example #2
0
def script_remove(script_id):
    store = stores.get_store('scripts')
    rec = store.get(script_id)
    if rec is None:
        return _not_found_error("Script not found")

    store.remove(script_id)
    return dict(status=defines.SUCCESS, data=script_id)
Example #3
0
def script_get(script_id):
    _logger.debug("Fetching script: %s", 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")

    return dict(status=defines.SUCCESS, data=rec[0])
Example #4
0
def script_get(script_id):
    _logger.debug("Fetching script: %s", 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")

    return dict(status=defines.SUCCESS, data=rec[0])
Example #5
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)
Example #6
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)
Example #7
0
def notice_delete(notice_id):
    _logger.debug("Delete notice with ID: %s", notice_id)
    store = stores.get_store('notices')

    rec = store.get(notice_id)
    if rec is None:
        response.status_code = 404
        return dict(status=defines.ERROR, reason="Notice not found")

    store.remove(notice_id)

    return dict(status=defines.SUCCESS, data=notice_id)
Example #8
0
def notice_delete(notice_id):
    _logger.debug("Delete notice with ID: %s", notice_id)
    store = stores.get_store('notices')

    rec = store.get(notice_id)
    if rec is None:
        response.status_code = 404
        return dict(status=defines.ERROR, reason="Notice not found")

    store.remove(notice_id)

    return dict(status=defines.SUCCESS, data=notice_id)
Example #9
0
def notice_list():
    store = stores.get_store('notices')
    result = []

    count = 100
    with store.cursor() as cur:
        for k in cur.iterprev(keys=True, values=True):
            rec = cur.value()
            result.append(rec[0])
            count -= 1
            if count == 0:
                break

    return dict(status=defines.SUCCESS, data=result)
Example #10
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)
Example #11
0
def notice_list():
    store = stores.get_store('notices')
    result = []

    count = 100
    with store.cursor() as cur:
        for k in cur.iterprev(keys=True, values=True):
            rec = cur.value()
            result.append(rec[0])
            count -= 1
            if count == 0:
                break

    return dict(status=defines.SUCCESS, data=result)
Example #12
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)
Example #13
0
 def start(self, context):
     self._context = context
     context.connect(self.on_user_notified, signal=USER_NOTIFIED)
     self._notice_store = get_store('notices')