添加单包安装的功能
This commit is contained in:
parent
2689ba47d9
commit
e6fa1d327d
|
@ -20,15 +20,15 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
UPDATER_DBUS_INTERFACE = 'com.kylin.systemupgrade.interface'
|
||||
|
||||
def __init__(self, parent, bus_name,
|
||||
object_path='/com/kylin/systemupgrade'):
|
||||
object_path=UPDATER_DBUS_PATH):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
self.parent = parent
|
||||
|
||||
#网络检测 电池检测等等的启动检查
|
||||
self.alert_watcher = AlertWatcher()
|
||||
self.alert_watcher.check_alert_state()
|
||||
self.alert_watcher.connect("network-alert", self._on_network_alert)
|
||||
self.connected = False
|
||||
# self.alert_watcher = AlertWatcher()
|
||||
# self.alert_watcher.check_alert_state()
|
||||
# self.alert_watcher.connect("network-alert", self._on_network_alert)
|
||||
# self.connected = False
|
||||
self.transaction = None
|
||||
|
||||
#更新important.list的本次升级的列表
|
||||
|
|
|
@ -79,6 +79,25 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
error_string=None, error_desc=None)
|
||||
raise
|
||||
|
||||
@inline_callbacks
|
||||
def install_deb(self,install_path,install_force):
|
||||
"""安装deb包 """
|
||||
try:
|
||||
trans = yield self.client.install_file(path = install_path,force = install_force,defer=True)
|
||||
self.window_main.dbusController.transaction = trans
|
||||
# 注册回调函数 接收更新的状态
|
||||
yield self._show_transaction(trans, self.ACTION_INSTALL_DEB,
|
||||
_("Installing deb packages…"), False)
|
||||
except errors.NotAuthorizedError:
|
||||
self._action_done(self.ACTION_INSTALL_DEB,
|
||||
authorized=False, success=False,
|
||||
error_string=None, error_desc=None)
|
||||
except Exception:
|
||||
self._action_done(self.ACTION_INSTALL_DEB,
|
||||
authorized=True, success=False,
|
||||
error_string=None, error_desc=None)
|
||||
raise
|
||||
|
||||
#进度回调
|
||||
def _on_progress_changed(self, trans,progress,action):
|
||||
if progress == 101:
|
||||
|
|
|
@ -15,6 +15,8 @@ import apt_pkg
|
|||
class InstallBackend():
|
||||
ACTION_UPDATE = 0
|
||||
ACTION_INSTALL = 1
|
||||
ACTION_INSTALL_DEB = 1
|
||||
|
||||
|
||||
def __init__(self, window_main, action):
|
||||
self.window_main = window_main
|
||||
|
@ -119,19 +121,20 @@ class InstallBackend():
|
|||
#FIXME: 在下载升级的能抑制系统关闭或者睡眠 参考ubuntu此部分代码
|
||||
|
||||
if self.action == self.ACTION_INSTALL:
|
||||
_success,pkgs_install,pkgs_upgrade,pkgs_remove,header,desc = self._make_problem_resolver(partial_upgrade_list)
|
||||
# _success,pkgs_install,pkgs_upgrade,pkgs_remove,header,desc = self._make_problem_resolver(partial_upgrade_list)
|
||||
|
||||
is_remove_pkgs = len(pkgs_remove) != 0
|
||||
# is_remove_pkgs = len(pkgs_remove) != 0
|
||||
|
||||
#属于检测查询依赖解决是否成功 是否存在删包
|
||||
if force_install == False or _success == False:
|
||||
self.window_main.is_upgrading = False
|
||||
self.window_main.dbusController.UpdateDependResloveStatus(_success,is_remove_pkgs,pkgs_remove,header,desc)
|
||||
return
|
||||
# #属于检测查询依赖解决是否成功 是否存在删包
|
||||
# if force_install == False or _success == False:
|
||||
# self.window_main.is_upgrading = False
|
||||
# self.window_main.dbusController.UpdateDependResloveStatus(_success,is_remove_pkgs,pkgs_remove,header,desc)
|
||||
# return
|
||||
|
||||
try:
|
||||
logging.info("commit install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
|
||||
self.commit(pkgs_install, pkgs_upgrade, pkgs_remove)
|
||||
self.install_deb('/home/x/share/deb/*.deb',True)
|
||||
# logging.info("commit install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
|
||||
# self.commit(pkgs_install, pkgs_upgrade, pkgs_remove)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
|
@ -155,6 +158,10 @@ class InstallBackend():
|
|||
"""Commit the cache changes """
|
||||
raise NotImplementedError
|
||||
|
||||
def install_deb(self,install_path,install_force):
|
||||
"""install_deb the cache changes """
|
||||
raise NotImplementedError
|
||||
|
||||
#出现错误和更新升级完成都会调到此方法 进行处理
|
||||
def _action_done(self, action, authorized, success, error_string,
|
||||
error_desc, trans_failed=False):
|
||||
|
@ -177,7 +184,7 @@ class InstallBackend():
|
|||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade_list,error_string,error_desc)
|
||||
else:
|
||||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade_list,'','')
|
||||
else:
|
||||
elif action == self.ACTION_UPDATE:
|
||||
self.window_main.is_updating = False
|
||||
if success:
|
||||
self.window_main.start_available()
|
||||
|
@ -186,6 +193,16 @@ class InstallBackend():
|
|||
self.window_main.dbusController.UpdateDetectFinished(success,[],error_string,error_desc)
|
||||
else:
|
||||
self.window_main.dbusController.UpdateDetectFinished(success,[],'','')
|
||||
elif action == self.ACTION_INSTALL_DEB:
|
||||
if success:
|
||||
#当组列表为空时 表示现在的单独进行安装某些包或卸载,不发信号到控制面板
|
||||
self.window_main.start_available()
|
||||
elif error_string or error_desc:
|
||||
logging.warning(error_string + error_desc)
|
||||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade_list,error_string,error_desc)
|
||||
else:
|
||||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade_list,'','')
|
||||
|
||||
|
||||
|
||||
# try aptdaemon
|
||||
|
|
Loading…
Reference in New Issue