@@ -0,0 +1,2173 @@
+#!/usr/bin/python%0A%0Aimport png%0A%0Adevice_size = %5B0%5D%0Achunks = %5B%5D%0A%0Awidth = 1200%0Aheight = 800%0Anum_pixels = width * height%0A%0Apixels = %5B%5B%5D for x in xrange(num_pixels)%5D%0A%0Alines = open('output').read().splitlines()%0Afor line in lines:%0A    fields = line.split()%0A    if fields%5B0%5D == 'chunk':%0A        chunks.append(%7B%0A            'type': int(fields%5B4%5D),%0A            'devid': int(fields%5B8%5D),%0A            'offset': int(fields%5B10%5D),%0A            'length': int(fields%5B12%5D),%0A            'used': int(fields%5B14%5D),%0A        %7D)%0A    elif fields%5B0%5D == 'dev':%0A        device_size.append(int(fields%5B6%5D))%0A%0Adevice_offset = %5B%5D%0Afor i in range(len(device_size)):%0A    device_offset.append(sum(device_size%5B:i%5D))%0A%0Abytes_per_pixel = float(sum(device_size)) / num_pixels%0Aprint(%22bytes per pixel: %25s%22 %25 bytes_per_pixel)%0A%0Afor chunk in chunks:%0A    first_byte = device_offset%5Bchunk%5B'devid'%5D%5D + chunk%5B'offset'%5D%0A    last_byte = first_byte + chunk%5B'length'%5D - 1%0A    used_pct = float(chunk%5B'used'%5D) / float(chunk%5B'length'%5D)%0A%0A    first_pixel = int(first_byte / bytes_per_pixel)%0A    last_pixel = int(last_byte / bytes_per_pixel)%0A%0A    if first_pixel == last_pixel:%0A        pct_of_pixel = chunk%5B'length'%5D / bytes_per_pixel%0A        pixels%5Bfirst_pixel%5D.append((pct_of_pixel, used_pct))%0A    else:%0A        pct_of_first_pixel = (bytes_per_pixel - (first_byte %25 bytes_per_pixel)) / bytes_per_pixel%0A        pixels%5Bfirst_pixel%5D.append((pct_of_first_pixel, used_pct))%0A%0A        for intermediate_pixel in xrange(first_pixel + 1, last_pixel):%0A            pixels%5Bintermediate_pixel%5D.append((1, used_pct))%0A%0A        pct_of_last_pixel = (last_byte %25 bytes_per_pixel) / bytes_per_pixel%0A        pixels%5Blast_pixel%5D.append((pct_of_last_pixel, used_pct))%0A%0Afor i in xrange(len(pixels)):%0A    if isinstance(pixels%5Bi%5D, list):%0A        if len(pixels%5Bi%5D) == 0:%0A            pixels%5Bi%5D = 0%0A        else:%0A            gradient = 0%0A            for pct, used in pixels%5Bi%5D:%0A                gradient = gradient + (255 * pct * used)%0A            pixels%5Bi%5D = int(gradient)%0A    else:%0A        pixels%5Bi%5D = int(255 * pixels%5Bi%5D)%0A%0Apng_grid = %5B%5D%0Afor i in range(0, len(pixels), width):%0A    png_grid.append(pixels%5Bi:i+width%5D)%0A%0Apng.from_array(png_grid, 'L').save(%22heatmap.png%22)%0A

Convert output into png image