예제 #1
0
    def rollback_write(self, path, name):
        """
        Rollback a filesystem write. If the file does not exist, fail silently.

        Arguments:
            path<string> -- Absolute filesystem path to file.
            name<string> -- Image name.

        Returns:
            True if image was successfully removed, else False.
        """
        result = False

        writer = FileWriter()
        if writer.file_exists(path + name):
            writer.unwrite(path, name)
            print 'Rolled back write of %s at %s.' % (name, path)
            result = True

        return result
예제 #2
0
    def write_blob(self, blob, path, name):
        """
        Write the image blob and a thumbnail to the filesystem.

        Arguments:
            blob<string> -- Image blob.
            path<string> -- Absolute filesystem path to write to.
            name<string> -- Image name.

        Returns:
            True if image was successfully written, else False.
        """
        result = False

        writer = FileWriter()
        if not writer.file_exists(path + name):
            writer.write(blob, path, name)
            print 'Wrote %s to %s.' % (name, path)
            result = True
        else:
            print '%s already exists at %s. Skipping write.' % (name, path)

        return result