3
# Copyright (C) 2015 Canonical
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26
from util import logger
29
def strptime_instance_last_run(instance):
30
"""PractiTest times look like '13-Apr-2015 22:02', return a datetime."""
32
return datetime.datetime.strptime(
33
instance['last_run']['value'], '%d-%b-%Y %H:%M')
35
# not all instances have last_runs
39
def get_first_instance(instances):
40
instances = list(map(strptime_instance_last_run, instances))
41
instances = [instance for instance in instances if instance is not None]
44
for instance in instances:
55
# FIXME: return this instead
58
logger.info(last-first)
61
def get_practitest_report_for_week(week_number):
62
# FIXME: switch this over to config.ini
63
session = practitest.PractitestSession(
64
config.PROJECT_ID, config.API_KEY, config.API_SECRET_KEY)
65
instances = session.get_instances(week_number)
66
maximum = get_first_instance(instances)
70
def _parse_arguments():
71
parser = argparse.ArgumentParser('Compute team totals for a given week.')
72
parser.add_argument('week',
75
return parser.parse_args()
79
args = _parse_arguments()
80
get_practitest_report_for_week(args.week)
83
if __name__ == '__main__':