Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 14
0
    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()
Exemplo n.º 15
0
def deleteAllStreams():
    streamIds = [astream["_id"] for astream in core.query(schema.allStreams)]
    [stream.delete(streamId) for streamId in streamIds]
Exemplo n.º 16
0
def deleteAllPermissions():
    permIds = [aperm["_id"] for aperm in core.query(schema.allPermissions)]
    [permission.delete(permId) for permId in permIds]
Exemplo n.º 17
0
def deleteAllShifts():
    shiftIds = [ashift["_id"] for ashift in core.query(schema.allShifts)]
    [permission.delete(shiftId) for shiftId in shiftIds]
Exemplo n.º 18
0
def inGroup(id):
    """
    Returns all users in a particular group.
    """
    db = core.connect()
    return core.query(schema.allGroups, id)
Exemplo n.º 19
0
def deleteAllEvents():
    eventIds = [aevent["_id"] for aevent in core.query(schema.allEvents)]
    [event.delete(eventId) for eventId in eventIds]
Exemplo n.º 20
0
def byUser(id, userId=None):
    return core.query(schema.shiftByUser, id)