[map] create login.html with geo locations

This commit is contained in:
Thomas NOËL 2013-03-21 15:16:11 +01:00
parent 904fc18a71
commit 181f0db4aa
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,66 @@
#!/bin/sh
# lock to avoid concurrent updates
LOCK=/var/run/univnautes-update-map_in-progress.lock
if [ -r $LOCK ]
then
PID=`cat $LOCK`
ps waux | grep $PID | grep univnautes | grep -vq grep && exit
fi
unlock() {
rm -f $LOCK
exit
}
trap unlock INT TERM EXIT
echo $$ > $LOCK
# config
. /usr/local/univnautes/etc/univnautes.conf
log() {
logger -p local4.info -t update-map -- "$*"
}
GEOURLS=/var/lib/univnautes/geourls
GEOLOCAL=/var/lib/univnautes/geolocal
LOGINHTML=/var/lib/univnautes/templates/login.html
GEODIR=/var/lib/univnautes/geofiles
mkdir -p $GEODIR
GEOFILES=""
n=1
for url in `cat $GEOURLS | tr -d `
do
GEOFILE=$GEODIR/$n
wget -q --no-check-certificate -O $GEOFILE $url
if [ $? -eq 0 ]
then
log "$url OK ($n)"
GEOFILES=$GEOFILES" "$GEOFILE
n=$(($n+1))
else
log "cannot download $url"
fi
done
if [ -r $GEOLOCAL ]
then
GEOFILES=$GEOFILES" "$GEOLOCAL
fi
# virtualenv activation
VIRTUAL_ENV="/usr/local/univnautes"
export VIRTUAL_ENV
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# create indexhtml
cd /usr/local/univnautes/pffedportal
if [ -r pffedportal.db ]
then
python ./create_loginhtml.py $GEOFILES 2>&1 > $LOGINHTML | logger -p local4.info -t update-map
log "geo-list of idp created"
fi
exit 0

View File

@ -29,7 +29,9 @@ def geo2idp(filename):
print >> sys.stderr, 'reading %s: %s' % (filename, e)
return {}
f.close()
if not idp_list or not isinstance(idp_list, list):
if not idp_list:
return {}
if not isinstance(idp_list, list):
print >> sys.stderr, '%s does not contain a list' % filename
return {}
for idp in idp_list: