切换到系统dbus 增加系统dbus配置文件

This commit is contained in:
wangsong 2021-09-14 11:24:57 +08:00
parent ae4137a9e7
commit c419449bbc
5 changed files with 40 additions and 17 deletions

View File

@ -631,9 +631,7 @@ class UpdateList():
self._read_important_list()
#important_list 为空时此次不需要升级
if self.important_list:
pass
else:
if not self.important_list:
#不需要升级 全部的软件都是新的
header = _("No software updates are available.")
desc = _('important_list is Empty')
@ -653,8 +651,6 @@ class UpdateList():
logging.info("System all upgradeable packages:new_install:%d upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
#源过滤
# fu = filter.UpdateListFilterCache()
# allowed_origin_upgrade_pkgs = fu.check_in_allowed_origin(pkgs_upgrade)
@ -662,7 +658,7 @@ class UpdateList():
self._make_groups_upgrade(cache,pkgs_upgrade = ([pkg.name for pkg in pkgs_upgrade]))
#是否存在可升级的组
if self.update_list.local_upgrade_list.get('upgrade_groups_list',[]):
if self.local_upgrade_list.get('upgrade_groups_list',[]):
#增加需要移除的包列表
self.local_upgrade_list.update({"pkgs_remove":[pkg.name for pkg in pkgs_remove]})
return True,header,desc

View File

@ -244,19 +244,19 @@ class UpdateManager():
# check if there is another g-a-i already and if not setup one
# listening on dbus
try:
bus = dbus.SessionBus()
# bus = dbus.SystemBus()
# bus = dbus.SessionBus()
bus = dbus.SystemBus()
except Exception:
logging.error("warning: could not initiate dbus")
return
try:
proxy_obj = bus.get_object('org.freedesktop.UpdateManager',
'/org/freedesktop/UpdateManagerObject')
proxy_obj = bus.get_object('com.kylin.systemupgrade',
'/com/kylin/systemupgrade')
logging.warning("kylin-update-manager have started...")
sys.exit(0)
except dbus.DBusException:
bus_name = dbus.service.BusName('org.freedesktop.UpdateManager',
bus_name = dbus.service.BusName('com.kylin.systemupgrade',
bus)
logging.info('initiate dbus success ...')
return UpdateManagerDbusController(self, bus_name)

View File

@ -11,10 +11,10 @@ from .Core.roam import NetworkManagerHelper
class UpdateManagerDbusController(dbus.service.Object):
""" this is a helper to provide the UpdateManagerIFace """
INTERFACE = 'org.freedesktop.UpdateManagerIFace'
INTERFACE = 'com.kylin.systemupgrade.interface'
def __init__(self, parent, bus_name,
object_path='/org/freedesktop/UpdateManagerObject'):
object_path='/com/kylin/systemupgrade'):
dbus.service.Object.__init__(self, bus_name, object_path)
self.parent = parent

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only root can own the service -->
<policy user="root">
<allow own="com.kylin.systemupgrade"/>
<allow send_interface="com.kylin.systemupgrade.interface"/>
</policy>
<!-- Allow anyone to invoke methods on the interfaces -->
<policy context="default">
<allow send_destination="com.kylin.systemupgrade"
send_interface="com.kylin.systemupgrade.interface"/>
<allow send_destination="com.kylin.systemupgrade"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="com.kylin.systemupgrade"
send_interface="org.freedesktop.DBus.Properties"/>
</policy>
</busconfig>

View File

@ -3,14 +3,13 @@
from __future__ import print_function
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from UpdateManager.UpdateManager import UpdateManager
from gettext import gettext as _
import logging
from optparse import OptionParser
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
#定义日志的格式
FORMAT = '%(asctime)-15s %(levelname)s:%(message)s'
@ -35,6 +34,11 @@ if __name__ == "__main__":
logging.basicConfig(format=FORMAT,level=logging.INFO)
logging.info('kylin-update-manager starting ...')
bus_loop = DBusGMainLoop(set_as_default=True)
app = UpdateManager(options)
app.start_update()
Gtk.main()
loop = GLib.MainLoop()
loop.run()