Пример #1
0
    def synch_db(cls):
        """Updates the database with images found in the image directory."""
        if not cls.is_synch_db():
            return
        # Deal with images not in the database first
        cls.images_not_in_db()
        for image in cls.__not_in_db__:
            logging.info("Adding image: " + image.getPath() + " to database.")
            model_image = Image(**image.toImageDbMap())
            Image.addImage(model_image)
            ImageFile.populateParts(image)
            for part in image.getPartitions():
                Partition.addPart(Partition(**part.toPartDbMap(model_image.id)))

        for image in cls.__not_on_disk__:
            logging.warn("Image: " + image.path + " appears to have been deleted from disk.")
Пример #2
0
def analysis_handler(image_id, part_id, encoded_filepath):
    """Page that displays analysis results for a file."""
    file_path = urllib.unquote(encoded_filepath)
    image = Image.byId(image_id)
    image_part = Partition.byId(part_id)
    fs_ele = FileSysEle.fromImagePath(image.path, image_part, image.bps, file_path)

    # Do something for directory handling here, not sure what yet
    return render_template('analysis.html', image=image, partition=image_part, file_path=file_path)
Пример #3
0
def file_handler(image_id, part_id, encoded_filepath):
    """Display page for a file system element.
    If the element is a directory then the page displays the directory listing
    as read from the disk image.
    If a file is selected they files contents as a binary payload is sent in
    the Response.
    """
    file_path = urllib.unquote(encoded_filepath)
    image = Image.byId(image_id)
    image_part = Partition.byId(part_id)
    fs_ele = FileSysEle.fromImagePath(image.path, image_part, image.bps, file_path)
    if fs_ele.isDirectory():
        # Render the dir listing template
        files = FileSysEle.listFiles(image.path, image_part, image.bps, file_path)
        return render_template('directory.html', image=image,
                               partition=image_part, files=files)
    # Its a file so return the download
    temp_file, mime_type = FileSysEle.createTempCopy(image.path,
                                                     image_part.start,
                                                     image.bps, fs_ele)
    return send_file(temp_file, mimetype=mime_type, as_attachment=True, attachment_filename=fs_ele.name)