修改method log颜色

增加包的检测
This commit is contained in:
luoxueyi 2021-11-06 14:52:19 +08:00
parent fd860e475f
commit a19cdec584
2 changed files with 21 additions and 10 deletions

View File

@ -96,7 +96,12 @@ class UpdateManager():
# 进行本地deb包安装的操作
def start_deb_install(self, deb_path = "", is_install = False, auto_satisfy = False):
# 包常规检查
absolute_path, debname = os.path.split(deb_path)
if not os.path.exists(deb_path):
return False,"<"+debname+"> does not exist."
elif not debname.endswith(".deb"):
return False,"<"+debname+"> Not a DEB package."
logging.info("About to Install Package: %s.",str(debname))
try:
if not auto_satisfy:

View File

@ -22,19 +22,21 @@ UPDATER_DBUS_SERVICE = 'com.kylin.systemupgrade'
#颜色设置
COLORLOG_SUFFIX = "\033[0m"
# NO_PRE = "\033[0m"
# RED_PRE = "\033[31;1m"
# GREEN_PRE = "\033[32;1m"
# YELLOW_PRE = "\033[33;1m"
# BULE_PRE = "\033[34;1m"
# RED_PRE = "\033[35;1m"
# BACK_BLACK_PER = "\033[40;1m"
# BACK_RED_PER = "\033[41;1m"
# BACK_GREEN_PER = "\033[42;1m"
BACK_YELLOW_PER = "\033[43;1m"
# BACK_BLUE_PER = "\033[44;1m"
# BACK_WHITE_YELLOW_PRE = "\033[1;31;43m"
# GREEN_GREENBACK_PRE = "\033[1;32;42m"
BULE_GREENBACK_PRE = "\033[1;34;42m"
COLORLOG_PREFIX = BACK_YELLOW_PER
COLORLOG_PREFIX = BACK_YELLOW_PER
COLORMETHOR_PREFIX = BULE_GREENBACK_PRE
#dbus 建立
class UpdateManagerDbusController(dbus.service.Object):
@ -117,7 +119,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
self.parent.start_fix_broken()
logging.info('method FixBrokenDepends ...')
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' FixBrokenDepends ...')
return True
except Exception:
return False
@ -132,7 +134,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
self.parent.start_update()
logging.info('method UpdateDetect ...')
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' UpdateDetect ...')
return True
except Exception:
return False
@ -150,7 +152,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info('method DistUpgradeSystem and is_install:%r...',is_install)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeSystem and is_install:%r...',is_install)
self.parent.start_install(MODE_UPGRADE_ALL,is_install)
return True,'success'
except Exception as e:
@ -170,6 +172,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
partial_upgrade_list = [str(i) for i in _partial_upgrade_list]
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradePartial and is_install:%r, partial_upgrade_list:%s. ',is_install,",".join(partial_upgrade_list))
local_upgrade_groups = self.parent.update_list.local_upgrade_data.upgrade_groups
local_single_pkgs = self.parent.update_list.local_upgrade_data.single_pkgs
@ -196,7 +199,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info('method DistPurgePackages and purge list is:%s...',purge_list)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistPurgePackages and purge list is:%s...',purge_list)
self.parent.start_purge_pkgs(purge_list)
return True,'success'
except Exception as e:
@ -229,7 +232,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info('method DistUpgradeSystem and is_install:%r...',is_install)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeSystem and is_install:%r...',is_install)
self.parent.start_install(MODE_UPGRADE_SYSTEM,is_install)
return True,'success'
except Exception as e:
@ -242,7 +245,7 @@ class UpdateManagerDbusController(dbus.service.Object):
try:
is_install = bool(_is_install)
deb_path = str(path)
logging.info('method InstallDebFile and is_install:%r...',is_install)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' InstallDebFile and is_install:%r...',is_install)
(status,_error_str) = self.parent.start_deb_install(deb_path, is_install)
if not status:
return status,_error_str
@ -255,6 +258,7 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', sender_keyword='sender')
def InsertInstallState(self, item, value, sender=None):
try:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' InsertInstallState, options%svalue%s' % (item, value))
self.parent.sqlite3_server.insert_into_display(item, value)
logging.info("Database inserted successfullyoptions%svalue%s" % (item, value))
return True
@ -265,7 +269,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # download certain package and its dependencies
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='asi', out_signature='b')
def DownloadPackages(self, pkgs=[], try_times=1):
logging.info("Download Packages ...")
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DownloadPackages: %s',pkgs)
if try_times > 0:
pass
else:
@ -279,6 +283,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # dbus接口改变apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='sb')
def SetDownloadspeedMax(self, speed, set):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetDownloadspeedMax, speed:%s, set:%r.'%(speed, set))
if set:
with open("/etc/apt/apt.conf.d/80apt-download", "w+") as f:
text = f.write("Acquire::http::Dl-Limit" + " \"" + "%s" % str(speed) + "\";\n")
@ -294,6 +299,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # dbus接口获取apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='bs')
def GetDownloadspeedLimitValue(self):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' GetDownloadspeedLimitValue...')
try:
f = open("/etc/apt/apt.conf.d/80apt-download", "r")
value = f.readline().split()