增加模拟计算方式
This commit is contained in:
parent
3b42b53817
commit
f752ae8ba0
|
@ -1,9 +1,6 @@
|
|||
# UpdateManager.py
|
||||
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
|
||||
import os
|
||||
import subprocess
|
||||
from unicodedata import lookup
|
||||
from apt import Cache
|
||||
import apt_pkg
|
||||
import sys
|
||||
import time
|
||||
|
@ -12,10 +9,16 @@ import dbus
|
|||
import logging
|
||||
import dbus.service
|
||||
import json
|
||||
import threading
|
||||
import subprocess
|
||||
from apt import Cache
|
||||
from gettext import gettext as _
|
||||
from apt.debfile import DebPackage
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
from .Core.errors import *
|
||||
from .Core.enums import *
|
||||
from .Core.MyCache import MyCache
|
||||
from .UpdateManagerDbus import UpdateManagerDbusController,UPDATER_DBUS_INTERFACE,UPDATER_DBUS_PATH,UPDATER_DBUS_SERVICE
|
||||
from .Core.UpdateList import UpdateList
|
||||
|
@ -24,14 +27,12 @@ from .Core.Database import Sqlite3Server
|
|||
from .Core.loop import mainloop
|
||||
from .Core.DataAcquisition import UpdateMsgCollector
|
||||
|
||||
from gettext import gettext as _
|
||||
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
|
||||
from SystemUpdater.Core.utils import get_broken_details,kill_process
|
||||
from SystemUpdater.Core.DpkgInstallProgress import LogInstallProgress
|
||||
from SystemUpdater.Core.utils import deb_verify,PolicyKit_Authority,get_proc_from_dbus_name
|
||||
|
||||
from .Core.errors import *
|
||||
from .Core.enums import *
|
||||
|
||||
|
||||
class UpdateManager():
|
||||
BACKEND_PKG_NAME = 'kylin-system-updater'
|
||||
|
@ -888,6 +889,40 @@ class InhibitShutdownLock():
|
|||
except Exception as e:
|
||||
logging.error("unlock failed." + str(e))
|
||||
|
||||
class SimulateUpdateInstall():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def emulate_install(self,pkgs):
|
||||
args = ["apt-get", "install","--simulate"]
|
||||
args = args + pkgs
|
||||
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.info(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def emulate_update(self):
|
||||
args = ["apt-get", "update"]
|
||||
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.info(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def thread_install(self):
|
||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||
threading_emulate.start()
|
||||
|
||||
def thread_update(self):
|
||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||
threading_emulate.start()
|
||||
|
||||
def emulate_install_broken(self,pkgs):
|
||||
self.emulate_install(pkgs)
|
||||
|
||||
|
||||
pass
|
||||
|
||||
class UpdateInstallMode():
|
||||
def __init__(self,parent):
|
||||
self.parent = parent
|
||||
|
|
|
@ -250,28 +250,8 @@ class InstallBackend():
|
|||
self.fix_incomplete()
|
||||
#卸载包
|
||||
elif self.action == self.ACTION_REMOVE_PACKAGES:
|
||||
# remove_pkgs = []
|
||||
# for pkg in partial_upgrade_list:
|
||||
# if pkg in self.cache:
|
||||
# pkg_cache = self.cache[pkg]
|
||||
# pkg_cache.mark_delete(True, True)
|
||||
# else:
|
||||
# #没有在cache中就认为不需要升级
|
||||
# logging.error("Check: (%s) The reomve package is not in Cache...",pkg)
|
||||
|
||||
# for pkg_obj in self.cache.get_changes():
|
||||
# if pkg_obj.marked_delete:
|
||||
# remove_pkgs.append(pkg_obj.name)
|
||||
|
||||
# success,header,desc = self.check_essential_pkgs(remove_pkgs)
|
||||
# if success == False:
|
||||
# self._action_done(self.action,False,False,header,desc)
|
||||
# return
|
||||
# else:
|
||||
self._start_install_lock()
|
||||
self.purge_packages(partial_upgrade_list)
|
||||
|
||||
#清空所有下载的文件
|
||||
elif self.action == self.ACTION_CLEAN:
|
||||
self.clean()
|
||||
#更新cache
|
||||
|
@ -481,13 +461,10 @@ class InstallBackend():
|
|||
for pkg in pkgs_install + pkgs_upgrade:
|
||||
pkg_string = pkg_string + ' ' + str(pkg)
|
||||
logging.info('Resolver calculation Packages List: '+pkg_string+'\n')
|
||||
# logging.error('\n' + msg)
|
||||
terminal_msg = self.emulate_calcul_broken(pkgs_install + pkgs_upgrade)
|
||||
logging.error(terminal_msg)
|
||||
raise UpdateBaseError(ERROR_RESOLVER_FAILED,
|
||||
desc= terminal_msg)
|
||||
# threading_emulate = threading.Thread(target=emulate_calcul_broken,args=(pkgs_install + pkgs_upgrade,))
|
||||
# threading_emulate.start()
|
||||
|
||||
def _emulate_calcul_delete(self,pkg,cache):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue