@@ -0,0 +1,678 @@
+import re%0Aimport sqlite3%0A%0Adef open_cloudfront_log_db():%0A    db = sqlite3.connect('cf.db')%0A    return db%0A%0Adef format_size(sz):%0A    abbrevs = (%0A        (1%3C%3C50, 'PB'),%0A        (1%3C%3C40, 'TB'),%0A        (1%3C%3C30, 'GB'),%0A        (1%3C%3C20, 'MB'),%0A        (1%3C%3C10, 'KB'),%0A        (1, 'B')%0A    )%0A%0A    for factor, suffix in abbrevs:%0A        if sz %3E= factor:%0A            break%0A%0A    return '%25.2f %25s' %25 (float(sz) / factor, suffix)%0A%0Adef __main__():%0A    cloudfront_db = open_cloudfront_log_db()%0A%0A    cur = cloudfront_db.cursor()%0A    cur.execute('select * from logs')%0A%0A    total_bytes = sum(%5Bint(row%5B1%5D) for row in cur%5D)%0A%0A    print format_size(total_bytes)%0A%0Aif __name__ == %22__main__%22:%0A    __main__()%0A

Print total byte count from db