From: <jj...@us...> - 2004-02-08 12:59:05
|
Update of /cvsroot/ngetsuite/ngetsuite/ngetsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7965/ngetsuite Modified Files: core.rb group.rb queue.rb Log Message: added -p to change the period of queues, added an arg to -r to allow to download in a subdir of basedir/groupdir, fixed the initial value of the period Index: core.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/core.rb,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** core.rb 7 Feb 2004 16:21:20 -0000 1.31 --- core.rb 8 Feb 2004 12:55:48 -0000 1.32 *************** *** 119,123 **** end ! def queue_regexp(groupid, regexp, prio = '5', period = '0') begin n = Integer(prio) --- 119,123 ---- end ! def queue_regexp(groupid, regexp, prio='5', period='0', subpath='') begin n = Integer(prio) *************** *** 128,132 **** name = Group.getname(groupid) g = Group.new(name) ! g.queue_regexp(regexp, n) end --- 128,132 ---- name = Group.getname(groupid) g = Group.new(name) ! g.queue_regexp(regexp, n, period, subpath) end *************** *** 144,147 **** --- 144,153 ---- end + def set_period(queueid, period) + q = Queue.getqueue(queueid) + q._period = period + q.sync_to_db + end + def set_priority(queueid, prio) q = Queue.getqueue(queueid) *************** *** 228,232 **** args = arg.split(',') size = args.size ! if ((size >= 2) && (size <= 4)) queue_regexp(*args) else --- 234,238 ---- args = arg.split(',') size = args.size ! if ((size >= 2) && (size <= 5)) queue_regexp(*args) else *************** *** 247,250 **** --- 253,263 ---- search_group(*args) end + when 'set-period' + args = arg.split(',') + if (args.size == 2) + set_period(*args) + else + raise ArgumentError.new("Incorrect args : #{arg}") + end when 'set-priority' args = arg.split(',') Index: group.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/group.rb,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** group.rb 7 Feb 2004 16:21:20 -0000 1.33 --- group.rb 8 Feb 2004 12:55:48 -0000 1.34 *************** *** 166,171 **** end ! def queue_regexp(regexp, prio) ! q = RegexpQueue.new(nil, false, @_fullname, regexp, prio) q._date_added = Time.now q._status = NgetSuite::PENDING --- 166,171 ---- end ! def queue_regexp(regexp, prio, period=0, subpath='') ! q = RegexpQueue.new(nil, false, @_fullname, regexp, prio, period, subpath) q._date_added = Time.now q._status = NgetSuite::PENDING *************** *** 229,232 **** --- 229,233 ---- Dir.mkdir tempdir pwd = Dir.pwd + Dir.chdir(tempdir) begin # fetches the nfos *************** *** 234,241 **** # but mark them for nget as if we didn't download them `#{@nget} --path #{tempdir} -qq -G #{@_fullname} -U -r '\\.nfo|\\.txt'` ! debug "Fetchnfos: files downloaded in #{Time.now-t}s" sth = Db.dbh.prepare 'insert ignore into nfos (`group`, `mid`, `text`) values (?, ?, ?)' - Dir.chdir(tempdir) Dir['ngettemp-*'].each { |file| File.open(file).each { |line| --- 235,242 ---- # but mark them for nget as if we didn't download them `#{@nget} --path #{tempdir} -qq -G #{@_fullname} -U -r '\\.nfo|\\.txt'` ! debug "Fetchnfos: #{Dir['ngettemp-*'].length} files downloaded in #{Time.now-t}s" + nb_nfos = 0 sth = Db.dbh.prepare 'insert ignore into nfos (`group`, `mid`, `text`) values (?, ?, ?)' Dir['ngettemp-*'].each { |file| File.open(file).each { |line| *************** *** 244,248 **** mid = $1 text = `#{@yydecode} #{file} -o -`.chomp ! sth.execute(@_fullname, mid, text) if text and text.length < 15000 # Does not fucking work #if text and (text.length < 15000) --- 245,252 ---- mid = $1 text = `#{@yydecode} #{file} -o -`.chomp ! if text and text.length < 15000 ! sth.execute(@_fullname, mid, text) ! nb_nfos += 1 ! end # Does not fucking work #if text and (text.length < 15000) *************** *** 259,263 **** `rm -rf #{tempdir}` end ! debug "Fetchnfos finished in #{Time.now-t}s" end --- 263,267 ---- `rm -rf #{tempdir}` end ! debug "Indexed #{nb_nfos} nfos in #{Time.now-t}s" end Index: queue.rb =================================================================== RCS file: /cvsroot/ngetsuite/ngetsuite/ngetsuite/queue.rb,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** queue.rb 7 Feb 2004 16:21:20 -0000 1.22 --- queue.rb 8 Feb 2004 12:55:48 -0000 1.23 *************** *** 2,5 **** --- 2,6 ---- require 'ngetsuite/db' require 'ngetsuite/queue_file' + require 'ftools' module NgetSuite *************** *** 110,114 **** end ! def initialize(id, fetch_from_db = false, group = nil, value = nil, priority = 1, period = 0) @_id = id @_group = group --- 111,115 ---- end ! def initialize(id, fetch_from_db = false, group='', value='', priority=1, period=0, subpath = '') @_id = id @_group = group *************** *** 117,122 **** @_period = period @_subdir = group ! if group ! @_subdir = Group.getgroup(group)._directory.sub(/#{$config['basedir']}\/*/, '') end update_from_db if fetch_from_db --- 118,132 ---- @_period = period @_subdir = group ! if group != '' ! @_subdir = Group.getgroup(group)._directory.sub(/#{$config['basedir']}(#{File::Separator})*/, '') ! if subpath != '' ! @_subdir += File::Separator + subpath ! dir = $config['basedir'] + File::Separator + @_subdir ! if FileTest.exists? dir ! puts "The download target #{dir} already exists" ! else ! File.makedirs dir ! end ! end end update_from_db if fetch_from_db *************** *** 156,162 **** public_class_method :new ! def initialize(id, fetch_from_db = false, group = nil, value = nil, priority = 1, period = 0) @_type = REGEXP ! super(id, fetch_from_db, group, value, priority, period) end --- 166,172 ---- public_class_method :new ! def initialize(*args) @_type = REGEXP ! super(*args) end *************** *** 169,175 **** public_class_method :new ! def initialize(id, fetch_from_db = false, group = nil, value = nil, priority = 1, period = 0) @_type = SINGLE ! super(id, fetch_from_db, group, value, priority, period) end --- 179,185 ---- public_class_method :new ! def initialize(*args) @_type = SINGLE ! super(*args) end |