From: <jj...@us...> - 2004-02-23 20:02:17
|
Update of /cvsroot/ngetsuite/ngetsuite/ngetsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29689/ngetsuite Modified Files: config.rb downloader.rb group.rb utils.rb Log Message: misc bugfix, fixed base changing function, added 'nice_nget_update' and 'nice_nget_download' config options Index: config.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/config.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** config.rb 6 Feb 2004 23:46:59 -0000 1.4 --- config.rb 23 Feb 2004 17:08:08 -0000 1.5 *************** *** 28,31 **** --- 28,33 ---- debug = false daemon_debug = false + nice_nget_update = 0 + nice_nget_download = 0 extern_headers_update = '' extern_nfos_fetch = '' Index: downloader.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/downloader.rb,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** downloader.rb 20 Feb 2004 16:44:39 -0000 1.23 --- downloader.rb 23 Feb 2004 17:08:08 -0000 1.24 *************** *** 80,84 **** @curfile.update(part, speed, filenb, size) when /^autopar.*seems like a (par2?) \((.*)\)/ ! ldebug "autopar: found a #{$1} file for " + blue($2) when /^already have (.*)$/ ldebug "already have the file '#{blue $1}'" --- 80,84 ---- @curfile.update(part, speed, filenb, size) when /^autopar.*seems like a (par2?) \((.*)\)/ ! ldebug "#{yellow 'autopar'}: found a #{$1} file for " + blue($2) when /^already have (.*)$/ ldebug "already have the file '#{blue $1}'" *************** *** 133,137 **** Db.dbh.do "update queue set `status`='PROCESSING', `date_started`=NOW() where `queueindex`='#{@queueindex}'" Db.dbh.do 'unlock tables' ! @io = IO.popen("#{$config['nget']} -q -I -G #{@group} -r '#{@value}' 2>&1") @t = Thread.new(@io, self){ |io, parent| begin --- 133,137 ---- Db.dbh.do "update queue set `status`='PROCESSING', `date_started`=NOW() where `queueindex`='#{@queueindex}'" Db.dbh.do 'unlock tables' ! @io = IO.popen("nice -n#{$config['nice_nget_download']} -- #{$config['nget']} -q -I -G #{@group} -r '#{@value}' 2>&1") @t = Thread.new(@io, self){ |io, parent| begin Index: group.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/group.rb,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** group.rb 20 Feb 2004 16:44:39 -0000 1.37 --- group.rb 23 Feb 2004 17:08:08 -0000 1.38 *************** *** 162,167 **** begin ! IO.popen("nice -n19 #{$config['nget']} -g #{@_fullname} -cr '^#{n}Dummy' 2>&1").each("\r") do |line| ! print "progress#{red $1} speed#{blue $2} ETA#{green $3} \r" if line =~ /Retrieving headers \d+-\d+ : \d+\/\d+\/\d+(\s+\d+%)(\s+\d+B\/s)(.*s)/ and $stdout.isatty end rescue --- 162,167 ---- begin ! IO.popen("nice -n#{$config['nice_nget_update']} -- #{$config['nget']} -g #{@_fullname} -cr '^#{n}Dummy' 2>&1").each("\r") do |line| ! print "progress#{yellow $1} speed#{blue $2} ETA #{$3} \r" if line =~ /Retrieving headers \d+-\d+ : \d+\/\d+\/\d+(\s+\d+%)(\s+\d+B\/s)(.*s)/ and $stdout.isatty end rescue *************** *** 172,176 **** $stdout.sync = false if $stdout.isatty ! debug "Updatengetcache finished in #{Time.now-t}s" end --- 172,176 ---- $stdout.sync = false if $stdout.isatty ! debug "Updatengetcache finished in #{Utils.cooltime(Time.now-t)}" end *************** *** 209,213 **** cache.parse(filecallback) @_cache_low,@_cache_high = cache.servers[0].low, cache.servers[0].high ! debug "Parsengetcache done in #{Time.now-t}s" end --- 209,213 ---- cache.parse(filecallback) @_cache_low,@_cache_high = cache.servers[0].low, cache.servers[0].high ! debug "Parsengetcache done in #{Utils.cooltime(Time.now-t)}" end *************** *** 230,237 **** begin # fetches the nfos, w/o decoding ! `nice -n19 #{$config['nget']} --path #{tempdir} -G #{@_fullname} -K -L 150 -r '\\.nfo|\\.txt' 2>&1` # but mark them for nget as if we didn't download them ! `#{$config['nget']} --path #{tempdir} -qq -G #{@_fullname} -U -r '\\.nfo|\\.txt' 2>&1` ! debug "Fetchnfos: #{Dir['ngettemp-*'].length} files downloaded in #{Time.now-t}s" nb_nfos = 0 --- 230,237 ---- begin # fetches the nfos, w/o decoding ! `nice -n#{$config['nice_nget_update']} -- #{$config['nget']} --path #{tempdir} -G #{@_fullname} -K -L 150 -r '\\.nfo|\\.txt' 2>&1` # but mark them for nget as if we didn't download them ! `nice -n#{$config['nice_nget_update']} -- #{$config['nget']} --path #{tempdir} -qq -G #{@_fullname} -U -r '\\.nfo|\\.txt' 2>&1` ! debug "Fetchnfos: #{Dir['ngettemp-*'].length} files downloaded in #{Utils.cooltime(Time.now-t)}" nb_nfos = 0 *************** *** 258,262 **** end ! debug "Indexed #{nb_nfos} nfos in #{Time.now-t}s" end --- 258,262 ---- end ! debug "Indexed #{nb_nfos} nfos in #{Utils.cooltime(Time.now-t)}" end *************** *** 285,289 **** rls.insert_to_db ! debug "Inserted #{nb_releases} releases in #{Time.now-t}s" end --- 285,289 ---- rls.insert_to_db ! debug "Inserted #{nb_releases} releases in #{Utils.cooltime(Time.now-t)}" end Index: utils.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/utils.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** utils.rb 21 Feb 2004 15:58:18 -0000 1.14 --- utils.rb 23 Feb 2004 17:08:08 -0000 1.15 *************** *** 89,111 **** end ! def Utils.spreadbase(value, base, nbunits, delimiters) return '-1' unless value last = delimiters.pop ! arr = delimiters.map { |d| v = value % base value /= base ! "#{v}#{d}" ! } << "#{value}#{last}" ! ! a = arr.last ! while a.to_i == 0 ! a = arr.pop ! end ! ! return arr.reverse[0..nbunits-1].join(' ') end def Utils.cooltime(seconds) ! Utils.spreadbase(seconds.to_i, 60, 2, ['s', 'm', 'h']) end def cooltime(seconds) --- 89,108 ---- end ! def Utils.spreadbase(value, base, nbshow, delimiters) return '-1' unless value last = delimiters.pop ! arr = Array.new ! arr.concat delimiters.map { |d| v = value % base value /= base ! "#{v}#{d}" if v != 0 ! }.compact ! arr << "#{value}#{last}" if value != 0 ! arr << "0#{delimiters[0]}" if arr.empty? ! return arr.reverse[0..nbshow-1].join(' ') end def Utils.cooltime(seconds) ! Utils.spreadbase(seconds.to_i, 60, 3, ['s', 'm', 'h']) end def cooltime(seconds) *************** *** 114,120 **** def Utils.pretty_size(size) ! Utils.spreadbase(size.to_i, 1024, 1, ['b', 'kb', 'Mb']) end - def pretty_size(asize) Utils.pretty_size(asize) --- 111,116 ---- def Utils.pretty_size(size) ! Utils.spreadbase(size.to_i, 1024, 1, ['b', 'kb', 'Mb', 'Gb']) end def pretty_size(asize) Utils.pretty_size(asize) |