[yast-commit] <rest-service> backgroud_patches_bnc550934 : pass also the requested patch ID to the subscript
ref: refs/heads/backgroud_patches_bnc550934 commit 1f11d6a11f283b7ee266f36bfaf42b2948b689ec Author: Ladislav Slezak <lslezak@novell.com> Date: Wed Dec 16 18:56:58 2009 +0100 pass also the requested patch ID to the subscript --- plugins/patches/app/models/patch.rb | 15 +++++++++------ plugins/patches/scripts/list_patches.rb | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/patches/app/models/patch.rb b/plugins/patches/app/models/patch.rb index a3608c6..bee5300 100644 --- a/plugins/patches/app/models/patch.rb +++ b/plugins/patches/app/models/patch.rb @@ -32,12 +32,13 @@ class Patch < Resolvable end def self.subprocess_find(what) - # open subprocess - subproc = IO.popen(subprocess_command) + subproc = IO.popen(subprocess_command what) result = nil + process_id = what + while !subproc.eof? do begin line = subproc.readline @@ -52,7 +53,7 @@ class Patch < Resolvable elsif received.has_key? 'background_status' s = received['background_status'] - update_progress what do |bs| + update_progress process_id do |bs| bs.status = s['status'] bs.progress = s['progress'] bs.subprogress = s['subprogress'] @@ -155,8 +156,10 @@ class Patch < Resolvable script end - def self.subprocess_command - 'cd ' + RAILS_ROOT + ' && ' + File.join(RAILS_ROOT, 'script/runner') + ' -e ' + - (ENV["RAILS_ENV"] || 'development') + ' ' + subprocess_script + def self.subprocess_command(what) + raise "Invalid parameter" if what.to_s.include?("'") or what.to_s.include?('\\') + ret = "cd #{RAILS_ROOT} && #{File.join(RAILS_ROOT, 'script/runner')} -e #{ENV['RAILS_ENV'] || 'development'} #{subprocess_script}" + ret += " #{what}" if what != :available + ret end end diff --git a/plugins/patches/scripts/list_patches.rb b/plugins/patches/scripts/list_patches.rb index 06c0c74..25d0daf 100644 --- a/plugins/patches/scripts/list_patches.rb +++ b/plugins/patches/scripts/list_patches.rb @@ -12,6 +12,8 @@ bs = BackgroundStatus.new do $stdout.flush end -patches = Patch.do_find(:all, bs) +what = ARGV[0] || :available + +patches = Patch.do_find(what, bs) puts patches.to_xml(:root => "patches", :dasherize => false).gsub!("\n", '') -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
Ladislav Slezak