Commit 77c55b6e authored by Steve McIntyre's avatar Steve McIntyre

Update to cope with unxpected API change on contributors.d.o

parent ab844c80
......@@ -228,31 +228,73 @@ my %r;
if (defined $tmp) {
%r = %$tmp;
my $tmp_error = $r{"errors"};
my @errors = @$tmp_error;
$error = $r{"code"};
#print Dumper(%r);
printf OUTLOG " POST returned %d in JSON\n", $error;
printf OUTLOG " identifiers: skipped %d\n", $r{"identifiers_skipped"};
printf OUTLOG " records: skipped %d parsed %d\n", $r{"records_skipped"}, $r{"records_parsed"};
printf OUTLOG " contributions: skipped %d processed %d updated %d created %d\n",
$r{"contributions_skipped"}, $r{"contributions_processed"},
$r{"contributions_updated"}, $r{"contributions_created"};
printf OUTLOG " errors:\n";
if (0 == scalar(@errors)) {
printf OUTLOG " none\n";
my $tmp1 = $r{"errors"};
my $contributors_version = undef;
# contributors.d.o code changed its interface without warning :-(
if (defined $tmp1) {
$contributors_version = 1;
} else {
foreach my $e (@errors) {
printf OUTLOG " %s\n", $e;
$tmp1 = $r{"stats"};
if (defined $tmp1) {
$contributors_version = 2;
}
}
# 200 == OK, 400 == OK with warnings
if ($error <= 400) {
unlink "$filename.gz", "$tmplogfile";
if (!defined $contributors_version) {
print OUTLOG " ERROR! Unable to parse return structure from contributors.debian.org\n";
die "ERROR! Unable to parse return structure from contributors.debian.org\n";
} else {
print OUTLOG " Major error. Leaving files around: submitted data in $filename.gz, return in $tmplogfile\n";
print " Major error. Leaving files around: submitted data in $filename.gz, return in $tmplogfile\n";
printf OUTLOG " Got a version %d response\n", $contributors_version;
if ($contributors_version == 1) {
my $tmp_error = $r{"errors"};
my @errors = @$tmp_error;
$error = $r{"code"};
#print Dumper(%r);
printf OUTLOG " POST returned %d in JSON\n", $error;
printf OUTLOG " identifiers: skipped %d\n", $r{"identifiers_skipped"};
printf OUTLOG " records: skipped %d parsed %d\n", $r{"records_skipped"}, $r{"records_parsed"};
printf OUTLOG " contributions: skipped %d processed %d updated %d created %d\n",
$r{"contributions_skipped"}, $r{"contributions_processed"},
$r{"contributions_updated"}, $r{"contributions_created"};
printf OUTLOG " errors:\n";
if (0 == scalar(@errors)) {
printf OUTLOG " none\n";
} else {
foreach my $e (@errors) {
printf OUTLOG " %s\n", $e;
}
}
} elsif ($contributors_version == 2) {
my $tmp_stats = $r{"stats"};
my %stats = %$tmp_stats;
my $tmp_errors = $stats{"errors"};
my @errors = @$tmp_errors;
$error = $r{"result_code"};
#print Dumper(%r);
printf OUTLOG " POST returned %d in JSON\n", $error;
printf OUTLOG " records: parsed %d\n", $stats{"records_parsed"};
printf OUTLOG " errors:\n";
if (0 == scalar(@errors)) {
printf OUTLOG " none\n";
} else {
foreach my $e (@errors) {
printf OUTLOG " %s\n", $e;
}
}
}
# 200 == OK, 400 == OK with warnings
if ($error <= 400) {
unlink "$filename.gz", "$tmplogfile";
} else {
print OUTLOG " Major error. Leaving files around: submitted data in $filename.gz, return in $tmplogfile\n";
print " Major error. Leaving files around: submitted data in $filename.gz, return in $tmplogfile\n";
}
}
} else {
print OUTLOG " POST returned invalid JSON data\n";
print OUTLOG " Leaving files around: submitted data in $filename.gz, return in $tmplogfile\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment