chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cope with JSON.pm version 2 which has an incompatible change
[ypp-sc-tools.db-live.git]
/
pctb
/
commod-results-processor
diff --git
a/pctb/commod-results-processor
b/pctb/commod-results-processor
index e3f45d177b190c00ee7451fdf73f66cd99bb8bca..4a70ddf7767376ab8b9db5406750c257460e9c3c 100755
(executable)
--- a/
pctb/commod-results-processor
+++ b/
pctb/commod-results-processor
@@
-224,7
+224,7
@@
our ($ua)= LWP::UserAgent->new;
sub load_commodmap() {
undef %commodmap;
sub load_commodmap() {
undef %commodmap;
- my $c= new IO::File "
#commodmap#
.tsv";
+ my $c= new IO::File "
_commodmap
.tsv";
if (!$c) { $!==&ENOENT or die $!; return; }
while (<$c>) {
m/^(\S.*\S)\t(\d+)\n$/ or die "$_";
if (!$c) { $!==&ENOENT or die $!; return; }
while (<$c>) {
m/^(\S.*\S)\t(\d+)\n$/ or die "$_";
@@
-244,7
+244,7
@@
sub refresh_commodmap() {
my $incommodmap=0;
my $intag='';
my %got;
my $incommodmap=0;
my $intag='';
my %got;
- my $o= new IO::File "
#commodmap#.tsv.new
",'w' or die $!;
+ my $o= new IO::File "
_commodmap.tsv.tmp
",'w' or die $!;
undef %commodmap;
my $xp= new XML::Parser
undef %commodmap;
my $xp= new XML::Parser
@@
-292,7
+292,7
@@
sub refresh_commodmap() {
# print STDERR "[[[$content]]]\n";
$xp->parse($content);
close $o or die $!;
# print STDERR "[[[$content]]]\n";
$xp->parse($content);
close $o or die $!;
- rename "
#commodmap#.tsv.new","#commodmap#
.tsv" or die $!;
+ rename "
_commodmap.tsv.tmp","_commodmap
.tsv" or die $!;
}
our %newcommods;
}
our %newcommods;
@@
-317,7
+317,7
@@
sub refresh_newcommods() {
my $rsync= $ENV{'YPPSC_PCTB_RSYNC'};
$rsync= 'rsync' if !defined $rsync;
my $rsync= $ENV{'YPPSC_PCTB_RSYNC'};
$rsync= 'rsync' if !defined $rsync;
- my $local= "
#master-newcommods#
.txt";
+ my $local= "
_master-newcommods
.txt";
my $src= $ENV{'YPPSC_PCTB_DICT_UPDATE'};
if ($src) {
my $remote= "$src/master-newcommods.txt";
my $src= $ENV{'YPPSC_PCTB_DICT_UPDATE'};
if ($src) {
my $remote= "$src/master-newcommods.txt";
@@
-325,7
+325,7
@@
sub refresh_newcommods() {
die "$? $!" if $! or $?;
}
read_newcommods($local);
die "$? $!" if $! or $?;
}
read_newcommods($local);
- read_newcommods('
#local-newcommods#
.txt');
+ read_newcommods('
_local-newcommods
.txt');
}
our (%stallmap, @stallmap);
}
our (%stallmap, @stallmap);
@@
-430,7
+430,7
@@
sub main__genmarketdata () {
sub save_upload_html ($$) {
my ($which, $resptxt) = @_;
sub save_upload_html ($$) {
my ($which, $resptxt) = @_;
- open R, ">./
#upload-$which#
.html" or die $!;
+ open R, ">./
_upload-$which
.html" or die $!;
print R $resptxt or die $!;
close R or die $!;
}
print R $resptxt or die $!;
close R or die $!;
}
@@
-449,7
+449,7
@@
sub main__upload () {
]
};
]
};
- print STDERR "Uploading data to
server
...\n";
+ print STDERR "Uploading data to
$pctb
...\n";
my $resp= $ua->post("$url", Content => $content,
Content_Type => 'form-data');
my $resp= $ua->post("$url", Content => $content,
Content_Type => 'form-data');
@@
-458,7
+458,7
@@
sub main__upload () {
my $resptxt= $resp->content();
save_upload_html('1', $resptxt);
my $resptxt= $resp->content();
save_upload_html('1', $resptxt);
- open R, ">./
#upload-1#
.html" or die $!;
+ open R, ">./
_upload-1
.html" or die $!;
print R $resptxt or die $!;
close R or die $!;
print R $resptxt or die $!;
close R or die $!;
@@
-491,29
+491,32
@@
sub main__upload () {
die "@forcerls ?" if grep { $_ ne $forcerl } @forcerls;
my $setisland= {
die "@forcerls ?" if grep { $_ ne $forcerl } @forcerls;
my $setisland= {
- 'action' => 'setisland',
- 'filename' => $filename,
- 'forcereload' => $forcerl,
- 'ocean' => $oceanids[0],
- 'island' => $islandid,
};
print STDERR "Setting ocean and island...\n";
};
print STDERR "Setting ocean and island...\n";
- $resp= $ua->post("${url}IWJTEST", $setisland);
+ my $siurl= ($url . "?action=setisland".
+ "&filename=$filename".
+ "&forcereload=$forcerl".
+ "&ocean=$oceanids[0]".
+ "&island=$islandid");
+ $resp= $ua->get($siurl);
+
die $resp->status_line unless $resp->is_success;
$resptxt= $resp->content();
save_upload_html('2', $resptxt);
die $resp->status_line unless $resp->is_success;
$resptxt= $resp->content();
save_upload_html('2', $resptxt);
-
-
-#
-#http://pctb.ilk.org/upload.php?&ocean=2&island=48&action=setisland&forcereload=1244748679&filename=PFayDW' >v.html
-#
-# print ">$filename|$forcerl|@oceanids|$islandid<\n";
+ die unless $resptxt =~ m/your uploaded data has been processed/i;
+ die unless $resptxt =~ m/your data has been integrated into the database/i;
+
+ $resptxt =~ s/\<a href=\"about:\w+\"\>[^<>]+\<\/a\>//g;
+ save_upload_html('3', $resptxt);
- system 'printenv|grep YPP|sort';
+ print "\n" or die $!;
+ system('w3m -T text/html -dump < _upload-3.html');
+
+ print "\n" or die $!;
}
}