X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fcommod-email-processor;h=b395aa8d851fc1ede7bc385968b20b65d8758eca;hb=efc8497c2414dfded724d7181e11df53b947e387;hp=d2f0e819f6ef8c0f41626424fe13beb624d4f088;hpb=c68fb80a6bbf7acbcac4b2cb2143f5fea745cd2b;p=ypp-sc-tools.web-live.git diff --git a/yarrg/commod-email-processor b/yarrg/commod-email-processor index d2f0e81..b395aa8 100755 --- a/yarrg/commod-email-processor +++ b/yarrg/commod-email-processor @@ -25,34 +25,21 @@ # are used without permission. This program is not endorsed or # sponsored by Three Rings. -# Emails are: -# multipart/mixed, containing -# text/plain; name="metadata"; charset="utf-8" -# Content-Disposition: inline; filename="metadata" -# ocean\t canonical mixed case -# island\t canonical mixed case -# timestamp\t time_t (non-leap secs since start of 1970 UTC) -# clientname\t may contain spaces -# clientversion\t may contain spaces -# clientfixes\t space-delimited list -# clientspec\t \t\t -# servername\t may contain spaces -# serverversion\t may contain spaces -# serverfixes\t space-delimited list -# serverspec\t \t\t -# application/octet-stream; name="deduped.tsv.gz" -# Content-Disposition: attachment; filename="deduped.tsv.gz" -# - use strict (qw(vars)); use POSIX; use MIME::Parser; +BEGIN { + my $selfdir= $0; + $selfdir =~ s,/+[^/]*$,,; + chdir("$selfdir") or die "$selfdir $!"; +} + use Commods; use CommodsDatabase; -setlocale(LC_CTYPE, "en_GB.UTF-8"); +set_ctype_utf8(); my $parser= new MIME::Parser; our $entity; @@ -111,7 +98,9 @@ sub main () { db_setocean($md{'ocean'}); my $dbfn= db_filename(); (stat $dbfn) or die "stat database $dbfn failed $!\n"; + db_writer(); db_connect(); + db_onconflict(sub { print STDERR "temporary failure: @_\n"; exit 75; }); my ($islandid) = $dbh->selectrow_array( "SELECT islands.islandid @@ -200,7 +189,7 @@ sub main () { pipethrough_run_finish($pt, 'gunzip <$deduped_tsv.gz'); - print "\n"; +# print "\n"; $dbh->commit(); # select * from ((buy natural join commods) natural join stalls) natural join islands;