ref: refs/heads/network commit 4b12b4a8afc582b7a86508bc8d06c85cfe9251d0 Author: Martin Vidner <mvidner@suse.cz> Date: Thu Aug 27 09:48:31 2009 +0200 Deleted the wrongly named file. --- plugins/patches/app/models/policykit.rb | 112 ------------------------------- 1 files changed, 0 insertions(+), 112 deletions(-) diff --git a/plugins/patches/app/models/policykit.rb b/plugins/patches/app/models/policykit.rb deleted file mode 100644 index f5bad05..0000000 --- a/plugins/patches/app/models/policykit.rb +++ /dev/null @@ -1,112 +0,0 @@ -require "dbus" -require 'socket' -require 'thread' - -# Used to stop DBus::Main loop -class PKErrorException < Exception; end -# Used to stop DBus::Main loop -class PKFinishedException < Exception; end - -# Model for patches available via package kit -class Policykit - - attr_accessor :resolvable_id, - :kind, - :name, - :arch, - :repo, - :summary - 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" - - obj_tid.on_signal(signal.to_s) do |line1,line2,line3| block.call(line1,line2,line3) end - - obj_tid.on_signal("Error") do |u1,u2| - raise PKErrorException - end - obj_tid.on_signal("Finished") do |u1,u2| - raise PKFinishedException - end - - obj_tid_with_iface.send(method.to_sym, *args) - - if patch_updates.empty? - loop = DBus::Main.new - loop << system_bus - begin - loop.run - rescue PKErrorException - rescue PKFinishedException - end - end - - 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 -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org