Merge branch 'backend_manual' into 'backend_uu'
Backend manual See merge request kylinos-src/update-manager-group/kylin-system-updater!509
This commit is contained in:
commit
183a462157
|
@ -3,11 +3,10 @@ import os
|
|||
import dbus
|
||||
import dbus.service
|
||||
import logging
|
||||
import subprocess
|
||||
from gettext import gettext as _
|
||||
from .Core.loop import mainloop
|
||||
from SystemUpdater.Core.utils import get_proc_from_dbus_name
|
||||
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
|
||||
from .Core.MyCache import MyCache
|
||||
|
||||
UPDATER_DBUS_INTERFACE = 'com.kylin.UpgradeStrategies.interface'
|
||||
UPDATER_DBUS_PATH = '/com/kylin/UpgradeStrategies'
|
||||
|
@ -46,6 +45,8 @@ UU_UPGRADE_MODE_BEFORE_SHUTDOWN = 3
|
|||
class UpgradeStrategiesDbusController(dbus.service.Object):
|
||||
""" this is a helper to provide the UpdateManagerIFace """
|
||||
|
||||
P2P_DEDAULT_PATH = "/etc/default/apt-p2p"
|
||||
|
||||
def __init__(self, parent, bus_name,
|
||||
object_path=UPDATER_DBUS_PATH):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
|
@ -72,6 +73,35 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
|
|||
mainloop.quit()
|
||||
logging.debug("Exit")
|
||||
|
||||
## dbus接口: 开启或关闭预下载功能
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='b',sender_keyword='sender')
|
||||
def ChangingP2PStatus(self,_status,sender = None):
|
||||
status = str(_status)
|
||||
sender_name = get_proc_from_dbus_name(sender)
|
||||
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' ChangingP2PStatus, _status = %s , sender name: %s',status,sender_name)
|
||||
|
||||
if os.path.exists(self.P2P_DEDAULT_PATH):
|
||||
if status == "enable":
|
||||
with open(self.P2P_DEDAULT_PATH, 'w+') as configfile:
|
||||
configfile.write("#enable=true\n")
|
||||
elif status == "disable":
|
||||
with open(self.P2P_DEDAULT_PATH, 'w+') as configfile:
|
||||
configfile.write("enable=false\n")
|
||||
else:
|
||||
logging.waring("error: input value _status=%s",status)
|
||||
|
||||
args = ["systemctl","restart","apt-p2p.service"]
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.info(str(p.stdout))
|
||||
if p.returncode == 0:
|
||||
logging.info("Execute successfully")
|
||||
return True
|
||||
else:
|
||||
logging.info("Failed to execute reboot")
|
||||
return False
|
||||
else:
|
||||
logging.waring("apt-p2p function is not install...")
|
||||
|
||||
## dbus接口: 开启或关闭预下载功能
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='bs', out_signature='b',sender_keyword='sender')
|
||||
def SetPreDownloadState(self, _state, _time, sender = None):
|
||||
|
|
|
@ -568,6 +568,8 @@ class InstallBackend():
|
|||
|
||||
if pkg_cache.marked_keep == True:
|
||||
pkg_cache.mark_install(False, False, True)
|
||||
if pkg_cache.marked_keep == True:
|
||||
raise
|
||||
|
||||
resolver.clear(pkg_cache)
|
||||
resolver.protect(pkg_cache)
|
||||
|
|
Loading…
Reference in New Issue