增加部分下载的dbus接口
This commit is contained in:
parent
311f48bf6a
commit
96cfc85d62
|
@ -222,8 +222,10 @@ class UpdateList():
|
|||
|
||||
self.IMPORTANT_LIST_PATH="/var/lib/kylin-software-properties/template/important.list"
|
||||
|
||||
# important推送列表
|
||||
self.important_list = []
|
||||
|
||||
|
||||
#所有的组升级安装列表
|
||||
self.output_upgrade_list = {}
|
||||
# a stable machine uniq id
|
||||
try:
|
||||
|
|
|
@ -111,15 +111,15 @@ class UpdateManager():
|
|||
update_backend.start()
|
||||
|
||||
#进行升级的操作
|
||||
def start_install(self):
|
||||
def start_install(self,partial_upgrade_list = []):
|
||||
#FIXME: 此功能未完善
|
||||
#检查磁盘的状态
|
||||
# if self.check_free_space(self.cache) == False:
|
||||
# return
|
||||
|
||||
|
||||
self.is_upgrading = True
|
||||
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
|
||||
install_backend.start()
|
||||
install_backend.start(partial_upgrade_list)
|
||||
|
||||
#进行升级的操作-传入包列表
|
||||
def start_install_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = [],pkgs_purge = []):
|
||||
|
|
|
@ -88,7 +88,21 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
#部分升级
|
||||
@dbus.service.method(INTERFACE,in_signature='as',out_signature='b')
|
||||
def partial_upgrade(self,upgrade_list):
|
||||
pass
|
||||
try:
|
||||
#处于更新和升级中的话 不进行升级
|
||||
if self.parent.is_updating or self.parent.is_upgrading:
|
||||
logging.info('In the process of updating or Upgrading...')
|
||||
return False,'In the process of updating or Upgrading...'
|
||||
else:
|
||||
#不为空时
|
||||
if upgrade_list:
|
||||
self.parent.start_install(upgrade_list)
|
||||
logging.info('dbus upgrading ...')
|
||||
return True,'dbus upgrading ...'
|
||||
else:
|
||||
return False,'upgrade_list is empty'
|
||||
except Exception as e:
|
||||
return False,e
|
||||
|
||||
#更新和升级的进度信息 0~100 进度信息 101为非预期的信号
|
||||
@dbus.service.signal(INTERFACE,signature='is')
|
||||
|
|
|
@ -5,15 +5,8 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from aptdaemon import client, errors
|
||||
from defer import inline_callbacks
|
||||
from aptdaemon.gtk3widgets import (
|
||||
AptConfigFileConflictDialog,
|
||||
AptMediumRequiredDialog,
|
||||
AptProgressBar
|
||||
)
|
||||
from aptdaemon.enums import (EXIT_SUCCESS,
|
||||
EXIT_FAILED,
|
||||
get_error_description_from_enum,
|
||||
|
@ -102,6 +95,9 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
def _on_download_changed(self, trans, details):
|
||||
logging.info(details)
|
||||
|
||||
def _on_progress_download_changed(self,trans,current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
|
||||
print(current_items, total_items, currenty_bytes, total_bytes, current_cps, eta)
|
||||
|
||||
@inline_callbacks
|
||||
def _show_transaction(self, trans, action, header, show_details):
|
||||
|
||||
|
@ -116,75 +112,16 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
trans.connect("status-changed", self._on_status_changed)
|
||||
trans.connect("progress-changed", self._on_progress_changed)
|
||||
|
||||
trans.connect("progress-details-changed", self._on_progress_download_changed)
|
||||
|
||||
# trans.connect("download-changed", self._on_download_changed)
|
||||
|
||||
trans.connect("config-file-conflict", self._on_config_file_conflict)
|
||||
# trans.connect("config-file-conflict", self._on_config_file_conflict)
|
||||
|
||||
# yield trans.set_debconf_frontend("kylin")
|
||||
# yield trans.set_debconf_frontend("ukui")
|
||||
trans.set_locale('en@UTF-8')
|
||||
yield trans.run()
|
||||
|
||||
def _on_expanded(self, expander, param):
|
||||
# Make the dialog resizable if the expander is expanded
|
||||
# try to restore a previous size
|
||||
if not expander.get_expanded():
|
||||
self._expanded_size = (expander.terminal.get_visible(),
|
||||
self.window_main.get_size())
|
||||
self.window_main.end_user_resizable()
|
||||
elif self._expanded_size:
|
||||
term_visible, (stored_width, stored_height) = self._expanded_size
|
||||
# Check if the stored size was for the download details or
|
||||
# the terminal widget
|
||||
if term_visible != expander.terminal.get_visible():
|
||||
# The stored size was for the download details, so we need
|
||||
# get a new size for the terminal widget
|
||||
self._resize_to_show_details(expander)
|
||||
else:
|
||||
self.window_main.begin_user_resizable(stored_width,
|
||||
stored_height)
|
||||
else:
|
||||
self._resize_to_show_details(expander)
|
||||
|
||||
def _resize_to_show_details(self, expander):
|
||||
"""Resize the window to show the expanded details.
|
||||
|
||||
Unfortunately the expander only expands to the preferred size of the
|
||||
child widget (e.g showing all 80x24 chars of the Vte terminal) if
|
||||
the window is rendered the first time and the terminal is also visible.
|
||||
If the expander is expanded afterwards the window won't change its
|
||||
size anymore. So we have to do this manually. See LP#840942
|
||||
"""
|
||||
if expander.get_expanded():
|
||||
win_width, win_height = self.window_main.get_size()
|
||||
exp_width = expander.get_allocation().width
|
||||
exp_height = expander.get_allocation().height
|
||||
if expander.terminal.get_visible():
|
||||
terminal_width = expander.terminal.get_char_width() * 80
|
||||
terminal_height = expander.terminal.get_char_height() * 24
|
||||
new_width = terminal_width - exp_width + win_width
|
||||
new_height = terminal_height - exp_height + win_height
|
||||
else:
|
||||
new_width = win_width + 100
|
||||
new_height = win_height + 200
|
||||
self.window_main.begin_user_resizable(new_width, new_height)
|
||||
|
||||
def _on_medium_required(self, transaction, medium, drive):
|
||||
dialog = AptMediumRequiredDialog(medium, drive, self.window_main)
|
||||
res = dialog.run()
|
||||
dialog.hide()
|
||||
if res == Gtk.ResponseType.OK:
|
||||
transaction.provide_medium(medium)
|
||||
else:
|
||||
transaction.cancel()
|
||||
|
||||
def _on_config_file_conflict(self, transaction, old, new):
|
||||
dialog = AptConfigFileConflictDialog(old, new, self.window_main)
|
||||
res = dialog.run()
|
||||
dialog.hide()
|
||||
if res == Gtk.ResponseType.YES:
|
||||
transaction.resolve_config_file_conflict(old, "replace")
|
||||
else:
|
||||
transaction.resolve_config_file_conflict(old, "keep")
|
||||
|
||||
def _on_finished(self, trans, status, action):
|
||||
error_string = ''
|
||||
error_desc = ''
|
||||
|
@ -210,16 +147,3 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
self._action_done(action,
|
||||
authorized=True, success=is_success,
|
||||
error_string=error_string, error_desc=error_desc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# import mock
|
||||
# options = mock.Mock()
|
||||
# data_dir = "/usr/share/update-manager"
|
||||
|
||||
# from UpdateManager.UpdateManager import UpdateManager
|
||||
# app = UpdateManager(data_dir, options)
|
||||
|
||||
# b = InstallBackendAptdaemon(app, None)
|
||||
# b.commit(["2vcard"], [], [])
|
||||
Gtk.main()
|
||||
|
|
|
@ -20,7 +20,7 @@ class InstallBackend():
|
|||
self.window_main = window_main
|
||||
self.action = action
|
||||
|
||||
def start(self):
|
||||
def start(self,partial_upgrade_list = []):
|
||||
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
|
||||
|
||||
#FIXME: 在下载升级的能抑制系统关闭或者睡眠 参考ubuntu此部分代码
|
||||
|
@ -34,6 +34,11 @@ class InstallBackend():
|
|||
|
||||
try:
|
||||
upgrade_groups_list = self.window_main.update_list.output_upgrade_list.get('upgrade_groups_list',[])
|
||||
|
||||
#当partial_upgrade_list 不为空时为可选升级方式
|
||||
if partial_upgrade_list:
|
||||
upgrade_groups_list = list(set(partial_upgrade_list) & set(upgrade_groups_list))
|
||||
#遍历升级组列表
|
||||
if upgrade_groups_list:
|
||||
for group_name in upgrade_groups_list:
|
||||
pkgs_install += self.window_main.update_list.output_upgrade_list.get(group_name,[]).get('pkgs_install',[])
|
||||
|
@ -42,12 +47,13 @@ class InstallBackend():
|
|||
pkgs_remove.append(self.window_main.update_list.output_upgrade_list.get("pkgs_remove",[]))
|
||||
else:
|
||||
logging.info("no upgradeable packages")
|
||||
return
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
# self.commit(pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge)
|
||||
self.commit(pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge)
|
||||
else:
|
||||
self.update()
|
||||
self.update()
|
||||
|
||||
def start_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = [],pkgs_purge = []):
|
||||
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
|
||||
|
|
Loading…
Reference in New Issue