改名字

This commit is contained in:
Luoxueyi 2022-09-14 15:46:46 +08:00
parent a2ebe87865
commit 8546174f89
4 changed files with 44 additions and 41 deletions

View File

@ -40,3 +40,30 @@ def get_logfile():
return os.path.join(path, "kylin-system-updater.log.1")
except:
return os.path.join(path, "kylin-system-updater.log.1")
def upgrade_strategies_logfile():
if not os.path.exists(path):
os.makedirs(path)
#优先获取当前未写满100M的日志编号文件
for i in os.listdir(path):
if "upgrade-strategies-daemon.log." in os.path.basename(path + i):
numlist.append((path + i).split(".")[2])
if get_FileSize(path + i) < 10:
return path + i
#获取1-5未使用的最小数字的标号作为日志文件
for i in range(1, 6):
if str(i) not in numlist:
return(os.path.join(path, ("upgrade-strategies-daemon.log.%s") % i))
try:
#编号1-5日志文件均写满时删除第一个往前移动日志编号获取最后一个编号作为日志文件
if len(numlist) != 0:
os.remove(os.path.join(path, "upgrade-strategies-daemon.log.1"))
for i in range(2, 6):
os.rename(os.path.join(path, ("upgrade-strategies-daemon.log.%s") % i),
os.path.join(path, ("upgrade-strategies-daemon.log.%s") % (i - 1)))
return os.path.join(path, "upgrade-strategies-daemon.log.5")
#默认情况下未生成任何日志时使用编号1的日志文件
else:
return os.path.join(path, "upgrade-strategies-daemon.log.1")
except:
return os.path.join(path, "upgrade-strategies-daemon.log.1")

View File

@ -51,11 +51,11 @@ class UpgradeStrategies():
self.retry_limit = self.RETRY_LIMIT_NUM
#dbus
self.dbusController = self._setup_dbus()
# #config
# self.configs_uncover = UpgradeConfig(defaults_dir="system-updater-defaults.conf")
# self.configs_cover = UpgradeConfig(name = "system-updater-coverable.conf")
# self.uuconfigs = UpgradeConfig(datadir = "/var/lib/unattended-upgrades/", name = "unattended-upgrades-policy.conf")
# #数据采集器
#config
self.configs_uncover = UpgradeConfig(defaults_dir="system-updater-defaults.conf")
self.configs_cover = UpgradeConfig(name = "system-updater-coverable.conf")
self.uuconfigs = UpgradeConfig(datadir = "/var/lib/unattended-upgrades/", name = "unattended-upgrades-policy.conf")
#数据采集器
# self.collector = UpdateMsgCollector(self)
except Exception as e:

View File

@ -11,7 +11,7 @@ import os
import sys
import gettext
from SystemUpdater.Core.LogManager import get_logfile as logfile
from SystemUpdater.Core.LogManager import upgrade_strategies_logfile as logfile
gettext.bindtextdomain('kylin-system-updater', '/usr/share/locale')
gettext.textdomain('kylin-system-updater')
@ -70,7 +70,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGINT,signal_handler_term)
if options.debug:
logging.basicConfig(format=FORMAT,level=logging.INFO,datefmt='%m-%d,%H:%M:%S')
logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S',filename = logfile(),filemode = 'a')
else:
logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S',filename = logfile(),filemode = 'a')

View File

@ -1,53 +1,29 @@
#!/usr/bin/env python3
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
import os
import glob
from distutils.core import setup
from subprocess import check_output
from DistUtilsExtra.command import (
build_extra, build_i18n, build_help)
disabled = []
def plugins():
return []
return [os.path.join('janitor/plugincore/plugins', name)
for name in os.listdir('janitor/plugincore/plugins')
if name.endswith('_plugin.py') and name not in disabled]
#for line in check_output('dpkg-parsechangelog --format rfc822'.split(),
# universal_newlines=True).splitlines():
# header, colon, value = line.lower().partition(':')
# if header == 'version':
# version = value.strip()
# break
#else:
# raise RuntimeError('No version found in debian/changelog')
class CustomBuild(build_extra.build_extra):
def run(self):
# with open("SystemUpdater/UpdateManagerVersion.py", "w") as f:
# f.write("VERSION = '%s'\n" % version)
build_extra.build_extra.run(self)
setup(name='kylin-system-updater',
# version=version,
packages=['SystemUpdater',
setup(
name='kylin-system-updater',
packages=['SystemUpdater',
'SystemUpdater.backend',
'SystemUpdater.Core',],
scripts=['kylin-system-updater'],
data_files=[('share/man/man8',
scripts=['kylin-system-updater'],
data_files=[('share/man/man8',
glob.glob('data/*.8')),
],
cmdclass={"build": CustomBuild,
"build_i18n": build_i18n.build_i18n,
"build_help": build_help.build_help}
)
cmdclass={"build": CustomBuild,
"build_i18n": build_i18n.build_i18n
# "build_help": build_help.build_help
}
)