scripts/s3-daily-totals
author Dan Minor <dminor@mozilla.com>
Fri, 18 Dec 2015 15:12:07 -0500
changeset 362083 2248273cff1c9789e941b14cb0a303dbfca0ff98
parent 361517 d41a65872dc175ce978d8b9515e9879512039a5b
child 362306 24d0f9419046d4c108685ea5d6a252545b8f0efc
permissions -rwxr-xr-x
mozreview: people besides review requesters should be able autoland (bug 1205018) r=mdoglio This removes the check for whether or not the review is mutable by the current user, which allows people other than the review requester to autoland provided they have sufficient privileges.

#!/usr/bin/env python2
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys

from boto.s3.connection import S3Connection


BUCKETS = (
    'moz-devservices-logging-us-west-2',
    'moz-devservices-logging-us-east-1',
)

def get_s3_daily_totals(day):
    c = S3Connection()
    total = 0
    for bn in BUCKETS:
        b = c.get_bucket(bn, validate=False)
        path = 's3/hg-bundles/%s' % day
        key = b.get_key(path, validate=False)

        data = key.get_contents_as_string()
        for line in data.splitlines():
            parts = line.split(' ')
            if parts[7] != 'REST.GET.OBJECT':
                continue

            if parts[12] == '304':
                continue

            total += int(parts[14])

    return total


if __name__ == '__main__':
    for day in sys.argv[1:]:
        total = get_s3_daily_totals(day)
        print('%s\t%d' % (day, total))