~james-w/launchpad-work-items-tracker/ignore-some-more-blueprints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh -e
# Run work item tracker for all available configurations; this is intended to
# be run from cron hourly.
# Copyright (C) 2010 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>

# directory for all *.db
DB_DIR="$1"

# output root directory; output will go into $WWWROOT/project
WWWROOT="$2"

# source tree of the WI tracker
WTROOT=`dirname $0`

if [ ! -d "$1" ] || [ ! -d "$2" ]; then
    echo "Usage: $0 <database dir> <www root dir>" >&2
    exit 1
fi

for CFG in $WTROOT/config/*.cfg; do
    PROJ=`basename $CFG .cfg`
    DB=$DB_DIR/$PROJ.db

    # stuff that we do daily only
    if [ `date +%H` = 00 ]; then
	DAILY_OPTS="--refresh"
	GENERATE_ALL_OPTS="--all-milestones"
	cp $WWWROOT/$PROJ/$PROJ.db $WWWROOT/$PROJ/$PROJ.db.`date +\%Y\%m\%d`
    else
	DAILY_OPTS=""
	GENERATE_ALL_OPTS=""
    fi

    if [ -n "$DEBUG" ]; then
	ERRORS="--debug"
    else
	ERRORS="--mail"
    fi

    # collect info
    if ! $WTROOT/collect -d $DB -c $CFG $ERRORS $DAILY_OPTS; then
	echo "collect failed for $CFG" >&2
	continue
    fi

    # publish new DB
    mkdir -p $WWWROOT/$PROJ
    cp $DB $WWWROOT/$PROJ/$PROJ.db.new
    mv $WWWROOT/$PROJ/$PROJ.db.new $WWWROOT/$PROJ/$PROJ.db

    # generate reports and charts
    if [ -z "$DEBUG" ]; then
	$WTROOT/generate-all -c $CFG -d $DB -o $WWWROOT/$PROJ $GENERATE_ALL_OPTS >/dev/null
    else
	$WTROOT/generate-all -c $CFG -d $DB -o $WWWROOT/$PROJ $GENERATE_ALL_OPTS
    fi
done