Changeset 1474
- Timestamp:
- Sep 24, 2013, 5:05:08 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/shepherd
r1471 r1474 2 2 3 3 our $progname = 'shepherd'; 4 my $version = '1. 8.8';4 my $version = '1.9.0'; 5 5 6 6 # tv_grab_au … … 73 73 our $pref_title_source; 74 74 my $last_successful_run; 75 my $last_successful_refresh; 75 76 our $hd_to_sds; 76 77 … … 265 266 { 266 267 &postprocess_data unless ($opt->{skippost}); 267 &output_data ;268 &output_data(); 268 269 &finalize_stats; 269 270 &report_stats; … … 885 886 unless ($opt->{dontcallgrabbers}) 886 887 { 887 $last_successful_run = time; 888 my $total_wanted = $plugin_data->{$progname}->{total_duration} + $plugin_data->{$progname}->{total_missing}; 889 $last_successful_run_data = ($total_wanted ? 100* $plugin_data->{$progname}->{total_duration} / $total_wanted : 0); 890 891 $last_successful_runs->{$last_successful_run} = $last_successful_run_data; 888 unless ($opt->{'autorefresh'}) 889 { 890 $last_successful_run = time; 891 my $total_wanted = $plugin_data->{$progname}->{total_duration} + $plugin_data->{$progname}->{total_missing}; 892 $last_successful_run_data = ($total_wanted ? 100* $plugin_data->{$progname}->{total_duration} / $total_wanted : 0); 893 $last_successful_runs->{$last_successful_run} = $last_successful_run_data; 894 } 895 $last_successful_refresh = time; 892 896 } 893 897 } … … 1102 1106 } 1103 1107 1104 # if last run was successful and was less than 22 hours ago, refuse to run. 1105 # there's really no point calling shepherd more frequently than this. 1108 # If the last run was successful and was less than 22 hours ago, refuse to run. 1109 # There's really no point calling shepherd more frequently than this. 1110 # 1111 # However, as of v1.9.0, we also do a "refresh" of the current day by default 1112 # if it's been less than 22 hours since the last full run, but more than 4 hours 1113 # since the last refresh. A refresh just updates the current day. 1114 # 1106 1115 sub check_last_run 1107 1116 { … … 1109 1118 my $last_ran_secs_ago = time - $last_successful_run; 1110 1119 1111 &log(0,"\n".ucfirst($progname)." last ran successfully".pretty_duration($last_ran_secs_ago)." ago.\n");1120 &log(0,"\n".ucfirst($progname)." last successfully completed a full run ".pretty_duration($last_ran_secs_ago)." ago.\n"); 1112 1121 1113 1122 return if ($last_ran_secs_ago > (22*60*60)); … … 1153 1162 } 1154 1163 1155 &log("!! Shepherd has successfully completed a run less than 22 hours ago.\n" . 1156 "!! Exiting to avoid wasting time and bandwidth.\n\n"); 1164 &log("!! Will not re-run since last full run was less than 22 hours ago.\n"); 1165 1166 if (!$last_successful_refresh or $last_successful_refresh < $last_successful_run) 1167 { 1168 $last_successful_refresh = $last_successful_run; 1169 } 1170 my $last_refreshed_secs_ago = time - $last_successful_refresh; 1171 if ($last_successful_refresh != $last_successful_run) 1172 { 1173 &log("\nShepherd last successfully refreshed " . &pretty_duration($last_refreshed_secs_ago) . " ago.\n"); 1174 } 1175 if ($last_refreshed_secs_ago > (4*60*60)) 1176 { 1177 if ($opt->{'days'} and $days != 1) 1178 { 1179 &log("!! Will not autorefresh due to user-supplied '--days' option.\n"); 1180 } 1181 elsif ($opt->{'noautorefresh'}) 1182 { 1183 &log("!! Will not autorefresh due to '--noautorefresh' option.\n"); 1184 } 1185 elsif ((localtime)[2] >= 23) 1186 { 1187 &log("!! Will not autorefresh due to lateness of current time (11PM+).\n"); 1188 } 1189 else 1190 { 1191 &log("\n*** Autorefreshing today's data! ***\n"); 1192 $days = $opt->{'days'} = 1; 1193 $opt->{'autorefresh'} = 1; 1194 unless ($opt->{'output'}) 1195 { 1196 $output_filename = "$CWD/refresh.xmltv"; 1197 &test_output_file(); 1198 } 1199 return; 1200 } 1201 } 1202 else 1203 { 1204 &log("!! Last refresh was less than 4 hours ago.\n"); 1205 } 1206 1207 &log("\n!! Exiting to avoid wasting time and bandwidth.\n\n"); 1157 1208 1158 1209 if (defined $opt->{'refresh-mythtv'}) … … 1162 1213 else 1163 1214 { 1164 &log("If you wish Shepherd to re-output the data it gathered last run,\n" .1215 &log("If you wish Shepherd to re-output the data it gathered last full run,\n" . 1165 1216 "use the --reoutput option (e.g. 'tv_grab_au --reoutput'). To do this\n" . 1166 1217 "via mythfilldatabase, use 'mythfilldatabase -- --reoutput'. (Or,\n". … … 1912 1963 { 1913 1964 write_file($config_file, 'configuration', 1914 [$region, $pref_title_source, $want_paytv_channels, $sysid, $last_successful_run, $last_successful_run_data, $last_successful_runs, $ sources, $components, $components_pending_install, $pending_messages ],1915 ["region", "pref_title_source", "want_paytv_channels", "sysid", "last_successful_run", "last_successful_run_data", "last_successful_runs", ' sources', "components", "components_pending_install", "pending_messages" ]);1965 [$region, $pref_title_source, $want_paytv_channels, $sysid, $last_successful_run, $last_successful_run_data, $last_successful_runs, $last_successful_refresh, $sources, $components, $components_pending_install, $pending_messages ], 1966 ["region", "pref_title_source", "want_paytv_channels", "sysid", "last_successful_run", "last_successful_run_data", "last_successful_runs", 'last_successful_refresh', 'sources', "components", "components_pending_install", "pending_messages" ]); 1916 1967 } 1917 1968 … … 2007 2058 reoutput 2008 2059 reoutput-mythtv 2060 noautorefresh 2009 2061 )); 2010 2062 $debug = $opt->{debug}; … … 2752 2804 $last_successful_run_data; 2753 2805 } 2754 &log("\n$str.\n"); 2806 $str .= ".\n"; 2807 if ($last_successful_refresh and $last_successful_refresh != $last_successful_run) 2808 { 2809 $str .= sprintf "Shepherd last autorefreshed %s ago.\n", 2810 &pretty_duration(time - $last_successful_refresh); 2811 } 2812 &log($str); 2755 2813 } 2756 2814 &log("\nPreferred titles from grabber '$pref_title_source'\n") if ($pref_title_source); … … 2771 2829 scalar(keys %$last_successful_runs), 2772 2830 int((time - $all_runs[0]) / 86400)); 2831 if ($last_successful_refresh and $last_successful_refresh != $last_successful_run) 2832 { 2833 &log(sprintf "Shepherd last successfully autorefreshed %s ago (%s).\n\n", 2834 &pretty_duration(time - $last_successful_refresh), 2835 &pretty_date($last_successful_refresh)); 2836 } 2837 2773 2838 my $str; 2774 2839 foreach my $when (sort {$b <=> $a} keys (%{$last_successful_runs})) … … 2810 2875 { 2811 2876 print q{Info options: 2812 --help Display this message2877 --help Hello! 2813 2878 --dev-help Display advanced options 2814 2879 --version Display version 2815 --status Display status of various components2816 --desc Display detailed status of components2880 --status Display status 2881 --desc Display detailed status 2817 2882 --history Display usage history 2818 --check Display check of all components2883 --check Verify current installation 2819 2884 2820 2885 --show-config Show setup details … … 2825 2890 2826 2891 Session options: 2827 --output < s> Create file <s>(default: ~/.shepherd/output.xmltv)2828 --days <n> Retrieve <n> days of guidedata2892 --output <file> Specify an output file (default: ~/.shepherd/output.xmltv) 2893 --days <n> Retrieve <n> days of data 2829 2894 --offset <n> Skip first <n> days 2830 2895 … … 2835 2900 2836 2901 --noupdate Don't update Shepherd; just grab data 2837 --update Don't grab data; just update Shepherd 2838 --skipupdate Skip update of Shepherd 2839 --skippost Skip postprocessing of data 2902 --update Update Shepherd but don't grab data 2903 --skipupdate Don't update Shepherd or verify components; just grab data 2904 --skippost Don't run any postprocessors on data 2905 --noautorefresh Don't switch to autorefresh mode (i.e. "--days 1") 2840 2906 2841 2907 --mode <s> Quality (default), Efficiency or Speed 2842 --grabwith <s> Grab with grabber <s> before trying other grabbers2908 --grabwith <s> Run grabber(s) <s> before any others 2843 2909 (e.g. --grabwith sbsweb,abc_website) 2844 2910 2845 2911 --debug Print debugging messages 2846 2912 --quiet Don't print anything except errors 2847 --notquiet Don't be --quiet2913 --notquiet Override --quiet 2848 2914 --nolog Don't write a logfile 2849 2915 --nonotify Don't report anonymous usage statistics … … 2944 3010 my $iteration = query_iteration($grabber); 2945 3011 2946 my $output = sprintf "%s/grabbers/%s/output-%d.xmltv", 2947 $CWD, $grabber, $iteration; 3012 my $output = sprintf "%s/grabbers/%s/%s-%d.xmltv", 3013 $CWD, $grabber, 3014 ($opt->{'autorefresh'} ? 'refresh' : 'output'), 3015 $iteration; 2948 3016 2949 3017 my $comm = "$CWD/grabbers/$grabber/$grabber " . … … 4840 4908 &log("\nSHEPHERD: Using $data_processor_type: $data_processor_name\n"); 4841 4909 4842 my $output = sprintf "%s/%ss/%s/output.xmltv",$CWD,$data_processor_type,$data_processor_name; 4910 my $out = ($opt->{'autorefresh'} ? 'refresh' : 'output'); 4911 my $output = sprintf "%s/%ss/%s/%s.xmltv",$CWD,$data_processor_type,$data_processor_name, $out; 4843 4912 my $comm = sprintf "%s/%ss/%s/%s",$CWD,$data_processor_type,$data_processor_name,$data_processor_name; 4844 4913 $comm .= " --region $region" . … … 4934 5003 $reuse_cached_output = 0 if (!defined $reuse_cached_output); 4935 5004 4936 my $output_cache_copy = "$CWD/output.xmltv";5005 my $output_cache_copy = $output_filename; 4937 5006 4938 5007 if ($reuse_cached_output) { … … 4962 5031 &log("Final output stored in $output_filename.\n"); 4963 5032 4964 # copy final output to our cache copy as well 4965 if ($output_filename ne $output_cache_copy) { 4966 unlink($output_cache_copy); 4967 open(F1,"<$output_filename"); 4968 open(F2,">$output_cache_copy"); 4969 while (<F1>) { 4970 print F2 $_; 4971 } 4972 close(F1); 4973 close(F2); 4974 } 4975 &log("Cached output stored in $output_cache_copy.\n"); 4976 } 4977 4978 if (!$opt->{'output'} and !$opt->{'nooutput'}) { 5033 unless ($opt->{'autorefresh'}) 5034 { 5035 # copy final output to our cache copy as well 5036 if ($output_filename ne $output_cache_copy) { 5037 unlink($output_cache_copy); 5038 open(F1,"<$output_filename"); 5039 open(F2,">$output_cache_copy"); 5040 while (<F1>) { 5041 print F2 $_; 5042 } 5043 close(F1); 5044 close(F2); 5045 } 5046 &log("Cached output stored in $output_cache_copy.\n"); 5047 } 5048 } 5049 5050 if (!$opt->{'nooutput'} and ($reuse_cached_output or !$opt->{'output'})) { 4979 5051 &log("\nPrinting XMLTV output to STDOUT in 5 seconds...\n"); 4980 5052 sleep 5; -
trunk/status
r1473 r1474 1 application shepherd 1. 8.81 application shepherd 1.9.0 2 2 reference channel_list 107 3 3 reference Shepherd/Common.pm 1.10
Note: See TracChangeset
for help on using the changeset viewer.