修复代码逻辑 调整
This commit is contained in:
parent
25b4d1d7a6
commit
6ce5c7d410
|
@ -114,10 +114,10 @@ class UpdateManager():
|
|||
|
||||
#进行升级的操作
|
||||
def start_install(self,partial_upgrade_list = []):
|
||||
#FIXME: 此功能未完善
|
||||
#检查磁盘的状态
|
||||
# if self.check_free_space(self.cache) == False:
|
||||
# return
|
||||
if self.check_free_space(self.cache) == False:
|
||||
return
|
||||
logging.info("Disk Check finished...")
|
||||
try:
|
||||
self.is_upgrading = True
|
||||
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
|
||||
|
@ -125,14 +125,12 @@ class UpdateManager():
|
|||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
|
||||
#进行升级的操作-传入包列表
|
||||
def start_install_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = [],pkgs_purge = []):
|
||||
#FIXME: 此功能未完善
|
||||
#检查磁盘的状态
|
||||
# if self.check_free_space(self.cache) == False:
|
||||
# return
|
||||
|
||||
if self.check_free_space(self.cache) == False:
|
||||
return
|
||||
logging.info("Disk Check finished...")
|
||||
self.is_upgrading = True
|
||||
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
|
||||
install_backend.start_alone(pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_purge)
|
||||
|
@ -246,7 +244,7 @@ class UpdateManager():
|
|||
|
||||
#发送更新升级列表完成的标志
|
||||
self.dbusController.update_finished_signal(_success,self.update_list.output_upgrade_list.get('upgrade_groups_list',[]),header,desc)
|
||||
|
||||
|
||||
def _setup_dbus(self):
|
||||
""" this sets up a dbus listener if none is installed already """
|
||||
# check if there is another g-a-i already and if not setup one
|
||||
|
|
|
@ -6,7 +6,6 @@ import threading
|
|||
|
||||
from .Core.AlertWatcher import AlertWatcher
|
||||
from .Core.roam import NetworkManagerHelper
|
||||
from .Core.utils import humanize_size
|
||||
|
||||
#dbus 建立
|
||||
class UpdateManagerDbusController(dbus.service.Object):
|
||||
|
@ -126,13 +125,18 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
def update_finished_signal(self, success, upgrade_group,error_string='',error_desc='',):
|
||||
logging.info("emit success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
|
||||
success,upgrade_group, error_string,error_desc)
|
||||
pass
|
||||
|
||||
#升级的进度信息 0~100 进度信息 101为非预期的信号
|
||||
@dbus.service.signal(INTERFACE,signature='asis')
|
||||
def upgrade_progress_signal(self,groups_list,progress,status):
|
||||
logging.info("emit groups_list = %s progress = %d , status = %s",groups_list,progress,status)
|
||||
|
||||
#升级完成的信号
|
||||
@dbus.service.signal(INTERFACE,signature='basss')
|
||||
def upgrade_finished_signal(self, success, upgrade_group,error_string='',error_desc='',):
|
||||
logging.info("emit success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
|
||||
success,upgrade_group, error_string,error_desc)
|
||||
|
||||
#发送下载包信息
|
||||
@dbus.service.signal(INTERFACE, signature='iiiiii')
|
||||
def on_download_changed_signal(self, current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
|
||||
|
@ -140,11 +144,9 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
current_items, total_items, \
|
||||
currenty_bytes, total_bytes,\
|
||||
current_cps, eta)
|
||||
pass
|
||||
|
||||
# 信号是否可取消
|
||||
@dbus.service.signal(INTERFACE, signature='b')
|
||||
def cancelable(self, cancelable):
|
||||
logging.info("cancelable: %r",\
|
||||
logging.info("emit cancelable: %r",\
|
||||
cancelable)
|
||||
pass
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
|
||||
# (c) 2005-2012 Canonical, GPL
|
||||
# (C) 2008-2009 Sebastian Heinlein <devel@glatzor.de>
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
@ -59,8 +56,7 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
pkgs_install, reinstall, pkgs_remove, purge = pkgs_purge, upgrade = pkgs_upgrade,
|
||||
downgrade = downgrade, defer=True)
|
||||
self.window_main.dbusController.transaction = trans
|
||||
#安装的进度信息
|
||||
# trans.connect("progress-changed", self._on_progress_changed)
|
||||
|
||||
yield self._show_transaction(trans, self.ACTION_INSTALL,
|
||||
_("Installing updates…"), True)
|
||||
except errors.NotAuthorizedError:
|
||||
|
@ -123,7 +119,7 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
trans.connect("status-changed", self._on_status_changed,action)
|
||||
trans.connect("progress-changed", self._on_progress_changed,action)
|
||||
|
||||
#取消标志位
|
||||
#取消
|
||||
trans.connect("cancellable-changed", self._on_cancellable_changed)
|
||||
|
||||
#下载的进度信息
|
||||
|
|
|
@ -19,7 +19,7 @@ class InstallBackend():
|
|||
def __init__(self, window_main, action):
|
||||
self.window_main = window_main
|
||||
self.action = action
|
||||
self.upgrade_groups_list = ['llllll']
|
||||
self.upgrade_groups_list = []
|
||||
|
||||
def start(self,partial_upgrade_list = []):
|
||||
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
|
||||
|
@ -46,16 +46,15 @@ class InstallBackend():
|
|||
pkgs_install += self.window_main.update_list.output_upgrade_list.get(group_name,[]).get('pkgs_install',[])
|
||||
pkgs_upgrade += self.window_main.update_list.output_upgrade_list.get(group_name,[]).get('pkgs_upgrade',[])
|
||||
|
||||
pkgs_remove.append(self.window_main.update_list.output_upgrade_list.get("pkgs_remove",[]))
|
||||
pkgs_remove = self.window_main.update_list.output_upgrade_list.get("pkgs_remove",[])
|
||||
else:
|
||||
logging.info("no upgradeable packages")
|
||||
return
|
||||
|
||||
|
||||
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,pkgs_purge)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
pass
|
||||
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,pkgs_purge)
|
||||
else:
|
||||
self.update()
|
||||
|
||||
|
@ -84,11 +83,12 @@ class InstallBackend():
|
|||
if action == self.ACTION_INSTALL:
|
||||
self.window_main.is_upgrading = False
|
||||
if success:
|
||||
self.window_main.start_available()
|
||||
elif error_string:
|
||||
self.window_main.dbusController.upgrade_finished_signal(success,self.upgrade_groups_list)
|
||||
elif error_string or error_desc:
|
||||
logging.warning(error_string + error_desc)
|
||||
self.window_main.dbusController.upgrade_finished_signal(success,self.upgrade_groups_list,error_string,error_desc)
|
||||
else:
|
||||
pass
|
||||
self.window_main.dbusController.upgrade_finished_signal(success,self.upgrade_groups_list)
|
||||
else:
|
||||
self.window_main.is_updating = False
|
||||
if success:
|
||||
|
|
|
@ -36,6 +36,5 @@ if __name__ == "__main__":
|
|||
|
||||
logging.info('kylin-update-manager starting ...')
|
||||
app = UpdateManager(options)
|
||||
|
||||
app.start_update()
|
||||
Gtk.main()
|
Loading…
Reference in New Issue