切换到系统dbus 增加系统dbus配置文件
This commit is contained in:
parent
ae4137a9e7
commit
c419449bbc
|
@ -631,9 +631,7 @@ class UpdateList():
|
||||||
self._read_important_list()
|
self._read_important_list()
|
||||||
|
|
||||||
#important_list 为空时此次不需要升级
|
#important_list 为空时此次不需要升级
|
||||||
if self.important_list:
|
if not self.important_list:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
#不需要升级 全部的软件都是新的
|
#不需要升级 全部的软件都是新的
|
||||||
header = _("No software updates are available.")
|
header = _("No software updates are available.")
|
||||||
desc = _('important_list is Empty')
|
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))
|
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()
|
# fu = filter.UpdateListFilterCache()
|
||||||
# allowed_origin_upgrade_pkgs = fu.check_in_allowed_origin(pkgs_upgrade)
|
# 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]))
|
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]})
|
self.local_upgrade_list.update({"pkgs_remove":[pkg.name for pkg in pkgs_remove]})
|
||||||
return True,header,desc
|
return True,header,desc
|
||||||
|
|
|
@ -244,19 +244,19 @@ class UpdateManager():
|
||||||
# check if there is another g-a-i already and if not setup one
|
# check if there is another g-a-i already and if not setup one
|
||||||
# listening on dbus
|
# listening on dbus
|
||||||
try:
|
try:
|
||||||
bus = dbus.SessionBus()
|
# bus = dbus.SessionBus()
|
||||||
# bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.error("warning: could not initiate dbus")
|
logging.error("warning: could not initiate dbus")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
proxy_obj = bus.get_object('org.freedesktop.UpdateManager',
|
proxy_obj = bus.get_object('com.kylin.systemupgrade',
|
||||||
'/org/freedesktop/UpdateManagerObject')
|
'/com/kylin/systemupgrade')
|
||||||
|
|
||||||
logging.warning("kylin-update-manager have started...")
|
logging.warning("kylin-update-manager have started...")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except dbus.DBusException:
|
except dbus.DBusException:
|
||||||
bus_name = dbus.service.BusName('org.freedesktop.UpdateManager',
|
bus_name = dbus.service.BusName('com.kylin.systemupgrade',
|
||||||
bus)
|
bus)
|
||||||
logging.info('initiate dbus success ...')
|
logging.info('initiate dbus success ...')
|
||||||
return UpdateManagerDbusController(self, bus_name)
|
return UpdateManagerDbusController(self, bus_name)
|
||||||
|
|
|
@ -11,10 +11,10 @@ from .Core.roam import NetworkManagerHelper
|
||||||
class UpdateManagerDbusController(dbus.service.Object):
|
class UpdateManagerDbusController(dbus.service.Object):
|
||||||
""" this is a helper to provide the UpdateManagerIFace """
|
""" this is a helper to provide the UpdateManagerIFace """
|
||||||
|
|
||||||
INTERFACE = 'org.freedesktop.UpdateManagerIFace'
|
INTERFACE = 'com.kylin.systemupgrade.interface'
|
||||||
|
|
||||||
def __init__(self, parent, bus_name,
|
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)
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
|
|
@ -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>
|
|
@ -3,14 +3,13 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version("Gtk", "3.0")
|
|
||||||
from gi.repository import Gtk
|
|
||||||
from UpdateManager.UpdateManager import UpdateManager
|
from UpdateManager.UpdateManager import UpdateManager
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
#定义日志的格式
|
#定义日志的格式
|
||||||
FORMAT = '%(asctime)-15s %(levelname)s:%(message)s'
|
FORMAT = '%(asctime)-15s %(levelname)s:%(message)s'
|
||||||
|
@ -35,6 +34,11 @@ if __name__ == "__main__":
|
||||||
logging.basicConfig(format=FORMAT,level=logging.INFO)
|
logging.basicConfig(format=FORMAT,level=logging.INFO)
|
||||||
|
|
||||||
logging.info('kylin-update-manager starting ...')
|
logging.info('kylin-update-manager starting ...')
|
||||||
|
|
||||||
|
bus_loop = DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
app = UpdateManager(options)
|
app = UpdateManager(options)
|
||||||
app.start_update()
|
app.start_update()
|
||||||
Gtk.main()
|
|
||||||
|
loop = GLib.MainLoop()
|
||||||
|
loop.run()
|
Loading…
Reference in New Issue