Changeset 130 for shepherd

Show
Ignore:
Timestamp:
10/24/06 05:06:59 (7 years ago)
Author:
lincoln
Message:

--status bling, more concise descriptions of all plugins, re-add .conf file back (optional) for postprocessors/reconcilers

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • shepherd

    r129 r130  
    33# "Shepherd" 
    44 
    5 my $version = '0.2.22'; 
     5my $version = '0.2.23'; 
    66 
    77# A wrapper for various Aussie TV guide data grabbers 
     
    895895        $seen_channels_with_data, $this_plugin->{programmes}, 
    896896        int($this_plugin->{total_duration} / 3600), 
    897         (defined $this_plugin->{earliest_data_seen} ? (strftime "%a%d%b%H:%M", localtime($this_plugin->{earliest_data_seen})) : 'no'), 
    898         (defined $this_plugin->{latest_data_seen} ? (strftime "%a%d%b%H:%M", localtime($this_plugin->{latest_data_seen})) : 'data'); 
     897        (defined $this_plugin->{earliest_data_seen} ? (strftime "%a%d%b%Hh", localtime($this_plugin->{earliest_data_seen})) : 'no'), 
     898        (defined $this_plugin->{latest_data_seen} ? (strftime "%a%d%b%Hh", localtime($this_plugin->{latest_data_seen})) : 'data'); 
    899899 
    900900    $plugin_data->{$plugin} = $this_plugin; 
     
    14021402    return unless (fetch_file($rfile, $newfile)); 
    14031403 
    1404     if ($progtype eq "grabber") {     
    1405         # Fetch grabber config file 
    1406         $rfile .= ".conf"; 
    1407         $config = fetch_file($rfile); 
    1408         return unless ($config); 
    1409  
     1404    # Fetch grabber config file 
     1405    $rfile .= ".conf"; 
     1406    $config = fetch_file($rfile); 
     1407 
     1408    if (!$config) { 
     1409        return if ($progtype eq "grabber"); # grabbers MUST have config files 
     1410    } else { 
    14101411        eval $config; 
    14111412    } 
     
    19221923} 
    19231924 
     1925sub pretty_print 
     1926{ 
     1927    my ($p, $len) = @_; 
     1928    my $spaces = ' ' x (79-$len); 
     1929    my $ret = ""; 
     1930 
     1931    while (length($p) > 0) { 
     1932        if (length($p) <= $len) { 
     1933            $ret .= $p; 
     1934            $p = ""; 
     1935        } else { 
     1936            # find a space to the left of cutoff 
     1937            my $len2 = $len; 
     1938            while ((substr($p,$len2,1) ne ' ') && ($len2 > 0)) { 
     1939                $len2--; 
     1940            } 
     1941            if ($len2 == 0) { 
     1942                # no space - just print it with cutoff 
     1943                $ret .= substr($p,0,$len); 
     1944                $p = substr($p,$len,(length($p)-$len)); 
     1945            } else { 
     1946                # print up to space 
     1947                $ret .= substr($p,0,$len2); 
     1948                $p = substr($p,($len2+1),(length($p)-$len2+1)); 
     1949            } 
     1950            # print whitespace 
     1951            $ret .= "\n".$spaces; 
     1952        } 
     1953    } 
     1954    return $ret; 
     1955} 
     1956 
    19241957sub status 
    19251958{ 
    1926     my %qual_table = ( 3 => "Best", 2 => "Good", 1 => "Unkn" ); 
    1927  
    19281959    print "\nThe following plugins are known:\n", 
    1929           " Type     Name             Description\n". 
    1930           " -------- ---------------- ------------------------------------------------------\n"; 
     1960          " Type     Name           Version Description\n". 
     1961          " -------- -------------- ------- ----------------------------------------------\n"; 
     1962 
    19311963    foreach (sort { $components->{$a}->{type} cmp $components->{$b}->{type} } keys %{$components}) { 
    1932         printf " %-8s %-16s %54s\n", 
     1964        printf " %-8s %-15s%7s %46s\n", 
    19331965          substr($components->{$_}->{type},0,8),  
    1934           length($_) > 14 ? substr($_,0,14).".." : $_, 
     1966          length($_) > 15 ? substr($_,0,13).".." : $_, 
     1967          ($components->{$_}->{ver} ? substr($components->{$_}->{ver},0,7) : "unknown"), 
    19351968          (defined $components->{$_}->{config}->{desc} ? 
    1936             (length($components->{$_}->{config}->{desc}) > 52 ? 
    1937               substr($components->{$_}->{config}->{desc},0,52).".." : $components->{$_}->{config}->{desc}) : ""); 
     1969            pretty_print($components->{$_}->{config}->{desc},46) : ""); 
    19381970    } 
    19391971    printf "\n"; 
    19401972 
    19411973    print "Grabbers, listed in order of quality:\n". 
    1942           " Qual Grabber           Version Enabled Ready Last Run   Status\n" . 
    1943           " ---- ----------------- ------- ------- ----- ---------- ----------------------------\n"; 
     1974          "                   Enabled/\n". 
     1975          " Grabber        Qual Ready Last Run   Status\n" . 
     1976          " -------------- ---- ----- ---------- -----------------------------------------\n"; 
     1977    my %qual_table = ( 3 => "Best", 2 => "Good", 1 => "Avg" ); 
    19441978    foreach (sort { $components->{$b}->{config}->{quality} <=> $components->{$a}->{config}->{quality} } query_grabbers()) { 
    19451979        my $h = $components->{$_}; 
    1946         printf  " %-4s %-16s %8s %4s %6s  %11s %s\n", 
     1980        printf  " %-15s%-4s  %1s/%1s %11s %s\n", 
     1981          length($_) > 15 ? substr($_,0,13).".." : $_, 
    19471982          $qual_table{($h->{config}->{quality})}, 
    1948           length($_) > 14 ? substr($_,0,14).".." : $_, 
    1949           ($h->{ver} ? substr($h->{ver},0,8) : "unknown"), 
    1950           $h->{disabled} ? '' : 'Y', 
    1951           $h->{ready} ? 'Y' : '', 
     1983          $h->{disabled} ? 'N' : 'Y', 
     1984          $h->{ready} ? 'Y' : 'N', 
    19521985          $h->{lastdata} ? (strftime "%a%d%b%y", localtime($h->{lastdata})) : 'never', 
    1953           $h->{laststatus} ? $h->{laststatus} : ''; 
     1986          $h->{laststatus} ? pretty_print($h->{laststatus},41) : ''; 
    19541987    } 
    19551988 
    19561989    print "\n". 
    1957           " Reconciler        Version Enabled Ready Last Run   Status\n" . 
    1958           " ---------------- -------- ------- ----- ---------- ---------------------------\n"; 
     1990          "              Enabled/\n". 
     1991          " Reconciler     Ready Last Run   Status\n" . 
     1992          " -------------- ----- ---------- ----------------------------------------------\n"; 
    19591993    foreach (sort { $components->{$a} <=> $components->{$b} } query_reconcilers()) { 
    19601994        my $h = $components->{$_}; 
    1961         printf  " %-16s %8s %4s %6s  %11s %s\n", 
    1962                 length($_) > 14 ? substr($_,0,14).".." : $_,, 
    1963                 ($h->{ver} ? $h->{ver} : "unknown"), 
    1964                 $h->{disabled} ? '' : 'Y', 
    1965                 $h->{ready} ? 'Y' : '', 
    1966                 $h->{lastdata} ? (strftime "%a%d%b%y", localtime($h->{lastdata})) : 'never', 
    1967                 $h->{laststatus} ? $h->{laststatus} : ''; 
     1995        printf  " %-15s %1s/%1s %11s %s\n", 
     1996          length($_) > 15 ? substr($_,0,13).".." : $_, 
     1997          $h->{disabled} ? 'N' : 'Y', 
     1998          $h->{ready} ? 'Y' : 'N', 
     1999          $h->{lastdata} ? (strftime "%a%d%b%y", localtime($h->{lastdata})) : 'never', 
     2000          $h->{laststatus} ? pretty_print($h->{laststatus},46) : ''; 
    19682001    } 
    19692002 
    19702003    print "\n". 
    1971           " Postprocessor     Version Enabled Ready Last Run   Status\n" . 
    1972           " ---------------- -------- ------- ----- ---------- ---------------------------\n"; 
     2004          "              Enabled/\n". 
     2005          " Postprocessor  Ready Last Run   Status\n" . 
     2006          " -------------- ----- ---------- ----------------------------------------------\n"; 
    19732007    foreach (sort { $components->{$a} <=> $components->{$b} } query_postprocessors()) { 
    19742008        my $h = $components->{$_}; 
    1975         printf  " %-16s %8s %4s %6s  %11s %s\n", 
    1976                 length($_) > 14 ? substr($_,0,14).".." : $_, 
    1977                 ($h->{ver} ? $h->{ver} : "unknown"), 
    1978                 $h->{disabled} ? '' : 'Y', 
    1979                 $h->{ready} ? 'Y' : '', 
    1980                 $h->{lastdata} ? (strftime "%a%d%b%y", localtime($h->{lastdata})) : 'never', 
    1981                 $h->{laststatus} ? $h->{laststatus} : ''; 
     2009        printf  " %-15s %1s/%1s %11s %s\n", 
     2010          length($_) > 15 ? substr($_,0,13).".." : $_, 
     2011          $h->{disabled} ? 'N' : 'Y', 
     2012          $h->{ready} ? 'Y' : 'N', 
     2013          $h->{lastdata} ? (strftime "%a%d%b%y", localtime($h->{lastdata})) : 'never', 
     2014          $h->{laststatus} ? pretty_print($h->{laststatus},46) : ''; 
    19822015    } 
    19832016    printf "\nPreferred titles from grabber '%s'\n",$pref_title_source if ($pref_title_source);