ref: refs/heads/network
commit c982fd8b45435a5fd5a7afc7fc788ce391b2911b
Author: Klaus Kämpf
Date: Thu Sep 10 11:20:53 2009 +0200
Set RAILS_ENV only if it wasn't defined before
---
plugins/patches/app/models/packagekit.rb | 90 ------------------------------
plugins/patches/app/models/resolvable.rb | 90 ++++++++++++++++++++++++++++++
webservice/config/environment.rb | 7 ++-
3 files changed, 95 insertions(+), 92 deletions(-)
diff --git a/plugins/patches/app/models/packagekit.rb b/plugins/patches/app/models/packagekit.rb
deleted file mode 100644
index 5f7c654..0000000
--- a/plugins/patches/app/models/packagekit.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-require "dbus"
-require 'socket'
-require 'thread'
-
-# Model for patches available via package kit
-class PackageKitModule
-
- def id
- @resolvable_id
- end
-
- def id=(id_val)
- @resolvable_id = id_val
- end
-
- # returns the modification time of
- # the patch status, which you can use
- # for cache policy purposes
- def self.mtime
- # we look for the most recent (max) modification time
- # of either the package database or libzypp cache files
- [ File.stat("/var/lib/rpm/Packages").mtime,
- File.stat("/var/cache/zypp/solv").mtime,
- * Dir["/var/cache/zypp/solv/*/solv"].map{ |x| File.stat(x).mtime } ].max
- end
-
- # default constructor
- def initialize(attributes)
- attributes.each do |key, value|
- instance_variable_set("@#{key}", value)
- end
- end
-
- def to_json( options = {} )
- hash = Hash.from_xml(to_xml())
- return hash.to_json
- end
-
- # find patches
- # Patch.find(:available)
- # Patch.find(212)
- def self.execute(method, args, signal, &block)
- patch_updates = []
- system_bus = DBus::SystemBus.instance
- package_kit = system_bus.service("org.freedesktop.PackageKit")
- obj = package_kit.object("/org/freedesktop/PackageKit")
- #logger.debug obj.inspect
- obj.introspect
- obj_with_iface = obj["org.freedesktop.PackageKit"]
- tid = obj_with_iface.GetTid
- obj_tid = package_kit.object(tid[0])
- obj_tid.introspect
- obj_tid_with_iface = obj_tid["org.freedesktop.PackageKit.Transaction"]
- obj_tid.default_iface = "org.freedesktop.PackageKit.Transaction"
-
- loop = DBus::Main.new
- loop << system_bus
-
- obj_tid.on_signal(signal.to_s, &block)
- obj_tid.on_signal("Error") {|u1,u2| loop.quit }
- obj_tid.on_signal("Finished") {|u1,u2| loop.quit }
-
- obj_tid_with_iface.send(method.to_sym, *args)
- loop.run
-
- obj_with_iface.SuggestDaemonQuit
- return patch_updates
- end
-
- # installs this
- def install
- self.class.install(id)
- end
-
- # Patch.install(patch)
- # Patch.install(id)
- def self.install(patch)
- if patch.is_a?(Patch)
- update_id = "#{patch.name};#{patch.resolvable_id};#{patch.arch};#{@patch.repo}"
- Rails.logger.debug "Install Update: #{update_id}"
- self.package_kit_install(update_id)
- else
- # if is not an object, assume it is an id
- patch_id = patch
- patch = Patch.find(patch_id)
- raise "Can't install update #{patch_id} because it does not exist" if patch.nil? or not patch.is_a?(Patch)
- self.install(patch)
- end
- end
-end
diff --git a/plugins/patches/app/models/resolvable.rb b/plugins/patches/app/models/resolvable.rb
new file mode 100644
index 0000000..5f7c654
--- /dev/null
+++ b/plugins/patches/app/models/resolvable.rb
@@ -0,0 +1,90 @@
+require "dbus"
+require 'socket'
+require 'thread'
+
+# Model for patches available via package kit
+class PackageKitModule
+
+ def id
+ @resolvable_id
+ end
+
+ def id=(id_val)
+ @resolvable_id = id_val
+ end
+
+ # returns the modification time of
+ # the patch status, which you can use
+ # for cache policy purposes
+ def self.mtime
+ # we look for the most recent (max) modification time
+ # of either the package database or libzypp cache files
+ [ File.stat("/var/lib/rpm/Packages").mtime,
+ File.stat("/var/cache/zypp/solv").mtime,
+ * Dir["/var/cache/zypp/solv/*/solv"].map{ |x| File.stat(x).mtime } ].max
+ end
+
+ # default constructor
+ def initialize(attributes)
+ attributes.each do |key, value|
+ instance_variable_set("@#{key}", value)
+ end
+ end
+
+ def to_json( options = {} )
+ hash = Hash.from_xml(to_xml())
+ return hash.to_json
+ end
+
+ # find patches
+ # Patch.find(:available)
+ # Patch.find(212)
+ def self.execute(method, args, signal, &block)
+ patch_updates = []
+ system_bus = DBus::SystemBus.instance
+ package_kit = system_bus.service("org.freedesktop.PackageKit")
+ obj = package_kit.object("/org/freedesktop/PackageKit")
+ #logger.debug obj.inspect
+ obj.introspect
+ obj_with_iface = obj["org.freedesktop.PackageKit"]
+ tid = obj_with_iface.GetTid
+ obj_tid = package_kit.object(tid[0])
+ obj_tid.introspect
+ obj_tid_with_iface = obj_tid["org.freedesktop.PackageKit.Transaction"]
+ obj_tid.default_iface = "org.freedesktop.PackageKit.Transaction"
+
+ loop = DBus::Main.new
+ loop << system_bus
+
+ obj_tid.on_signal(signal.to_s, &block)
+ obj_tid.on_signal("Error") {|u1,u2| loop.quit }
+ obj_tid.on_signal("Finished") {|u1,u2| loop.quit }
+
+ obj_tid_with_iface.send(method.to_sym, *args)
+ loop.run
+
+ obj_with_iface.SuggestDaemonQuit
+ return patch_updates
+ end
+
+ # installs this
+ def install
+ self.class.install(id)
+ end
+
+ # Patch.install(patch)
+ # Patch.install(id)
+ def self.install(patch)
+ if patch.is_a?(Patch)
+ update_id = "#{patch.name};#{patch.resolvable_id};#{patch.arch};#{@patch.repo}"
+ Rails.logger.debug "Install Update: #{update_id}"
+ self.package_kit_install(update_id)
+ else
+ # if is not an object, assume it is an id
+ patch_id = patch
+ patch = Patch.find(patch_id)
+ raise "Can't install update #{patch_id} because it does not exist" if patch.nil? or not patch.is_a?(Patch)
+ self.install(patch)
+ end
+ end
+end
diff --git a/webservice/config/environment.rb b/webservice/config/environment.rb
index 3edeabe..c85bf30 100644
--- a/webservice/config/environment.rb
+++ b/webservice/config/environment.rb
@@ -6,9 +6,12 @@
# Hmm, don't know if this is the right place for this
# but http://groups.google.com/group/sdruby/browse_thread/thread/5239824b058ac936 doesn't know any better
-RAILS_ENV = ENV['RAILS_ENV']
+#
+# Apparently, webrick sets it, while "rake test" doesn't.
+#
+RAILS_ENV = ENV['RAILS_ENV'] unless defined? RAILS_ENV
-STDERR.puts "RAILS_ENV environment variable isn't set !" unless RAILS_ENV
+STDERR.puts "\n\n\t***RAILS_ENV environment variable isn't set !\n\n" unless RAILS_ENV
# Specifies gem version of Rails to use when vendor/rails is not present
# RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org