From 4e1aa466fd0cef148e35e6c76ab96b2ee201c34c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 13 Dec 2012 16:30:37 +0400 Subject: [PATCH] #755: small refactoring --- app/models/build_list.rb | 2 +- app/models/platform.rb | 4 ++-- lib/abf_worker/base_observer.rb | 10 +++++----- lib/abf_worker/iso_worker_observer.rb | 10 +++++----- .../publish_build_list_container_observer.rb | 6 +++--- lib/abf_worker/rpm_worker_observer.rb | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 735d763c2..d3af2ffa6 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -427,7 +427,7 @@ class BuildList < ActiveRecord::Base end if save_to_platform.personal? include_repos_hash["#{save_to_platform.name}_release"] = save_to_platform. - urpmi_list(nil, nil, false)["#{build_for_platform.name}"]["#{arch.name}"] + urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"] end # mdv example: # https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git diff --git a/app/models/platform.rb b/app/models/platform.rb index 767006c95..db48d9179 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -58,7 +58,7 @@ class Platform < ActiveRecord::Base system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.name }/repository/*") end - def urpmi_list(host = nil, pair = nil, add_commands = true) + def urpmi_list(host = nil, pair = nil, add_commands = true, repository_name = 'main') host ||= default_host blank_pair = {:login => 'login', :pass => 'password'} pair = blank_pair if pair.blank? @@ -69,7 +69,7 @@ class Platform < ActiveRecord::Base local_pair = pl.id != self.id ? blank_pair : pair head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/" Arch.all.each do |arch| - tail = "/#{arch.name}/main/release" + tail = "/#{arch.name}/#{repository_name}/release" command = add_commands ? "urpmi.addmedia #{name} " : '' command << "#{head}#{name}/repository/#{pl.name}#{tail}" urpmi_commands[pl.name][arch.name] = command diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index 21133237b..86e402e18 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -1,10 +1,10 @@ module AbfWorker class BaseObserver - BUILD_COMPLETED = 0 - BUILD_FAILED = 1 - BUILD_PENDING = 2 - BUILD_STARTED = 3 - BUILD_CANCELED = 4 + COMPLETED = 0 + FAILED = 1 + PENDING = 2 + STARTED = 3 + CANCELED = 4 def self.update_results(subject, options) results = (subject.results || []) + options['results'] diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index 46eb87dcb..b091149d7 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -6,16 +6,16 @@ module AbfWorker status = options['status'].to_i pbl = ProductBuildList.find options['id'] case status - when BUILD_COMPLETED + when COMPLETED pbl.build_success - when BUILD_FAILED + when FAILED pbl.build_error - when BUILD_STARTED + when STARTED pbl.start_build - when BUILD_CANCELED + when CANCELED pbl.build_canceled end - if status != BUILD_STARTED + if status != STARTED update_results(pbl, options) end end diff --git a/lib/abf_worker/publish_build_list_container_observer.rb b/lib/abf_worker/publish_build_list_container_observer.rb index 25974867a..a06012950 100644 --- a/lib/abf_worker/publish_build_list_container_observer.rb +++ b/lib/abf_worker/publish_build_list_container_observer.rb @@ -6,13 +6,13 @@ module AbfWorker bl = BuildList.find options['id'] status = options['status'].to_i case status - when BUILD_COMPLETED + when COMPLETED bl.published update_results(bl, options) - when BUILD_FAILED + when FAILED bl.fail_publish update_results(bl, options) - when BUILD_CANCELED + when CANCELED bl.fail_publish update_results(bl, options) end diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 412a774dd..16f886b41 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -7,21 +7,21 @@ module AbfWorker status = options['status'].to_i item = find_or_create_item(bl) - fill_container_data(bl, options) if status != BUILD_STARTED + fill_container_data(bl, options) if status != STARTED case status - when BUILD_COMPLETED + when COMPLETED bl.build_success item.update_attributes({:status => BuildServer::SUCCESS}) bl.now_publish if bl.auto_publish? - when BUILD_FAILED + when FAILED bl.build_error item.update_attributes({:status => BuildServer::BUILD_ERROR}) - when BUILD_STARTED + when STARTED bl.bs_id = bl.id bl.save! bl.start_build - when BUILD_CANCELED + when CANCELED bl.build_canceled item.update_attributes({:status => BuildList::BUILD_CANCELED}) end