def get_images_for_range_camid( self, camid, start, end ): ''' Get a list of the images between timestamps start and end for the provided camid. List of tuples (camid, timestamp). ''' session = self.Session() start = Utils.timestamp_str_to_datetime( start ) end = Utils.timestamp_str_to_datetime( end ) imgs = [] for row in session.query( Image ).\ filter( Image.camid==camid).\ filter( Image.timestamp > start ).\ filter( Image.timestamp < end ).\ order_by( Image.timestamp ): imgs.append( (row.camid, Utils.timestamp_datetime_to_str( row.timestamp ) ) ) return imgs
def get_full_path_for_image( self, camid, timestamp ): ''' Get the full-image path for the provided camid and timestamp. Returns a tuple (content type, path) or None. ''' session = self.Session() timestamp = Utils.timestamp_str_to_datetime( timestamp ) for row in session.query( Image ).\ filter( Image.camid==camid ).\ filter( Image.timestamp==timestamp ): return (row.content_type, row.full) return None
def insert_image( self, camid, content_type, fullpath, thumbpath, timestamp ): ''' Insert a fully-specified image into the images table. Returns the imgid. ''' session = self.Session() timestamp = Utils.timestamp_str_to_datetime( timestamp ) image = Image( camid=camid, content_type=content_type, full=fullpath, thumb=thumbpath, timestamp=timestamp ) session.add( image ) session.commit() return image.imgid