download-reports 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/perl -w
  2. use strict;
  3. my $ver;
  4. if (@ARGV) {
  5. $ver = shift;
  6. } elsif (-f 'Makefile') {
  7. (undef,undef,$ver) = split(/ /,`grep "^VERSION = " Makefile`);
  8. chomp $ver;
  9. } else {
  10. die 'Makefile or version argument missing'
  11. }
  12. my $dir = "t/reports/$ver";
  13. die "wrong version or $dir missing"
  14. unless -d $dir;
  15. my $distname;
  16. if (-f 'Makefile') {
  17. (undef,undef,$distname) = split(/ /,`grep "^DISTNAME = " Makefile`);
  18. chomp $distname;
  19. } else {
  20. $distname = 'B-C';
  21. }
  22. my $yaml;
  23. # $wget = `http://www.cpantesters.org/distro/B/B-C.html?grade=1&perlmat=1&patches=1&oncpan=2&distmat=2&perlver=ALL&osname=ALL&version=$ver`;
  24. my $cache = "$dir/$distname.yaml";
  25. if (-f $cache and -M _ < 1) {
  26. local $/;
  27. open my $fh, '<', $cache;
  28. $yaml = <$fh>;
  29. close $fh,
  30. } else {
  31. chdir $dir or die;
  32. my $d = substr($distname,0,1);
  33. $yaml = `wget -O- -q http://www.cpantesters.org/distro/$d/$distname.yaml`;
  34. chdir '../../..';
  35. die unless $yaml;
  36. open my $fh, '>', $cache;
  37. print $fh $yaml;
  38. close $fh;
  39. }
  40. use YAML::XS;
  41. use Data::Dumper;
  42. use HTML::Entities;
  43. # HTML::Entities::decode_entities
  44. sub unescapeHTML {
  45. my $string = shift;
  46. # expanded version from CGI
  47. $string=~ s[&(\S*?);]{
  48. local $_ = $1;
  49. /^amp$/i ? "&" :
  50. /^quot$/i ? '"' :
  51. /^gt$/i ? ">" :
  52. /^lt$/i ? "<" :
  53. /^Agrave$/i ? "Á" :
  54. /^acirc$/i ? "â" :
  55. /^ouml$/i ? "ö" :
  56. /^uuml$/i ? "ü" :
  57. /^auml$/i ? "ä" :
  58. /^Ouml$/i ? "Ö" :
  59. /^Uuml$/i ? "Ü" :
  60. /^Auml$/i ? "Ä" :
  61. /^#(\d+)$/ ? chr($1) :
  62. /^#x([0-9a-f]+)$/i ? chr(hex($1)) :
  63. $_
  64. }gex;
  65. return $string;
  66. }
  67. my $content = Load $yaml;
  68. for my $e (@$content) {
  69. if ($e->{version} eq $ver) {
  70. print Dumper $e;
  71. my $fn = "$dir/log.test-".$e->{osname}.$e->{osvers}."-".$e->{perl};
  72. my $guid = $e->{guid};
  73. sleep 0.3;
  74. my $rpt = `wget -O- -q http://www.cpantesters.org/cpan/report/$guid`;
  75. # check for DEBUGGING
  76. if ($rpt =~ /ccflags[^\n]+ -DDEBUGGING.+?\n/sm) {
  77. $fn .= 'd';
  78. }
  79. if ($e->{platform} !~ /thread/) {
  80. $fn .= "-nt";
  81. }
  82. if (-e $fn) {
  83. warn "Skipping $fn already exists\n";
  84. } else {
  85. $rpt =~ s/^.*<pre>\nFrom:/From/sm;
  86. $rpt =~ s{<hr class="clear-contentunit" />.*$}{}s;
  87. decode_entities($rpt);
  88. # $rpt = unescapeHTML($rpt);
  89. open my $fh, '>', $fn;
  90. print $fh $rpt;
  91. close $fh;
  92. }
  93. }
  94. }