print -> puts

plus nog iets
This commit is contained in:
Ward Wouts 2008-02-04 21:37:09 +00:00
parent 8dcb4890ce
commit 102205e9eb

View file

@ -81,7 +81,7 @@ Debuglevel = 0
@tstart = Time.now @tstart = Time.now
def save_file(dir, name, data) def save_file(dir, name, data)
print "savename: #{name}\n" if Debuglevel > 1 puts "savename: #{name}" if Debuglevel > 1
nname = name.gsub(/\//, "-") nname = name.gsub(/\//, "-")
nname.gsub!(/>/, "") nname.gsub!(/>/, "")
@ -138,6 +138,7 @@ def save_file(dir, name, data)
nname.gsub!(/Û/, "U"); nname.gsub!(/û/, "u") nname.gsub!(/Û/, "U"); nname.gsub!(/û/, "u")
nname.gsub!(/§/, "S"); nname.gsub!(/£/, "L") nname.gsub!(/§/, "S"); nname.gsub!(/£/, "L")
nname.gsub!(/ß/, "ss")
### nname.gsub!('#{160.chr}', "") ### nname.gsub!('#{160.chr}', "")
### if nname.match(/([#{128.chr}-#{255.chr}])/) ### if nname.match(/([#{128.chr}-#{255.chr}])/)
@ -147,7 +148,7 @@ def save_file(dir, name, data)
nname.sub!(/\s*$/, "") nname.sub!(/\s*$/, "")
nname.sub!(/^[\s\.-]*/, "") nname.sub!(/^[\s\.-]*/, "")
print "nname: #{nname}\n" if Debuglevel > 1 puts "nname: #{nname}" if Debuglevel > 1
newname = nname[0...@maxfilelength] # all the recodings could have made newname = nname[0...@maxfilelength] # all the recodings could have made
# the filename too long # the filename too long
count = 1 count = 1
@ -157,41 +158,44 @@ def save_file(dir, name, data)
newname = "#{nname}-<#{date}.#{count}>" newname = "#{nname}-<#{date}.#{count}>"
count += 1 count += 1
end end
print "name: #{newname}\n" if Debuglevel > 1 puts "name: #{newname}" if Debuglevel > 1
begin begin
case data.class.to_s case data.class.to_s
when "String" when "String"
if File.move(data, "#{dir}/#{newname}") if File.move(data, "#{dir}/#{newname}")
print " Saving as: '#{newname}'\n" puts " Saving as: '#{newname}'"
else else
print "couldn't rename tempfile\n" puts "couldn't rename tempfile"
return false return false
end end
when "Array" when "Array"
if file = File.new("#{dir}/#{newname}", "w", 0644) if file = File.new("#{dir}/#{newname}", "w", 0644)
print " Saving as: '#{newname}'\n" puts " Saving as: '#{newname}'"
data.collect{|i| file.print "#{i}"} data.collect{|i| file.print "#{i}"}
else else
print "couldn't open file for writeing\n" puts "couldn't open file for writeing"
return false return false
end end
when "Tempfile" when "Tempfile"
if File.move(data.path, "#{dir}/#{newname}") if File.move(data.path, "#{dir}/#{newname}")
print " Saving as: '#{newname}'\n" puts " Saving as: '#{newname}'"
else else
print "couldn't rename tempfile\n" puts "couldn't rename tempfile #{data.path}"
return false return false
end end
else else
print "EEEEPS Can't save data of class: #{data.class.to_s}\n" puts "EEEEPS Can't save data of class: #{data.class.to_s}"
return false return false
end end
rescue Errno::ENOENT, Errno::EINVAL rescue Errno::ENOENT, Errno::EINVAL
print "Caught #{$!.class} (save_file)\n" puts "Caught #{$!.class} (save_file)"
print "Error: #{$!}\n" puts "Error: #{$!}"
print "What the *beep* happened?\n" puts "What the *beep* happened?"
print "(if Errno::EINVAL probably evil chars in filename)\n" puts "(if Errno::EINVAL probably evil chars in filename)"
if data.class.to_s == "Tempfile"
puts "keeping #{data.path}"
end
return false return false
end end
return true return true
@ -216,31 +220,36 @@ def parse_options(options)
options[opt] = arg options[opt] = arg
end end
rescue GetoptLong::InvalidOption rescue GetoptLong::InvalidOption
print "#{$!}\n" puts "#{$!}"
usage usage
end end
return options return options
end end
def usage def usage
print "\nUsage:\n\n" puts <<EOT
print "ripnews.rb [-I <pattern>] [-c <file>] [-L] [-C] [-M] [-S] [-T] [-X <pattern>]\n\n"
print "-I <pattern> specify an include pattern\n" Usage:
print "-c <file> specify an alternate configfile\n"
print "-L use subject as filename\n" ripnews.rb [-I <pattern>] [-c <file>] [-L] [-C] [-M] [-S] [-T] [-X <pattern>]
print "-C use combined filenames\n"
print "-M get multipart articles\n" -I <pattern> specify an include pattern
print "-s exit silently if already running\n" -c <file> specify an alternate configfile
print "-S get singlepart articles\n" -L use subject as filename
print "-T test mode, don't update newsrc file\n" -C use combined filenames
print "-X <pattern> specify an exclude pattern\n" -M get multipart articles
-s exit silently if already running
-S get singlepart articles
-T test mode, don't update newsrc file
-X <pattern> specify an exclude pattern
EOT
exit exit
end end
def parse_config(default = {}) def parse_config(default = {})
if ! default.has_key?('-s') if ! default.has_key?('-s')
print "Parsing config\n" puts "Parsing config"
print "#{default['-c']}\n" puts "#{default['-c']}"
end end
if FileTest.readable?("#{default['-c']}") if FileTest.readable?("#{default['-c']}")
file = File.new("#{default['-c']}") file = File.new("#{default['-c']}")
@ -282,7 +291,7 @@ def parse_config(default = {})
if line =~ /^OPT_(.*?)=(.*)/ if line =~ /^OPT_(.*?)=(.*)/
line = "-#{$1}=#{$2}" line = "-#{$1}=#{$2}"
end end
print "#{i}: #{line}\n" if Debuglevel > 1 puts "#{i}: #{line}" if Debuglevel > 1
if line =~ /(.*?)\s*\+=\s*(.*)/ if line =~ /(.*?)\s*\+=\s*(.*)/
if group == "" if group == ""
if default.has_key?($1) if default.has_key?($1)
@ -326,21 +335,21 @@ def parse_config(default = {})
elsif line =~ /^$/ elsif line =~ /^$/
next next
else else
print "Error parsing config on line: #{i}\n" puts "Error parsing config on line: #{i}"
return false return false
end end
end end
if group != "" if group != ""
print "Error parsing config: group not terminated on line #{i}\n" puts "Error parsing config: group not terminated on line #{i}"
return false return false
end end
if Debuglevel > 2 if Debuglevel > 2
config.each_key{|x| config.each_key{|x|
print "Group: #{x}\n" puts "Group: #{x}"
config[x].each_key{|y| config[x].each_key{|y|
print "Key: '#{y}' => Value: '#{config[x][y]}'\n" puts "Key: '#{y}' => Value: '#{config[x][y]}'"
} }
} }
end end
@ -349,12 +358,12 @@ end
def check_config def check_config
if @config.length == 0 if @config.length == 0
print "No configuration, nothing to do\n" puts "No configuration, nothing to do"
exit exit
end end
@config.each_key {|i| @config.each_key {|i|
unless @config[i].has_key?("-I") unless @config[i].has_key?("-I")
print "No inclusions given for group #{i}. Won't match anything.\n" puts "No inclusions given for group #{i}. Won't match anything."
end end
@config[i]["DATADIR"] ="." unless @config[i].has_key?("DATADIR") @config[i]["DATADIR"] ="." unless @config[i].has_key?("DATADIR")
@config[i]["PERMISSION"] = "0755" unless @config[i].has_key?("PERMISSION") @config[i]["PERMISSION"] = "0755" unless @config[i].has_key?("PERMISSION")
@ -383,15 +392,15 @@ def lock
begin begin
Process.kill(0, pid.to_i) Process.kill(0, pid.to_i)
if ! @config[group].has_key?('-s') if ! @config[group].has_key?('-s')
print "Already running, exiting...\n" puts "Already running, exiting..."
end end
exit exit
rescue Errno::ESRCH rescue Errno::ESRCH
print "Stale lock found... removing...\n" puts "Stale lock found... removing..."
File.unlink(@config[group]["LOCKFILE"]) File.unlink(@config[group]["LOCKFILE"])
end end
else else
print "Empty lockfile found... removing...\n" puts "Empty lockfile found... removing..."
File.unlink(@config[group]["LOCKFILE"]) File.unlink(@config[group]["LOCKFILE"])
end end
end end
@ -414,31 +423,31 @@ def renice
end end
def get_single(subj, group) def get_single(subj, group)
print "Fetching singlepart article: #{subj}\n" puts "Fetching singlepart article: #{subj}"
body = @articles.get_group_body(subj) body = @articles.get_group_body(subj)
if UUEncode.is_uuencoded(body) if UUEncode.is_uuencoded(body)
filename = UUEncode.get_filename(body) filename = UUEncode.get_filename(body)
print " filename #{filename}\n" puts " filename #{filename}"
unless check_ext(group, filename, "s", subj) unless check_ext(group, filename, "s", subj)
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
print " UUDecoding...\n" puts " UUDecoding..."
mode, filename, body = UUEncode.uudecode(body) mode, filename, body = UUEncode.uudecode(body)
elsif YEnc.is_yencoded(body) elsif YEnc.is_yencoded(body)
filename = YEnc.get_filename(body) filename = YEnc.get_filename(body)
unless check_ext(group, filename, "s", subj) unless check_ext(group, filename, "s", subj)
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
print " YDecoding...\n" puts " YDecoding..."
mode, filename, body = YEnc.ydecode(body) mode, filename, body = YEnc.ydecode(body)
else else
print " Unknown encoding (not UU, not yEnc), skipping...\n" puts " Unknown encoding (not UU, not yEnc), skipping..."
return false return false
end end
if mode == false if mode == false
print " Decoding failed skipping article...\n" puts " Decoding failed skipping article..."
return false return false
end end
output_data(subj, mode, filename, body) output_data(subj, mode, filename, body)
@ -446,22 +455,22 @@ def get_single(subj, group)
end end
def get_multi(subj, group) def get_multi(subj, group)
print "Fetching multipart article: #{subj}\n" puts "Fetching multipart article: #{subj}"
body = @articles.get_group_body_first(subj) body = @articles.get_group_body_first(subj)
if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body) if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body)
if UUEncode.is_uuencoded(body) if UUEncode.is_uuencoded(body)
filename = UUEncode.get_filename(body) filename = UUEncode.get_filename(body)
print " filename #{filename}\n" puts " filename #{filename}"
unless check_ext(group, filename, "m", subj) unless check_ext(group, filename, "m", subj)
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
elsif YEnc.is_yencoded(body) elsif YEnc.is_yencoded(body)
print "yencc\n" puts "yenc"
filename = YEnc.get_filename(body) filename = YEnc.get_filename(body)
print "filename #{filename}\n" puts "filename #{filename}"
unless check_ext(group, filename, "m", subj) unless check_ext(group, filename, "m", subj)
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
end end
@ -469,7 +478,7 @@ def get_multi(subj, group)
if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == "" if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == ""
bodyrest = @articles.get_group_body_rest(subj) bodyrest = @articles.get_group_body_rest(subj)
unless bodyrest unless bodyrest
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
body.concat(bodyrest) body.concat(bodyrest)
@ -478,7 +487,7 @@ def get_multi(subj, group)
body.collect{|x| file.print "#{x}\n"} body.collect{|x| file.print "#{x}\n"}
unless @articles.get_group_body_rest(subj, file) unless @articles.get_group_body_rest(subj, file)
print " Skipping article...\n" puts " Skipping article..."
return false return false
end end
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"]) fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
@ -489,14 +498,14 @@ def get_multi(subj, group)
Thread.pass Thread.pass
# puts "inside thread post pass\n" # puts "inside thread post pass\n"
if UUEncode.is_uuencoded(tbody) if UUEncode.is_uuencoded(tbody)
print " UUDecoding...\n" puts " UUDecoding..."
if tfile if tfile
tmode, tfilename, tbody = UUEncode.uudecode(tfile, tfileout) tmode, tfilename, tbody = UUEncode.uudecode(tfile, tfileout)
else else
tmode, tfilename, tbody = UUEncode.uudecode(tbody) tmode, tfilename, tbody = UUEncode.uudecode(tbody)
end end
elsif YEnc.is_yencoded(tbody) elsif YEnc.is_yencoded(tbody)
print " YDecoding...\n" puts " YDecoding..."
begin begin
if tfile if tfile
tmode, tfilename, tbody = YEnc.ydecode(tfile, tfileout) tmode, tfilename, tbody = YEnc.ydecode(tfile, tfileout)
@ -509,13 +518,13 @@ def get_multi(subj, group)
# XXX return succes even though it's not true # XXX return succes even though it's not true
Thread.current.exit Thread.current.exit
rescue PermError rescue PermError
print "#{$!}\n" puts "#{$!}"
print " Skipping article...\n" puts " Skipping article..."
Thread.current.exit Thread.current.exit
end end
end end
if tmode == false if tmode == false
print " Decoding failed skipping article...\n" puts " Decoding failed skipping article..."
Thread.current.exit Thread.current.exit
end end
@ -539,7 +548,7 @@ def get_multi(subj, group)
return true return true
else else
print " Unknown encoding (not UU, not yEnc), skipping...\n" puts " Unknown encoding (not UU, not yEnc), skipping..."
return false return false
end end
end end
@ -552,8 +561,8 @@ end
def output_data(subject, mode, filename="", body="") def output_data(subject, mode, filename="", body="")
group = @articles.get_groupname group = @articles.get_groupname
print " mode: #{mode}\n" if Debuglevel > 0 puts " mode: #{mode}" if Debuglevel > 0
print " Filename: '#{filename}'\n" if Debuglevel > 0 puts " Filename: '#{filename}'" if Debuglevel > 0
# de-crap subject... # de-crap subject...
sub = subject.sub(/\s*$/, "") # strip trailing spaces sub = subject.sub(/\s*$/, "") # strip trailing spaces
@ -561,17 +570,17 @@ def output_data(subject, mode, filename="", body="")
# decide on a filename # decide on a filename
if @config[group].has_key?("-L") and @config[group]["-L"] if @config[group].has_key?("-L") and @config[group]["-L"]
print "longname\n" if Debuglevel > 1 puts "longname" if Debuglevel > 1
outfile = sub[0...@maxfilelength] outfile = sub[0...@maxfilelength]
elsif @config[group].has_key?("-C") and @config[group]["-C"] elsif @config[group].has_key?("-C") and @config[group]["-C"]
print "combinedname\n" if Debuglevel > 1 puts "combinedname" if Debuglevel > 1
outfile = sub[0...@maxfilelength-filename.length-3] outfile = sub[0...@maxfilelength-filename.length-3]
outfile = "#{outfile} [#{filename}]" outfile = "#{outfile} [#{filename}]"
if outfile.length > @maxfilelength if outfile.length > @maxfilelength
outfile = filename[0...@maxfilelength] outfile = filename[0...@maxfilelength]
end end
elsif @config[group].has_key?("-CP") and @config[group]["-CP"] elsif @config[group].has_key?("-CP") and @config[group]["-CP"]
print "combinedname\n" if Debuglevel > 1 puts "combinedname" if Debuglevel > 1
poster = @articles.get_group_poster(subject) poster = @articles.get_group_poster(subject)
outfile = sub[0...@maxfilelength-poster.length-filename.length-6] outfile = sub[0...@maxfilelength-poster.length-filename.length-6]
outfile = "#{outfile} [#{poster}] [#{filename}]" outfile = "#{outfile} [#{poster}] [#{filename}]"
@ -579,7 +588,7 @@ def output_data(subject, mode, filename="", body="")
outfile = filename[0...@maxfilelength] outfile = filename[0...@maxfilelength]
end end
else else
print "shortname\n" if Debuglevel > 1 puts "shortname" if Debuglevel > 1
outfile = filename[0...@maxfilelength] outfile = filename[0...@maxfilelength]
end end
@ -596,27 +605,27 @@ def check_ext(group, filename, mode, subject)
case mode case mode
when "s" when "s"
if @config[group].has_key?("-SD") && ( filename =~ /\.(#{@config[group]["-SD"]})$/ ) if @config[group].has_key?("-SD") && ( filename =~ /\.(#{@config[group]["-SD"]})$/ )
print "Marking '#{subject}' as read\n" puts "Marking '#{subject}' as read"
@articles.group_update_newsrc(subject) @articles.group_update_newsrc(subject)
return false return false
end end
return @config[group].has_key?("-S") ? ( filename =~ /\.(#{@config[group]["-S"]})$/ ) : true return @config[group].has_key?("-S") ? ( filename =~ /\.(#{@config[group]["-S"]})$/ ) : true
when "m" when "m"
if @config[group].has_key?("-MD") && ( filename =~ /\.(#{@config[group]["-MD"]})$/ ) if @config[group].has_key?("-MD") && ( filename =~ /\.(#{@config[group]["-MD"]})$/ )
print "Marking '#{subject}' as read\n" puts "Marking '#{subject}' as read"
@articles.group_update_newsrc(subject) @articles.group_update_newsrc(subject)
return false return false
end end
return @config[group].has_key?("-M") ? ( filename =~ /\.(#{@config[group]["-M"]})$/ ) : true return @config[group].has_key?("-M") ? ( filename =~ /\.(#{@config[group]["-M"]})$/ ) : true
else else
print "Illegal mode \"#{mode}\" in check_ext\n" puts "Illegal mode \"#{mode}\" in check_ext"
exit exit
end end
end end
def get_max_file_length(tempdir=".") def get_max_file_length(tempdir=".")
if ! FileTest.directory?("#{tempdir}") || ! FileTest.writable?("#{tempdir}") if ! FileTest.directory?("#{tempdir}") || ! FileTest.writable?("#{tempdir}")
print "Tempdir '#{tempdir}' is not a writable directory\n" puts "Tempdir '#{tempdir}' is not a writable directory"
exit exit
end end
# this is quite stupid, there is no guarantee at all the generated file names # this is quite stupid, there is no guarantee at all the generated file names
@ -630,8 +639,8 @@ def get_max_file_length(tempdir=".")
name = name[0...-1] name = name[0...-1]
retry retry
rescue Errno::ENOENT rescue Errno::ENOENT
print "#{$!}\n" puts "#{$!}"
print "strange...\n" puts "strange..."
retry retry
end end
# this is how many characters are still likely to be appended # this is how many characters are still likely to be appended
@ -668,27 +677,27 @@ def startup
renice renice
trap("HUP") { trap("HUP") {
print "Rereading config...\n" puts "Rereading config..."
config = parse_config(@defaults) config = parse_config(@defaults)
if config != false if config != false
@config = config @config = config
check_config check_config
print "Done reading config\n" puts "Done reading config"
else else
print "Keeping old config due to errors\n" puts "Keeping old config due to errors"
end end
} }
@maxfilelength = get_max_file_length(@config[@config.keys[0]]["TEMPDIR"]) @maxfilelength = get_max_file_length(@config[@config.keys[0]]["TEMPDIR"])
print "\n$Id$\n" puts "\n$Id$"
print "Starting: #{@tstart}\n" puts "Starting: #{@tstart}"
if Debuglevel > 2 if Debuglevel > 2
@config.each_key{|i| @config.each_key{|i|
print "Group: #{i}\n" puts "Group: #{i}"
@config[i].each_key{|j| @config[i].each_key{|j|
print "Opt: #{j} val: #{@config[i][j]}\n" puts "Opt: #{j} val: #{@config[i][j]}"
} }
} }
end end
@ -700,10 +709,10 @@ def main
@decode_threads = [] @decode_threads = []
@newsrc_lock = Mutex.new @newsrc_lock = Mutex.new
profile_mem("#{group} start") profile_mem("#{group} start")
print "\nGetting articles for #{group}\n" puts "\nGetting articles for #{group}"
@articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"]) @articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"])
fill_preselector(group) fill_preselector(group)
print "initialized\n" puts "initialized"
@articles.get_articles(@config[group]["CACHEDIR"]) @articles.get_articles(@config[group]["CACHEDIR"])
profile_mem("#{group} articles read") profile_mem("#{group} articles read")
@ -711,23 +720,23 @@ def main
_create_group_dir(group) _create_group_dir(group)
for subj in @articles.get_group_subjects.sort{|a, b| ward_sort(a, b)} for subj in @articles.get_group_subjects.sort{|a, b| ward_sort(a, b)}
print "#{subj}\n" if Debuglevel > 2 puts "#{subj}" if Debuglevel > 2
poster = @articles.get_group_poster(subj) poster = @articles.get_group_poster(subj)
# explicitly mark as read # explicitly mark as read
if @config[group].has_key?("-MR") and subj =~ /#{@config[group]["-MR"]}/ if @config[group].has_key?("-MR") and subj =~ /#{@config[group]["-MR"]}/
print "Marking '#{subj}' as read\n" puts "Marking '#{subj}' as read"
_mark_read(subj) _mark_read(subj)
# get the juicy bits # get the juicy bits
elsif @config[group].has_key?("-MRF") and poster =~ /#{@config[group]["-MRF"]}/ elsif @config[group].has_key?("-MRF") and poster =~ /#{@config[group]["-MRF"]}/
print "Marking poster '#{poster}' as read\n" puts "Marking poster '#{poster}' as read (subj: '#{subj}')"
_mark_read(subj) _mark_read(subj)
elsif !(@config[group].has_key?("-X") and subj =~ /#{@config[group]["-X"]}/) and elsif !(@config[group].has_key?("-X") and subj =~ /#{@config[group]["-X"]}/) and
subj =~ /#{@config[group]["-I"]}/ subj =~ /#{@config[group]["-I"]}/
print "Match: #{subj}\n" if Debuglevel > 0 puts "Match: #{subj}" if Debuglevel > 0
_get_article(subj, group) _get_article(subj, group)
elsif !(@config[group].has_key?("-XF") and poster =~ /#{@config[group]["-XF"]}/) and elsif !(@config[group].has_key?("-XF") and poster =~ /#{@config[group]["-XF"]}/) and
@config[group].has_key?("-IF") and poster =~ /#{@config[group]["-IF"]}/ @config[group].has_key?("-IF") and poster =~ /#{@config[group]["-IF"]}/
print "Poster match: #{poster}\n" if Debuglevel > 0 puts "Poster match: #{poster}" if Debuglevel > 0
_get_article(subj, group) _get_article(subj, group)
else else
_mark_remaining(subj, group) _mark_remaining(subj, group)
@ -747,7 +756,7 @@ end
def ending def ending
tend = Time.now tend = Time.now
print "\nFinished: #{tend}\n" puts "\nFinished: #{tend}"
runtime = (tend - @tstart).to_i runtime = (tend - @tstart).to_i
h=runtime/3600 h=runtime/3600
m=runtime%3600 m=runtime%3600
@ -760,7 +769,7 @@ end
def _create_group_dir(group) def _create_group_dir(group)
unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or
Dir.mkdir("#{@config[group]["DATADIR"]}/#{group}", @config[group]["PERMISSION"].oct) Dir.mkdir("#{@config[group]["DATADIR"]}/#{group}", @config[group]["PERMISSION"].oct)
print "eeeps, couldn't create dir\n" puts "eeeps, couldn't create dir"
exit exit
end end
end end
@ -768,7 +777,7 @@ end
def _primary_thres_skip(subj, group) def _primary_thres_skip(subj, group)
if @config[group].has_key?("PRIMARYTHRES") if @config[group].has_key?("PRIMARYTHRES")
if ( @articles.group_percentage_primary(subj) < @config[group]["PRIMARYTHRES"].to_i ) if ( @articles.group_percentage_primary(subj) < @config[group]["PRIMARYTHRES"].to_i )
print "Only #{@articles.group_percentage_primary(subj)}% on primary, skipping: #{subj}\n" puts "Only #{@articles.group_percentage_primary(subj)}% on primary, skipping: #{subj}"
return true return true
end end
end end
@ -778,7 +787,7 @@ end
def _fallback_thres_skip(subj, group) def _fallback_thres_skip(subj, group)
if @config[group].has_key?("FALLBACKTHRES") if @config[group].has_key?("FALLBACKTHRES")
if ( @articles.group_percentage_fallback(subj) > @config[group]["FALLBACKTHRES"].to_i ) if ( @articles.group_percentage_fallback(subj) > @config[group]["FALLBACKTHRES"].to_i )
print "#{@articles.group_percentage_fallback(subj)}% only on fallback, skipping: #{subj}\n" puts "#{@articles.group_percentage_fallback(subj)}% only on fallback, skipping: #{subj}"
return true return true
end end
end end
@ -802,14 +811,14 @@ def _get_article(subj, group)
get_multi(subj, group) get_multi(subj, group)
end end
rescue TempError, PermError, YencError rescue TempError, PermError, YencError
print "#{$!}\n" puts "#{$!}"
print " Skipping article...\n" puts " Skipping article..."
#print "Caught #{$!.class}\n" #puts "Caught #{$!.class}"
#print "Error: #{$!}\n" #puts "Error: #{$!}"
end end
end end
else else
print "Not complete: #{subj}\n" puts "Not complete: #{subj}"
end end
end end
@ -821,7 +830,7 @@ def _mark_remaining(subj, group)
if subj =~ /#{@config[group]["-I"]}/ if subj =~ /#{@config[group]["-I"]}/
puts "fucking up here" puts "fucking up here"
end end
print "Marking remaining '#{subj}' as read\n" puts "Marking remaining '#{subj}' as read"
@articles.group_update_newsrc(subj) @articles.group_update_newsrc(subj)
end end
end end