Class: Yast::PackageKitClass

Inherits:
Module
  • Object
show all
Defined in:
library/packages/src/modules/PackageKit.rb

Instance Method Summary collapse

Instance Method Details

#IsRunningBoolean

Check whether PackageKit daemon is running

Returns:

  • (Boolean)

    return true if PackageKit is currently running



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'library/packages/src/modules/PackageKit.rb', line 41

def IsRunning
  cmd = "dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply " \
    "--reply-timeout=200 / org.freedesktop.DBus.NameHasOwner string:org.freedesktop.PackageKit"
  Builtins.y2milestone("Checking PackageKit status: %1", cmd)

  out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))

  ret = false
  lines = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")

  Builtins.foreach(lines) do |line|
    ret = true if Builtins.regexpmatch(line, "boolean.*true")
  end

  Builtins.y2milestone("PackageKit is running: %1", ret)

  ret
end

#mainObject



36
37
# File 'library/packages/src/modules/PackageKit.rb', line 36

def main
end

#SuggestQuitObject

Ask the PackageKit daemon to quit If a transaction is in progress the daemon will not quit, you have to check the current status using isRunning() function.



63
64
65
66
67
68
69
70
71
72
73
# File 'library/packages/src/modules/PackageKit.rb', line 63

def SuggestQuit
  cmd = "dbus-send --system --dest=org.freedesktop.PackageKit --type=method_call " \
    "/org/freedesktop/PackageKit org.freedesktop.PackageKit.SuggestDaemonQuit"
  Builtins.y2milestone("Asking PackageKit to quit: %1", cmd)

  ret = Convert.to_integer(SCR.Execute(path(".target.bash"), cmd))

  Builtins.y2error("dbus-send failed!") if ret != 0

  nil
end