From: <jj...@us...> - 2004-02-04 05:59:13
|
Update of /cvsroot/ngetsuite/ngetsuite/ngetsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31139/ngetsuite Modified Files: core.rb downloader.rb downloadmanager.rb ngetcache.rb utils.rb Log Message: downloader shutdown bugfix, misc bugfix Index: core.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/core.rb,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** core.rb 4 Feb 2004 03:07:57 -0000 1.28 --- core.rb 4 Feb 2004 05:56:50 -0000 1.29 *************** *** 226,230 **** end when 'delete-queue' ! Queue.delete(arg, false) when 'show-queue' args = arg.split(',') --- 226,230 ---- end when 'delete-queue' ! Queue.delete(arg, true) when 'show-queue' args = arg.split(',') Index: downloader.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/downloader.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** downloader.rb 3 Feb 2004 21:29:38 -0000 1.18 --- downloader.rb 4 Feb 2004 05:56:50 -0000 1.19 *************** *** 40,47 **** def update_status(line) ! #debug(Utils.red("begin update_status")) ! if line =~ /^already have .*\n$/ @nbfiles += 1 ! elsif line =~ /^Retrieving: (\d+).*\t(\d+)l.*(<.*>)\n$/ parts, nblines, mid = $1, $2, $3 @nbfiles += 1 --- 40,49 ---- def update_status(line) ! line.chomp! ! case line ! when /^already have (.*)$/ ! debug 'file already there : ' + $1 @nbfiles += 1 ! when /^Retrieving: (\d+).*\t(\d+)l.*(<.*>)$/ parts, nblines, mid = $1, $2, $3 @nbfiles += 1 *************** *** 55,59 **** debug (Utils.red "already in database") end ! elsif line =~ /\d+ \((\d+)\/\d+\).*\d+\/(\d+)B.* (\d+)B\/s \w+ (\d+)\/(\d+) \w+\n$/ part = $1 size = $2 --- 57,69 ---- debug (Utils.red "already in database") end ! when /^(\d+) \((\d+)\/(\d+)\): (\d+)\/(\d+)L (\d+)\/(\d+)B (\d+)% (\d+)B\/s (\w+) (\d+)\/(\d+) (\w+)$/ ! part = $2 ! size = $7 ! speed = $9 ! filenb = $12 ! debug "#{yellow $5+'L'}(#{yellow $7+'B'}) at #{red $9+'B/s'} [#{blue $2}/#{blue $3}] [#{green $11}/#{green $12}]" ! @curfile.update(part, speed, filenb, size) ! when /\d+ \((\d+)\/\d+\).*\d+\/(\d+)B.* (\d+)B\/s \w+ (\d+)\/(\d+) \w+$/ ! debug (Utils.red "the previous regexp should have been matched instead of this one") part = $1 size = $2 *************** *** 61,72 **** filenb = $4 @curfile.update(part, speed, filenb, size) ! elsif line =~ /^uu_msg\(\d+\):Loaded from .*: '.*' \(.*\): (.*) part \d+.*end (.*)\n$/ debug (Utils.yellow "filename : #{$1}, encoding : #{$2}") @curfile._filename = $1 @curfile.encoding = $2 ! elsif line =~ /^decoded ok/ @curfile.finish(true) log "Download finished for file #{@curfile._filename}, queue #{@value}" #TODO : handle decoding failures (=> @curfile.finish(false)) end #debug (Utils.red "end update_status") --- 71,88 ---- filenb = $4 @curfile.update(part, speed, filenb, size) ! when /^autopar/ ! debug 'autopar: ' + blue(line.gsub(/\t/, red('\\t'))) ! ! when /^uu_msg\(\d+\):Loaded from .*: '.*' \(.*\): (.*) part \d+.*end (.*)$/ debug (Utils.yellow "filename : #{$1}, encoding : #{$2}") @curfile._filename = $1 @curfile.encoding = $2 ! when /^decoded ok/ ! debug 'file decoded' @curfile.finish(true) log "Download finished for file #{@curfile._filename}, queue #{@value}" #TODO : handle decoding failures (=> @curfile.finish(false)) + else + debug "unhandled msg : #{blue line}" end #debug (Utils.red "end update_status") *************** *** 78,82 **** @start_time = Time.new @status = 'PROCESSING' - puts "before locking" $dbh.do 'lock tables queue write' $dbh.do "update queue set `status` = 'PROCESSING', `date_started`= NOW() where `id` = '#{@id}'" --- 94,97 ---- *************** *** 86,94 **** begin io.each { |line| - debug(Utils.blue(line)) update_status line } rescue Exception => e ! puts "Exception : #{e} => " + e.message print e.backtrace.join("\n") rescue Error => e --- 101,111 ---- begin io.each { |line| update_status line } + rescue IOError + puts 'nget got killed' + rescue Exception => e ! puts "Exception : #{e.class} => " + e.message print e.backtrace.join("\n") rescue Error => e *************** *** 110,113 **** --- 127,131 ---- def stop # oh no they killed kenny ! + debug "#{red 'dlder.stop'}" Process.kill('SIGTERM', @io.pid) @io.close *************** *** 115,119 **** $dbh.do 'lock tables queue write' ! $dbh.do "update queue set `status` = 'STOPPED', `date_finished`=NOW() where `id` = '#{@id}'" $dbh.do 'unlock tables' log "Download stopped for queue #{@value}, group #{@group}" --- 133,137 ---- $dbh.do 'lock tables queue write' ! $dbh.do "update `queue` set `status` = 'STOPPED', `date_finished`=NOW() where `id` = '#{@id}'" $dbh.do 'unlock tables' log "Download stopped for queue #{@value}, group #{@group}" Index: downloadmanager.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/downloadmanager.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** downloadmanager.rb 3 Feb 2004 21:29:38 -0000 1.15 --- downloadmanager.rb 4 Feb 2004 05:56:50 -0000 1.16 *************** *** 59,62 **** --- 59,63 ---- return false if row == nil + debug(green("New downloader starting")) @current_dlers += 1 *************** *** 86,90 **** if @started @started = false ! @dlers.each { |d| d.stop } --- 87,91 ---- if @started @started = false ! @dlers.each { |i, d| d.stop } Index: ngetcache.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/ngetcache.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ngetcache.rb 4 Feb 2004 01:45:39 -0000 1.4 --- ngetcache.rb 4 Feb 2004 05:56:50 -0000 1.5 *************** *** 50,53 **** --- 50,54 ---- raise BadNgetCache.new('not a ngetcache file') unless $1 == 'NGET4' and $3 == '1' @partscounttotal = $2.to_i + @partscountcurrent = 0 # servers description *************** *** 110,113 **** --- 111,116 ---- part.articles << article end + @partscountcurrent += 1 + print "#{@partscountcurrent}/#{@partscounttotal}\r" if $stdout.isatty part end Index: utils.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/utils.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** utils.rb 2 Feb 2004 17:44:19 -0000 1.10 --- utils.rb 4 Feb 2004 05:56:50 -0000 1.11 *************** *** 24,28 **** def Utils.debug(message=nil) ! puts "DEBUG: #{message}" if($config.fetch('debug', false) && message) end --- 24,28 ---- def Utils.debug(message=nil) ! puts "D: #{message}" if($config.fetch('debug', false) && message) end |