Changeset 124 for shepherd

Show
Ignore:
Timestamp:
10/23/06 02:05:48 (7 years ago)
Author:
max
Message:

Standardized on today being considered day 0.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • shepherd

    r123 r124  
    284284                         query_config($grabber, 'option_days_offset') . 
    285285                         " " . 
    286                          ($timeslice->{start} - 1); 
     286                         $timeslice->{start}; 
    287287            } 
    288288 
    289             my $n = $timeslice->{stop}; 
    290             if ($timeslice->{start} != 1  
     289            my $n = $timeslice->{stop} + 1; 
     290            if ($timeslice->{start} != 0  
    291291                    and  
    292292                !query_config($grabber, 'option_offset_eats_days')) 
     
    326326        if ((defined $opt->{dontcallgrabbers}) && ($opt->{dontcallgrabbers})) { 
    327327            printf "SHEPHERD: not calling grabber because of --dontcallgrabbers option, but will instead use existing $output\n"; 
     328            print "SHEPHERD: would have called: $comm\n" if ($debug); 
    328329        } else { 
    329330            print "SHEPHERD: Excuting command: $comm\n"; 
     
    553554} 
    554555 
     556# Return 1 if the grabber can provide data for this channel, 
     557# else 0. 
    555558sub supports_channel 
    556559{ 
     
    572575} 
    573576 
     577# Returns 0 if the grabber can't provide data for this day, 
     578# 1 if it can reliably, and 0.5 if it can unreliably. 
     579# 
     580# Note that in grabber .confs, a max_days of 7 means the 
     581# grabber can retrieve data for today plus 6 days. 
    574582sub supports_day 
    575583{ 
    576584    my ($grabber, $day) = @_; 
    577585 
    578     return 0 unless ($day <= query_config($grabber, 'max_days')); 
    579     return 0.5 if ($day > query_config($grabber, 'max_reliable_days')); 
     586    return 0 unless ($day < query_config($grabber, 'max_days')); 
     587    return 0.5 if ($day >= query_config($grabber, 'max_reliable_days')); 
    580588    return 1; 
    581589} 
     
    597605    foreach my $day (keys %$missing) 
    598606    { 
    599         my $date = substr(DateCalc("today", "+ " . ($day - 1) . " days"), 0, 8); 
     607        my $date = substr(DateCalc("today", "+ $day days"), 0, 8); 
    600608        foreach my $ch (@{$missing->{$day}}) 
    601609        { 
     
    642650    { 
    643651        print "Need data for days " . join(", ", sort keys %$missing) . ".\n"; 
     652        print Dumper($missing); 
    644653    } 
    645654    return $missing; 
     
    648657# Takes a hash of what's missing in the format: 
    649658#   { '1' => [ 'ABC', 'SBS' ], '2' => [ 'ABC' ], ... } 
    650 # and sets $timeslice to the biggest 'slice' of that. 
    651 # For example, the biggest slice of the above is days 1 -2 of ABC. 
     659# and returns the largest timeslice of that. For example,  
     660# the biggest slice of the above is days 1 -2 of ABC. 
    652661sub calculate_best_timeslice 
    653662{ 
     
    656665    my ($overlap, $a); 
    657666    my $slice = { 'chandays' => 0 }; 
    658     foreach my $day (1 .. $days) 
     667    foreach my $day (0 .. $days-1) 
    659668    { 
    660669        consider_slice($slice, $day, $day, @{$missing->{$day}}); 
    661670        $overlap = $missing->{$day}; 
    662         foreach my $nextday (($day + 1) .. $days) 
     671        foreach my $nextday (($day + 1) .. $days-1) 
    663672        { 
    664673            last unless ($missing->{$nextday}); 
     
    739748    foreach my $day (keys %$h) 
    740749    { 
    741         my $date = substr(DateCalc("today", "+ " . ($day - 1) . " days"), 0, 8); 
     750        my $date = substr(DateCalc("today", "+ $day days"), 0, 8); 
    742751        foreach my $ch (@{$h->{$day}}) 
    743752        { 
     
    13471356        } 
    13481357    } 
    1349  
    13501358} 
    13511359 
     
    19061914    set_order(1,$order); 
    19071915 
     1916    print "\n"; 
    19081917    show_channels(); 
    19091918    unless(ask_boolean("\nCreate configuration file?"))