class ThumbnailType(InodeIDType): """ A Column showing thumbnails of inodes """ def __init__(self, name='Thumbnail', **args ): InodeIDType.__init__(self, **args) self.fsfd = FileSystem.DBFS(self.case) self.name = name def select(self): return "%s.inode_id" % self.table ## When exporting to html we need to export the thumbnail too: def render_html(self, inode_id, table_renderer): ct='' try: fd = self.fsfd.open(inode_id = inode_id) image = Graph.Thumbnailer(fd, 200) inode_filename, ct, fd = table_renderer.make_archive_filename(inode_id) filename, ct, fd = table_renderer.make_archive_filename(inode_id, directory = "thumbnails/") table_renderer.add_file_from_string(filename, image.display()) except IOError,e: print e return "<a href=%r ><img src='images/broken.png' /></a>" % inode_filename InodeIDType.render_html(self, inode_id, table_renderer) table_renderer.add_file_to_archive(inode_id) return DB.expand("<a href=%r type=%r ><img src=%r /></a>", (inode_filename, ct, filename))
def tabular_view(query,result): result.table( elements = [ TimestampType('Timestamp','mtime', table='inode'), #TimestampType(name='Date',column='date'), PacketType(name='Request Packet',column='request_packet', case=query['case']), InodeIDType(), StringType('Method','method'), StringType('URL','url'), StringType('Content Type','content_type') ], table="http", case=query['case'] )
def vfs_popup(query, result): if not query.has_key('case'): result.heading("No case selected") else: import pyflag.FileSystem as FileSystem def make_new_query(query, path=''): case = query['case'] new_query = query.clone() new_query['__target__'] = name new_query['__target_type__'] = 'append' new_query['__target_format__'] = "vfs://%s%s%%s" % (case, path) new_query.poparray('callback_stored') return new_query def tree_view_cb(query, result): def tree_cb(path): fsfd = FileSystem.DBFS(query['case']) query.default("path", '/') if not path.endswith('/'): path = path + '/' dirs = [] for i in fsfd.dent_walk(path): if i['mode'] == "d/d" and i[ 'status'] == 'alloc' and i[ 'name'] not in dirs: dirs.append(i['name']) yield (([i['name'], i['name'], 'branch'])) def pane_cb(path, tmp): fsfd = FileSystem.DBFS(query["case"]) if not fsfd.isdir(path): path = posixpath.dirname(path) new_query = make_new_query(query, path + '/') tmp.table( elements=[ InodeIDType(case=query['case']), FilenameType(basename=True, case=query['case'], link=new_query, link_pane='parent'), IntegerType('File Size', 'size'), ], table='inode', where=DB.expand( "file.path=%r and file.mode!='d/d'", (path + '/')), case=query['case'], pagesize=10, filter="filter2", ) result.tree(tree_cb=tree_cb, pane_cb=pane_cb, branch=['']) def table_view_cb(query, result): case = query['case'] new_query = make_new_query(query, '') result.table(elements=[ InodeIDType(), FilenameType(case=case, link=new_query, link_pane='parent'), IntegerType('File Size', 'size') ], table='inode', case=case, order=2, direction=1)
def __init__(self, name='Thumbnail', **args ): InodeIDType.__init__(self, **args) self.fsfd = FileSystem.DBFS(self.case) self.name = name