imip-agent

Annotated tests/resource_request.sh

1069:37921ab84c01
2016-03-06 Paul Boddie Moved imip_store into a new imiptools.stores package as the file module.
paul@716 1
#!/bin/sh
paul@716 2
paul@716 3
THIS_DIR=`dirname $0`
paul@716 4
paul@716 5
TEMPLATES="$THIS_DIR/templates"
paul@716 6
RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
paul@716 7
SHOWMAIL="$THIS_DIR/../tools/showmail.py"
paul@716 8
STORE=/tmp/store
paul@716 9
STATIC=/tmp/static
paul@716 10
PREFS=/tmp/prefs
paul@1041 11
JOURNAL=/tmp/journal
paul@1041 12
ARGS="-S $STORE -P $STATIC -p $PREFS -j $JOURNAL -d"
paul@716 13
paul@716 14
ERROR=err.tmp
paul@716 15
paul@716 16
export N=$1
paul@716 17
export START=20141126T090000
paul@716 18
export END=20141126T100000
paul@716 19
export SENDERADDRESS="person-$N@example.com"
paul@716 20
export SENDER="mailto:person-$N@example.com"
paul@716 21
paul@716 22
# Exit if a previous result indicates acceptance of a request.
paul@716 23
paul@716 24
   [ -e "outP${N}.tmp" ] \
paul@716 25
&& `grep 'PARTSTAT' "outP${N}.tmp" | grep -q 'ACCEPTED'` \
paul@716 26
&& exit 0
paul@716 27
paul@716 28
FBRESULT=$2
paul@716 29
paul@716 30
# Find the end of a busy period or use the initial start.
paul@716 31
paul@716 32
FBSTART=`grep 'FREEBUSY' "$FBRESULT" | grep -v 'VFREEBUSY' | tail -n 1 | cut -d: -f2 | cut -d/ -f2 | tr -d '\\r'`
paul@716 33
FBEND=`python "$THIS_DIR/next_time.py" "$FBSTART" 09 16`
paul@716 34
START=${FBSTART:-$START}
paul@716 35
END=${FBEND:-$END}
paul@716 36
paul@716 37
echo "Try for $N with $START and $END..."
paul@716 38
paul@716 39
# Request a resource on behalf of a numbered person identity.
paul@716 40
paul@716 41
  envsubst < "$TEMPLATES/event-request-group.txt" \
paul@716 42
| tee "inP${N}.tmp" \
paul@716 43
| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
paul@716 44
| "$SHOWMAIL" 2>> $ERROR \
paul@716 45
> "outP${N}.tmp"