From: Yoann G. <jj...@us...> - 2005-12-02 02:07:51
|
Update of /cvsroot/ngetsuite/ngetsuite2/ngetsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20987/ngetsuite Modified Files: clihandler.rb group.rb Log Message: added --batch group,nr,regex which tries to download regex with a thread pool of nr threads - regex is matched against each subject in the group, and the matches are uniq!ed and downloaded to the current directory Index: group.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite2/ngetsuite/group.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** group.rb 19 Nov 2004 11:38:28 -0000 1.4 --- group.rb 2 Dec 2005 02:07:43 -0000 1.5 *************** *** 121,124 **** --- 121,152 ---- return @_directory end + + def batch(nr, filter) + sth = Db.dbh.execute('select subject from articles where groupindex=? and subject RLIKE ?', @_groupindex, filter) + list = [] + sth.fetch do |row| + row[0] =~ /#{filter}/i + list << $~[0] + end + run = [] + list.uniq! + while not list.empty? + if run.length < nr + name = list.shift + run << fork { + Dir.chdir $startdir + cmd = "nget -G #{@_fullname} -qq -r '#{Regexp.escape name}'" + puts cmd + system cmd + exit! + } + sleep 0.5 + else + if run.delete Process.wait + puts "1 done" + end + end + end + end def search_releases(filter) Index: clihandler.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite2/ngetsuite/clihandler.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** clihandler.rb 20 Oct 2004 14:46:38 -0000 1.2 --- clihandler.rb 2 Dec 2005 02:07:43 -0000 1.3 *************** *** 72,75 **** --- 72,79 ---- end + def batch(groupindex, nr, filter) + Group.getgroup(groupindex).batch(nr.to_i, filter) + end + def add_group(groupname, shortname = nil, dir = nil, desc = nil) g = Group.new(nil, false, groupname, shortname, dir, true, desc) |