Beispiel #1
0
    def paint(self):
        for light in self.lights():
            # TODO: Support setting top and bottom separately (have the data,
            # just don't want to figure out the query rn)
            query = "$sequence=%d" % light.sequence
            core.query(self.rig, query).setRGBRaw(*light.color)

        self.rig.updateOnce()
Beispiel #2
0
def notifications(id):
    """
    Return a list of all users who should be notified of an event on a stream.
    Parameters:
        id - a stream id.
    Returns:
        A list of stream user ids who are currently being notified of events on a stream.
    """
    return core.query(schema.notify, id)
Beispiel #3
0
def eventsForStream(streamId):
    """
    Return all the events on a stream.
    Parameters:
        streamId - a stream id.
    Returns:
        a list of event documents.
    """
    return core.query(schema.eventByStream, streamId)
Beispiel #4
0
def subscribers(id):
    """
    Returns the list of users subscribed to a stream.
    Parameters:
        id - a stream id.
    Returns:
        a list of stream documents.
    """
    return core.query(schema.streamBySubscribers, id)
Beispiel #5
0
def streamsForObjectRef(objectRef):
    """
    All streams for a objectRef, where objectRef is "type:id".
    Parameters:
        objectRef - a object reference. Always "type:id".
    Returns:
        a list of stream documents.
    """
    return core.query(schema.streamByObjectRef, objectRef)
Beispiel #6
0
def eventsForUser(userId):
    """
    Return all the user's events.
    Parameters:
        userId - a user id.
    Returns:
        a list of event documents.
    """
    return core.query(schema.eventByUser, userId)
Beispiel #7
0
def streamsByCreator(userId):
    """
    All streams created by a particular user.
    Parameters:
        userId - a user id.
    Returns:
        a list of stream documents.
    """
    return core.query(schema.streamByCreator, userId)
Beispiel #8
0
def comments(id):
    """
    Get all the comments posted by a user.
    Parameters:
        id - a user id
    Returns:
        A list of comments.
    """ 
    db = core.connect()
    return joinCommentData(core.query(schema.commentsByUser, id))
Beispiel #9
0
def permissionsForStream(streamId):
    """
    Returns all permission documents a particular stream.
    Parameters:
        streamId - a stream id.
    Returns:
        a list of permission documents.
    """
    db = core.connect()
    return core.query(schema.permissionByStream, streamId)
Beispiel #10
0
def permissionsForUser(userId):
    """
    Returns all permission documents for a particular user.
    Parameters:
        userId - a user id.
    Returns:
        a list of permission documents.
    """
    db = core.connect()
    return core.query(schema.permissionByUser, userId)
Beispiel #11
0
def byUserName(userName, userId=None):
    """
    Return the list of shifts a user has created.
    Parameters:
        userName - a user name.
    Returns:
        A list of the user's shifts.
    """
    id = user.idForName(userName)
    return core.query(schema.shiftByUser, id)
Beispiel #12
0
def byHref(href, userId=None):
    """
    Return the list of shifts at a particular url.
    Parameters:
        href - a url.
    Returns:
        A list of public shift's on the specified url.
    """
    shifts = core.query(schema.shiftByHref, href)
    return shifts
Beispiel #13
0
def favorites(id):
    """
    Get all of a user's favorites.
    Parameters:
        id - a user id.
    Returns:
        A list of favorites.
    """
    db = core.connect()
    shiftIds = core.query(schema.favoritesByUser, id)
    shifts = [db[id] for id in shiftIds]
    return shift.joinData(shifts, id)
    def post(self):
        sample = TornadoFile.create_from_request(self.request)
        tags = escape.json_decode(self.request.body_arguments['tags'][0])
        add_tag = strl_to_intl(tags['add'])
        sub_tag = strl_to_intl(tags['sub'])

        report = core.query(self.app_context, sample, add_tag, sub_tag)
        report = ast.literal_eval(str(report))
        self.set_status(HTTPStatus.OK)
        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(report))
        self.flush()
        self.finish()
Beispiel #15
0
def deleteAllStreams():
    streamIds = [astream["_id"] for astream in core.query(schema.allStreams)]
    [stream.delete(streamId) for streamId in streamIds]
Beispiel #16
0
def deleteAllPermissions():
    permIds = [aperm["_id"] for aperm in core.query(schema.allPermissions)]
    [permission.delete(permId) for permId in permIds]
Beispiel #17
0
def deleteAllShifts():
    shiftIds = [ashift["_id"] for ashift in core.query(schema.allShifts)]
    [permission.delete(shiftId) for shiftId in shiftIds]
Beispiel #18
0
def inGroup(id):
    """
    Returns all users in a particular group.
    """
    db = core.connect()
    return core.query(schema.allGroups, id)
Beispiel #19
0
def deleteAllEvents():
    eventIds = [aevent["_id"] for aevent in core.query(schema.allEvents)]
    [event.delete(eventId) for eventId in eventIds]
Beispiel #20
0
def byUser(id, userId=None):
    return core.query(schema.shiftByUser, id)