Changeset 617

Show
Ignore:
Timestamp:
03/12/07 19:03:47 (6 years ago)
Author:
lincoln
Message:

better behavior for frequent calling of shepherd - still whinge at the user for calling shepherd too frequently, but still give them output based on previously-generated (cached) output XMLTV

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/shepherd

    r616 r617  
    22 
    33my $progname = 'shepherd'; 
    4 my $version = '0.4.82'; 
     4my $version = '0.4.83'; 
    55 
    66# tv_grab_au 
     
    890890 
    891891    if (defined $opt->{notimetest}) { 
    892         &log(2, "Allowing operation due to '--notimetest' override but\n". 
     892        &log(2, "Allowing normal operation due to '--notimetest' override but\n". 
    893893                "please don't make a habit of this.\n\n"); 
    894894        return; 
    895895    } 
    896896 
    897     &log(2, "Please don't run ".ucfirst($progname)." so frequently.\n\n". 
    898         "If you are experimenting/testing and really mean to run ".ucfirst($progname).", do so using\n". 
    899         "the --notimetest setting but please don't make a habit of this.\n"); 
    900  
    901     &countdown(10, "Aborting"); 
    902     exit(1); 
     897    &log(2, "Please don't run ".ucfirst($progname)." so frequently.\n". 
     898        "Re-using (existing cached) output for this run.\n\n". 
     899        "If you are experimenting/testing and really want ".ucfirst($progname)." to fetch fresh data,\n". 
     900        "do so using the --notimetest setting but please don't make a habit of this.\n\n"); 
     901 
     902    &countdown(10); 
     903 
     904    &output_data(1); 
     905    exit(0); 
    903906} 
    904907 
     
    18491852        exit 0; 
    18501853    } 
     1854    $last_successful_run = undef; 
    18511855 
    18521856    write_config_file(); 
     
    38903894sub output_data 
    38913895{ 
    3892     # $input_postprocess_file contains our final output 
    3893     # send it to whereever --output told us to! 
    3894  
     3896    my $reuse_cached_output = shift; 
     3897    $reuse_cached_output = 0 if (!defined $reuse_cached_output); 
     3898     
     3899    my $output_cache_copy = "$CWD/output.xmltv"; 
    38953900    my $output_filename = "$CWD/output.xmltv"; 
    38963901    $output_filename = $opt->{output} if ($opt->{output}); 
     3902 
     3903    if ($reuse_cached_output) { 
     3904        # re-use existing cached output 
     3905        $input_postprocess_file = $output_cache_copy; 
     3906 
     3907        if ($output_filename eq $input_postprocess_file) { 
     3908            # nothing to do - the input is the same as the output 
     3909            &log("Re-using existing output $output_filename\n"); 
     3910            return; 
     3911        } 
     3912    } 
    38973913 
    38983914    my %writer_args = ( encoding => 'ISO-8859-1' ); 
     
    39113927 
    39123928    &log("Final output stored in $output_filename.\n"); 
     3929 
     3930    # copy final output to our cache copy as well 
     3931    if ($output_filename ne $output_cache_copy) { 
     3932        unlink($output_cache_copy); 
     3933        open(F1,"<$output_filename"); 
     3934        open(F2,">$output_cache_copy"); 
     3935        while (<F1>) { 
     3936            print F2 $_; 
     3937        } 
     3938        close(F1); 
     3939        close(F2); 
     3940    } 
     3941    &log("Cached output stored in $output_cache_copy.\n"); 
    39133942} 
    39143943 
  • status

    r616 r617  
    1 application     shepherd            0.4.82 
     1application     shepherd            0.4.83 
    22grabber         yahoo7widget        1.81 
    33grabber         rex                 3.4.6