取消功能,增加返回值
This commit is contained in:
parent
6cca6df1bb
commit
b71abbb124
|
@ -36,7 +36,7 @@ class UpdateManager():
|
|||
self.cache = None
|
||||
self.update_list = None
|
||||
|
||||
#表示aptdeamon是否处于工作状态
|
||||
#表示后端的状态 注意:这个状态很重要 用不好整个后端代码就会卡住
|
||||
self.is_working = InstallBackend.ACTION_DEFUALT_STATUS
|
||||
|
||||
#建立dbus
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import dbus
|
||||
import dbus.service
|
||||
import logging
|
||||
|
||||
import time
|
||||
from gettext import gettext as _
|
||||
from .backend import InstallBackend
|
||||
from .Core.loop import mainloop
|
||||
|
@ -262,21 +262,32 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
return False,str(e)
|
||||
|
||||
# 取消transaction
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='bs')
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='b')
|
||||
def CancelDownload(self):
|
||||
status = False
|
||||
message = ""
|
||||
try:
|
||||
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' CancelDownload...')
|
||||
|
||||
#空时直接返回
|
||||
if self.transaction == None:
|
||||
logging.info("transaction is none")
|
||||
return False
|
||||
|
||||
if self.transaction.cancellable == True:
|
||||
self.transaction.cancel()
|
||||
|
||||
status = True
|
||||
message = "Success"
|
||||
logging.info("dbus-mothod cancel task Success")
|
||||
elif self.transaction == None or self.transaction.cancellable == False:
|
||||
message = "Can not Cancel"
|
||||
else:
|
||||
status = False
|
||||
logging.info("cancel task Failed")
|
||||
|
||||
except Exception as e:
|
||||
return (status,str(e))
|
||||
return (status, message)
|
||||
logging.info("cancel task Failed")
|
||||
logging.error(str(e))
|
||||
status = False
|
||||
return status
|
||||
return status
|
||||
|
||||
# 依赖错误时调用的接口
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='b',out_signature='bs')
|
||||
|
|
|
@ -368,6 +368,7 @@ class InstallBackend():
|
|||
|
||||
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
|
||||
def _action_done(self, action, authorized, success, error_string,error_desc):
|
||||
#后端的状态 到空闲状态
|
||||
self.window_main.is_working = self.ACTION_DEFUALT_STATUS
|
||||
|
||||
#升级完成后走的分支
|
||||
|
@ -377,7 +378,8 @@ class InstallBackend():
|
|||
|
||||
upgrade_content = self.now_upgrade.upgrade_groups + self.now_upgrade.single_pkgs
|
||||
# unLockedEnableShutdown()
|
||||
|
||||
|
||||
#升级后的结果插入到数据库中
|
||||
self._make_insert_info(success,self.now_upgrade.upgrade_mode,error_string,error_desc)
|
||||
|
||||
if success:
|
||||
|
|
Loading…
Reference in New Issue