source: subversion/utils/osmAtHome/randomUpdate.pl @ 2021

Last change on this file since 2021 was 1895, checked in by nickburch, 13 years ago

Script to handle calling the random_update functionality for osm@Home

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2#             Call the random place update for OSM@Home
3#             -----------------------------------------
4#
5# Calls the random place update for OSM@Home, to download new data to the
6#  server for places that need updating
7# Handles a full download re-attempt for places that have failed to download
8
9use strict;
10use LWP::Simple;
11
12# Random update URL
13my $url = "http://almien.co.uk/OSM/Places/?action=random_update";
14my $force_url = "http://almien.co.uk/OSM/Places/?action=download&id=";
15
16print "Calling $url:\n";
17my $contents = get($url);
18
19# Was it nothing to update, update done, or a failing to download?
20
21# Nothing:
22#
23if($contents =~ /Nothing to update/) {
24        print "Nothing to update\n";
25}
26
27# Failing to download:
28#   Random selection was <a href="./?id=1166">1166</a>, but looks like that's marked as a &quot;failing download&quot;
29elsif($contents =~ /Random selection was <a href=".\/\?id=(\d+).*?failing download/) {
30        my $place = $1;
31        print "Place with id $place was previously failing, forcing it:\n";
32
33        my $retry = get($force_url.$place);
34        if($retry =~ /Downloading .*?Done,/) {
35                print "Updated\n";
36        } else {
37                print $retry;
38        }
39}
40
41# Downloaded:
42#   Downloading <a href="./?id=1006">place #1006</a> at
43elsif($contents =~ /Downloading <a href=".\/\?id=(\d+)">place.*?Done,/) {
44        my $place = $1;
45        print "Updated place with id $place\n";
46}
47
48else {
49        warn "Unknown contents:\n";
50        print $contents."\n";
51}
Note: See TracBrowser for help on using the repository browser.