X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Ffetchdumps.pl;h=6d02704a294e29bdaa06f20eb3786a847deaddf5;hb=ee8c0983439647a8e652e4a344d3958e01219f92;hp=efd124afc154c7688472c4e6219dab2ecace08e0;hpb=c643b311c8f134a59625192b900aa28b3f12d4f1;p=ndwebbie.git diff --git a/scripts/fetchdumps.pl b/scripts/fetchdumps.pl index efd124a..6d02704 100755 --- a/scripts/fetchdumps.pl +++ b/scripts/fetchdumps.pl @@ -27,17 +27,13 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -$0 =~ /(.*\/)[^\/]/; -my $dir = $1; -our $dbh; -for my $file ("/home/whale/db.pl") -{ - unless (my $return = do $file){ - warn "couldn't parse $file: $@" if $@; - warn "couldn't do $file: $!" unless defined $return; - warn "couldn't run $file" unless $return; - } -} +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use ND::DB; + +our $dbh = ND::DB::DB(); + $dbh->do("SET CLIENT_ENCODING TO 'LATIN1';"); my $insert = $dbh->prepare("INSERT INTO dumps(tick,type,modified,dump) VALUES(?,?,?,?)"); @@ -48,7 +44,7 @@ for my $type ("planet","alliance","galaxy"){ $select->execute($type,$head[2]); unless ($select->fetchrow){ my $file = get("http://game.planetarion.com/botfiles/${type}_listing.txt"); - if ($file =~ /Tick: (\d+)/){ + if (defined $file && $file =~ /Tick: (\d+)/){ $updated = $1; $insert->execute($1,$type,$head[2],$file); } @@ -57,9 +53,13 @@ for my $type ("planet","alliance","galaxy"){ } if ($updated){ - `${dir}parsedumps.pl $updated`; - `${dir}ndrank.pl`; - $dbh->do("UPDATE misc SET value = ? WHERE id = 'TICK'", undef, $updated); + `perl $FindBin::Bin/parsealliances.pl $updated`; + `perl $FindBin::Bin/parseplanets.pl $updated`; + `perl $FindBin::Bin/parsegalaxies.pl $updated`; + `perl $FindBin::Bin/ndrank.pl`; + $dbh->do(q{UPDATE misc SET value = ? WHERE id = 'TICK'}, undef, $updated); + system 'killall','-USR1', 'ndbot.pl'; + local $dbh->{Warn} = 0; }