/[webpac2]/trunk/run.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1084 by dpavlin, Sun Dec 23 22:06:08 2007 UTC revision 1164 by dpavlin, Sat Apr 25 14:46:42 2009 UTC
# Line 22  use File::Slurp; Line 22  use File::Slurp;
22  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
23  use Storable qw/dclone/;  use Storable qw/dclone/;
24  use Pod::Usage qw/pod2usage/;  use Pod::Usage qw/pod2usage/;
25    use LWP::Simple;
26    
 use Proc::Queue size => 1;  
27  use POSIX ":sys_wait_h"; # imports WNOHANG  use POSIX ":sys_wait_h"; # imports WNOHANG
28    
29  =head1 NAME  =head1 NAME
# Line 103  Create just links Line 103  Create just links
103    
104  Create merged index of databases which have links  Create merged index of databases which have links
105    
106    =item --mirror http://www.example.com
107    
108    Tries to download input path files from mirror URI
109    
110  =back  =back
111    
112  =cut  =cut
# Line 123  my $marc_dump = 0; Line 127  my $marc_dump = 0;
127  my $parallel = 0;  my $parallel = 0;
128  my $only_links = 0;  my $only_links = 0;
129  my $merge = 0;  my $merge = 0;
130    my $mirror;
131  my $help;  my $help;
132    
133  my $log = _new WebPAC::Common()->_get_logger();  my $log = _new WebPAC::Common()->_get_logger();
# Line 144  GetOptions( Line 149  GetOptions(
149          "parallel=i" => \$parallel,          "parallel=i" => \$parallel,
150          "only-links!" => \$only_links,          "only-links!" => \$only_links,
151          "merge" => \$merge,          "merge" => \$merge,
152            "mirror=s" => \$mirror,
153          "help" => \$help,          "help" => \$help,
154  );  );
155    
# Line 207  my $start_t = time(); Line 213  my $start_t = time();
213  my @links;  my @links;
214    
215  if ($parallel) {  if ($parallel) {
216            eval 'use Proc::Queue size => 1;';
217            die $@ if $@;
218          $log->info("Using $parallel processes for speedup");          $log->info("Using $parallel processes for speedup");
219          Proc::Queue::size($parallel);          Proc::Queue::size($parallel);
220  }  }
# Line 349  foreach my $database ( sort keys %{ $con Line 357  foreach my $database ( sort keys %{ $con
357                  $log->info("database $database doesn't have inputs defined");                  $log->info("database $database doesn't have inputs defined");
358          } );          } );
359    
360            if ( -e 'out/debug' ) { # FIXME flag?
361                    my $out;
362                    foreach my $i ( @inputs ) {
363                            warn dump( $i );
364                            next unless defined $i->{normalize};
365                            warn dump( $i->{normalize} );
366                            foreach my $normalize ( @{ $i->{normalize} } ) {
367                                    my $path = $normalize->{path};
368                                    $out .= qq/\n##\n## $path\n##\n\n/;
369                                    $out .= read_file( $path );
370                            }
371                    }
372                    my $all = "out/debug/all-normalize.pl";
373                    write_file( $all, $out );
374                    warn "### all normalize for this input saved to: $all";
375            };
376    
377          foreach my $input (@inputs) {          foreach my $input (@inputs) {
378    
379                  my $input_name = $input->{name} || $log->logdie("input without a name isn't valid: ",dump($input));                  my $input_name = $input->{name} || $log->logdie("input without a name isn't valid: ",dump($input));
380    
381                    if ( $input->{skip} ) {
382                            $log->info("skip $input_name");
383                            next;
384                    }
385    
386                  next if ($only_input && ($input_name !~ m#$only_input#i && $input->{type} !~ m#$only_input#i));                  next if ($only_input && ($input_name !~ m#$only_input#i && $input->{type} !~ m#$only_input#i));
387    
388                  my $type = lc($input->{type});                  my $type = lc($input->{type});
# Line 380  foreach my $database ( sort keys %{ $con Line 410  foreach my $database ( sort keys %{ $con
410                          delete($input->{modify_file});                          delete($input->{modify_file});
411                  }                  }
412    
413                    if ( $mirror ) {
414                            my $path = $input->{path} || die "no input path in ",dump( $input );
415                            $log->info( "mirror ", $path, " ", -s $path, " bytes" );
416    
417                            $log->warn( "$path not modified" )
418                                    if mirror( "$mirror/$path", $path ) == RC_NOT_MODIFIED;
419                    }
420    
421                  my $input_db = new WebPAC::Input(                  my $input_db = new WebPAC::Input(
422                          module => $input_module,                          module => $input_module,
                         encoding => $config->webpac('webpac_encoding'),  
423                          limit => $limit || $input->{limit},                          limit => $limit || $input->{limit},
424                          offset => $offset,                          offset => $offset,
425                          recode => $input->{recode},                          recode => $input->{recode},
# Line 427  foreach my $database ( sort keys %{ $con Line 464  foreach my $database ( sort keys %{ $con
464    
465                  my $maxmfn = $input_db->open(                  my $maxmfn = $input_db->open(
466                          path => $input->{path},                          path => $input->{path},
467                          code_page => $input->{encoding},        # database encoding                          input_encoding => $input->{encoding},   # database encoding
468                          lookup_coderef => $lookup_coderef,                          lookup_coderef => $lookup_coderef,
469                          lookup => $lookup_jar,                          lookup => $lookup_jar,
470                          %{ $input },                          %{ $input },
# Line 651  foreach my $database ( sort keys %{ $con Line 688  foreach my $database ( sort keys %{ $con
688                  close($report_fh) if ($report_fh);                  close($report_fh) if ($report_fh);
689          }          }
690    
691          eval { $indexer->finish } if ($indexer && $indexer->can('finish'));          $indexer->finish if $indexer && $indexer->can('finish');
692    
693          foreach my $out ( @output_modules ) {          foreach my $out ( @output_modules ) {
694                  $out->finish if $out->can('finish');                  $out->finish if $out->can('finish');

Legend:
Removed from v.1084  
changed lines
  Added in v.1164

  ViewVC Help
Powered by ViewVC 1.1.26