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