替换非必须的接口

This commit is contained in:
Luoxueyi 2022-09-15 10:34:50 +08:00
parent 8546174f89
commit 78008b67f7
6 changed files with 343 additions and 95 deletions

View File

@ -116,7 +116,9 @@ class Sqlite3Server(object):
self.connect.commit()
except Exception as e:
logging.error("Insert error: %s.", str(e))
return False
logging.info("Database: Insert (%s=%s) To display Complete ...", args[0], args[1])
return True
# 写入数据到tid_search表中
def insert_into_tid(self, *args, **kwargs):
@ -148,8 +150,8 @@ class Sqlite3Server(object):
self.connect.commit()
return str(self.cursor.fetchone()[0])
except Exception as e:
logging.error("Insert error: %s.", str(e))
logging.info(_("Database: Insert To Complete..."))
logging.error("select error: %s.", str(e))
return "Error"
# 写入updateinfos表中
def insert_into_updateinfo(self, *args, **kwargs):

View File

@ -1258,4 +1258,4 @@ class UpdateManagerDbusControllerUtils(dbus.service.Object):
self.parent.configs_uncover.getWithDefault("SystemStatus", "upload_installer_log", False))
}
else:
return {}
return {}

View File

@ -57,6 +57,13 @@ class UpgradeStrategies():
self.uuconfigs = UpgradeConfig(datadir = "/var/lib/unattended-upgrades/", name = "unattended-upgrades-policy.conf")
#数据采集器
# self.collector = UpdateMsgCollector(self)
#连接数据库
self.sqlite3_server = Sqlite3Server(self)
# self.simulate_mode = SimulateTerminal()
# self.install_mode = UpdateInstallMode(self)
self.apt_p2p_config = AptP2pConfigManager()
# self._reload_options_config()
# self._refresh_cache_only()
except Exception as e:
logging.error(e)
@ -112,3 +119,22 @@ class UpgradeStrategies():
logging.error("Dbus has not withdrawn and retry reboot times:%d...",retry_reboot_times)
time.sleep(1)
class AptP2pConfigManager():
APT_P2P_FILE = "/etc/apt-p2p/apt-p2p.conf"
HEADER_DSC = "apt-p2p config(/etc/apt-p2p/apt-p2p.conf) is not exists..."
def __init__(self):
if os.path.exists(self.APT_P2P_FILE):
self.p2pConfigs = UpgradeConfig(datadir = "/etc/apt-p2p/", name = "apt-p2p.conf")
else:
self.p2pConfigs = None
def get_bootstrap(self):
if self.p2pConfigs == None:
return self.HEADER_DSC
return self.p2pConfigs.getWithDefault("apt_p2p_Khashmir", "BOOTSTRAP", "Failed")
def set_bootstrap(self,value):
if self.p2pConfigs == None:
return self.HEADER_DSC
self.p2pConfigs.setValue("apt_p2p_Khashmir","BOOTSTRAP",str(value))

View File

@ -7,10 +7,17 @@ import logging
import apt_pkg
from gettext import gettext as _
from .backend import InstallBackend
from .Core.loop import mainloop
import SystemUpdater.Core.enums as enums
from .Core.errors import *
from .Core.utils import humanize_size
from SystemUpdater.Core.utils import get_proc_from_dbus_name,PolicyKit_Authority
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
import locale
from xml.etree import ElementTree
from .Core.MyCache import MyCache
from importlib import reload
UPDATER_DBUS_INTERFACE = 'com.kylin.UpgradeStrategies.interface'
UPDATER_DBUS_PATH = '/com/kylin/UpgradeStrategies'
@ -54,60 +61,6 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
self.transaction = None
# def _update_important_reply(self,retval):
# if bool(retval) == False:
# self.UpdateDetectFinished(False,[''],enums.get_error_string_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED),\
# enums.get_error_description_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED))
# else:
# self.parent.start_update_backend()
# def _update_important_error(self,retval):
# logging.error(str(retval))
# self.UpdateDetectFinished(False,[''],enums.get_error_string_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED),\
# enums.get_error_description_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED))
# #更新important.list的本次升级的列表
# def on_update_important_list(self):
# self.UpdateDetectStatusChanged(10,_("Updating Source Template"))
# obj = self.bus.get_object('com.kylin.software.properties', '/com/kylin/software/properties')
# interface = dbus.Interface(obj, dbus_interface='com.kylin.software.properties.interface')
# interface.updateSourceTemplate(timeout=20,reply_handler=self._update_important_reply,error_handler=self._update_important_error)
# def is_reboot_required(self):
# """If a reboot is required to get all changes into effect."""
# return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
# "var/run/reboot-required"))
# def is_logout_required(self):
# """If a logout is required to get all changes into effect."""
# return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
# "var/run/logout-required"))
# #重启aptdeamon后台服务
# def make_aptdeamon_restart(self):
# try:
# obj = self.bus.get_object('org.debian.apt', '/org/debian/apt')
# interface = dbus.Interface(obj, dbus_interface='org.debian.apt')
# logging.info("Now start to restart Aptdeamon...")
# interface.Quit()
# except Exception as e:
# logging.error(str(e))
# #设置aptdeamon的环境变量
# def set_aptdeamon_environ(self,key,value):
# try:
# logging.info("Set aptdeaom environment variables %s = %s...",key,value)
# obj = self.bus.get_object('org.debian.apt', '/org/debian/apt')
# interface = dbus.Interface(obj, dbus_interface='org.debian.apt')
# retval = interface.SetEnviron(key,value)
# return retval
# except Exception as e:
# logging.error(str(e))
# if key == "init" and value == "config":
# self.make_aptdeamon_restart()
# time.sleep(0.5)
# return False
@dbus.service.method(UPDATER_DBUS_INTERFACE,
in_signature="", out_signature="",
sender_keyword="caller_name")
@ -119,17 +72,276 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
mainloop.quit()
logging.debug("Exit")
@dbus.service.method(UPDATER_DBUS_INTERFACE,
in_signature="", out_signature="",
sender_keyword="caller_name")
def interface1(self, caller_name):
logging.info("interface1")
#set config value
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='sss',out_signature='b')
def SetConfigValue(self,section, option, value):
try:
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetConfigValue ...')
if self.parent.configs_uncover.has_section(str(section)) and self.parent.configs_uncover.has_option(str(section),str(option)):
if self.parent.configs_uncover.setValue(str(section), str(option),str(value)) == True:
return True
else:
return False
elif self.parent.sqlite3_server.ucconfigs.has_section(str(section)) and self.parent.sqlite3_server.ucconfigs.has_option(str(section),str(option)):
if self.parent.sqlite3_server.ucconfigs.setValue(str(section), str(option),str(value)) == True:
return True
else:
return False
except Exception as e:
logging.error(e)
return False
'''
#更新进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
def UpdateDetectStatusChanged(self,progress,status):
logging.info(COLORLOG_PREFIX+"Emitting"+COLORLOG_SUFFIX+" UpdateDetectStatusChanged progress = %d , status = %s",progress,status)
#get config value
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ss',out_signature='bs')
def GetConfigValue(self,section, option):
try:
if self.parent.configs_cover.has_section(str(section)) and self.parent.configs_cover.has_option(str(section),str(option)):
value = str(self.parent.configs_cover.get(str(section), str(option)))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" GetConfigValue section:%s option:%s value:%s ...",section,option,value)
return True,value
if self.parent.configs_uncover.has_section(str(section)) and self.parent.configs_uncover.has_option(str(section),str(option)):
value = str(self.parent.configs_uncover.get(str(section), str(option)))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" GetConfigValue section:%s option:%s value:%s ...",section,option,value)
return True,value
elif self.parent.sqlite3_server.ucconfigs.has_section(str(section)) and self.parent.sqlite3_server.ucconfigs.has_option(str(section),str(option)):
value = str(self.parent.sqlite3_server.ucconfigs.get(str(section), str(option)))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" GetConfigValue section:%s option:%s value:%s ...",section,option,value)
return True,value
else:
logging.warning("Warning: Can't found section:%s option:%s ... ",section, option)
except Exception as e:
logging.error("Error: GetConfigValue section:%s option:%s, %s.",section, option, e)
return False,''
#设置数据库配置信息
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ss',out_signature='b',sender_keyword='sender')
def DatabaseInfoSet(self,field_name,field_value,sender=None):
Status = False
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetDatabaseInfo,field_name:%s,field_value:%s,caller:%s .',\
field_name,field_value,sender_name)
Status = self.parent.sqlite3_server.insert_into_display(field_name,field_value)
return bool(Status)
#数据库获取配置信息
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='s',out_signature='s',sender_keyword='sender')
def DatabaseInfoGet(self,field_name,sender=None):
field_value = ''
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' GetDatabaseInfo field_name:%s caller:%s',field_name,sender_name)
field_value = self.parent.sqlite3_server.select_from_display(str(field_name))
logging.info("Get field_value:%s",field_value)
return field_value
# # dbus接口改变apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='sb', out_signature='b',sender_keyword='sender')
def DownloadspeedLimitSet(self, speed, set,sender = None):
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DownloadspeedLimitSet, speed:%s, set:%r, sender name: %s .'%(speed, set, sender_name))
#来重启Aptdeamon
self.parent.init_config_aptdeamon = True
if set:
with open("/etc/apt/apt.conf.d/80apt-download", "w+") as f:
try:
f.write("Acquire::http::Dl-Limit" + " \"" + "%s" % str(speed) + "\";\n")
f.write("Acquire::https::Dl-Limit" + " \"" + "%s" % str(speed) + "\";\n")
#更改数据库值
self.parent.sqlite3_server.insert_into_display("download_limit","true")
self.parent.sqlite3_server.insert_into_display("download_limit_value",str(speed))
#发送信号
self.ButtonStatusChange("speed" , str(speed))
return True
except Exception as e:
logging.error(e)
return False
else:
if os.path.exists("/etc/apt/apt.conf.d/80apt-download"):
os.remove("/etc/apt/apt.conf.d/80apt-download")
self.parent.sqlite3_server.insert_into_display("download_limit","false")
self.ButtonStatusChange("speed", "0")
return True
else:
self.parent.sqlite3_server.insert_into_display("download_limit","false")
self.ButtonStatusChange("speed", "0")
return True
# # dbus接口获取apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='bs',sender_keyword='sender')
def DownloadspeedLimitGet(self,sender = None):
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DownloadspeedLimitGet sender: %s .', sender_name)
try:
download_limit = self.parent.sqlite3_server.select_from_display("download_limit")
if download_limit == "true":
download_limit_value = self.parent.sqlite3_server.select_from_display("download_limit_value")
return True,str(download_limit_value)
else:
return False,str("0")
except:
return False, "0"
## dbus接口: 开启或关闭预下载功能
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='b', out_signature='b',sender_keyword='sender')
def SetPreDownloadState(self, _state,sender = None):
state = bool(_state)
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetPreDownloadState, state is %r, sender name: %s .',state,sender_name)
try:
if state:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "on", True)
else :
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "off", True)
self.ChangeUpgradePolicy()
except Exception as e:
logging.error(str(e))
return False
return True
## dbus接口: 发送立即更新的信号
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='b')
def AutoUpgradeAllNow(self):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' AutoUpgradeAllNow ...')
try:
self.UpgradeAllNow()
except Exception as e:
logging.error(str(e))
return False
return True
## dbus接口: 开启关闭自动更新功能
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='b', out_signature='b')
def SetAutoUpgradeState(self, _state):
state = bool(_state)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeState, state is %r ...',state)
try:
if state:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "on", True)
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "true")
self.ButtonStatusChange("autoUpgradeStatus", "true")
else :
self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "off", True)
# self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "manual", True)
# self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "manual", True)
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "false")
self.ButtonStatusChange("autoUpgradeStatus", "false")
self.ChangeUpgradePolicy()
except Exception as e:
logging.error(str(e))
return False
return True
## dbus接口: 设置自动更新策略
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='is', out_signature='b')
def SetAutoUpgradeMode(self, mode, time):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeMode, mode is %s, time is %s ...',mode, time)
try:
if mode == UU_UPGRADE_MODE_TIMING:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "timing", True)
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadTime", str(time), True)
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "timing", True)
self.ButtonStatusChange("autoUpgradeTime", str(time))
elif mode == UU_UPGRADE_MODE_BEFORE_SHUTDOWN:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "timing", True)
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "bshutdown", True)
self.ChangeUpgradePolicy()
except Exception as e:
logging.error(str(e))
return False
return True
# kill 进程
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='i', out_signature='b')
def KillProcessSignal(self, pid):
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' KillProcessSignal is %d', pid)
try:
# 判断文件是否存在
if (os.path.exists(RUN_UNATTENDED_UPGRADE)):
os.kill(int(pid), 9)
logging.info('%s has been killed', pid)
else:
logging.warning('%s is not exist.', RUN_UNATTENDED_UPGRADE)
except Exception as e:
logging.error(str(e))
return False
return True
# 获取系统版本号
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='ss',sender_keyword='sender')
def GetSystemUpdateVersion(self,sender=None):
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' GetSystemUpdateVersion sender: %s .', sender_name)
os_version = ''
update_version = ''
try:
self.parent.sqlite3_server.ucconfigs = UpgradeConfig(datadir = "/etc/kylin-version", name = "kylin-system-version.conf")
if not os.path.exists("/etc/kylin-version/kylin-system-version.conf"):
logging.warning("System version file doesn't exist.")
update_version,os_version = self.parent.sqlite3_server.get_default_version()
return str(os_version),str(update_version)
os_version = str(self.parent.sqlite3_server.ucconfigs.get("SYSTEM","os_version"))
update_version = str(self.parent.sqlite3_server.ucconfigs.get("SYSTEM","update_version"))
except Exception as e:
logging.error(str(e))
return str(e),''
logging.info('Current os_version: %s, release_id: %s .', os_version, update_version)
return os_version,update_version
# # dbus接口: 后端大数据采集
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='b',sender_keyword='sender')
def DataBackendCollect(self, messageType, uploadMessage, sender=None):
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DataBackendCollect, messageType is %s, called by: %s .',messageType,sender_name)
logging.debug("uploadMessage: %s.", uploadMessage)
try:
self.parent.collector.UpdateMsg(messageType, uploadMessage)
except Exception as e:
logging.error(str(e))
# 检查更新
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='as', out_signature='as', sender_keyword='sender')
def CheckInstalledOrUpgrade(self, pkgs, sender=None):
sender_name = get_proc_from_dbus_name(sender)
try:
pkglist = []
cache = MyCache(None)
self.parent.collector.cache = cache
for i in pkgs:
name = str(i).strip().replace("\n", "")
if name in cache:
pkg = cache[name]
if pkg.is_installed == False or pkg.is_upgradable == True:
pkglist.append(pkg.name)
pkglist.append(str(pkg.candidate.size))
self.parent.collector.make_background_version(pkg)
self.parent.collector.background_upgradable.append(pkg.name)
except:
logging.error("CheckInstalledOrUpgrade: Failed to obtain package information: %s" % str(i), exc_info=True)
# if len(pkglist) != 0:
# logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' CheckInstalledOrUpgrade, called by: %s, Upgrade list: %s .', sender_name, ", ".join(pkglist))
return pkglist
# 提供插入更新历史的接口
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='a{sv}', out_signature='b', sender_keyword='sender')
def InsertUpgradeHistory(self, arg = {}, sender=None):
try:
# {"appname":GLib.Variant("s", "kylin-system-updater"), "version":GLib.Variant("s", "string value")}
# "description":GLib.Variant("s", "Update Manager for Kylin"), "date":GLib.Variant("s", "2022-07-27 15:23:51")
# "status":GLib.Variant("s", "failed"), "keyword":GLib.Variant("s", "1")
# "errorcode":GLib.Variant("s", "System upgrade is complete. "), "appname_cn":GLib.Variant("s", "音乐")
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' Call InsertUpgradeHistory from %s.', sender_name)
if not self.parent.sqlite3_server.insert_upgrade_history(arg, sender_name) :
return False
except Exception as e:
logging.error("InsertUpgradeHistory Failed: %s" % str(e), exc_info=True)
return False
return True
# dbus 信号:用于发送立即更新信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE)
def UpgradeAllNow(self):
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" UpgradeAllNow")
WRITABLE_PROPERTIES = ()
@ -237,28 +449,36 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
def _set_property(self, iface, name, value, sender):
"""Helper to set a property on the properties D-Bus interface."""
# if iface == UPDATER_DBUS_INTERFACE:
# if name == "ShutdownInstall":
# self.parent.configs_uncover.setValue("InstallMode","shutdown_install",str(bool(value)))
# elif name == "P2pBootstrap":
# self.parent.apt_p2p_config.set_bootstrap(str(value))
# else:
# raise dbus.exceptions.DBusException("Unknown or read only "
# "property: %s" % name)
# else:
# raise dbus.exceptions.DBusException("Unknown interface: %s" %
# iface)
pass
if iface == UPDATER_DBUS_INTERFACE:
if name == "ShutdownInstall":
self.parent.configs_uncover.setValue("InstallMode","shutdown_install",str(bool(value)))
elif name == "P2pBootstrap":
self.parent.apt_p2p_config.set_bootstrap(str(value))
elif name == "UploadUpgradeLog":
self.parent.configs_uncover.setValue("SystemStatus","upload_upgrade_log",str(bool(value)))
elif name == "UploadInstallerLog":
self.parent.configs_uncover.setValue("SystemStatus","upload_installer_log",str(bool(value)))
else:
raise dbus.exceptions.DBusException("Unknown or read only "
"property: %s" % name)
else:
raise dbus.exceptions.DBusException("Unknown interface: %s" %
iface)
def _get_properties(self, iface):
"""Helper get the properties of a D-Bus interface."""
# if iface == UPDATER_DBUS_INTERFACE:
# return {
# "ShutdownInstall": dbus.Boolean(
# self.parent.configs_uncover.getWithDefault("InstallMode", "shutdown_install", False)),
if iface == UPDATER_DBUS_INTERFACE:
return {
"ShutdownInstall": dbus.Boolean(
self.parent.configs_uncover.getWithDefault("InstallMode", "shutdown_install", False)),
# "P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap())
# }
# else:
# return {}
pass
'''
"P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap()),
"UploadUpgradeLog": dbus.Boolean(
self.parent.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", True)),
"UploadInstallerLog": dbus.Boolean(
self.parent.configs_uncover.getWithDefault("SystemStatus", "upload_installer_log", False))
}
else:
return {}

View File

@ -7,16 +7,16 @@
<!-- Only root can own the service -->
<policy user="root">
<allow own="com.kylin.UpgradeStrategies"/>
<allow send_interface="com.kylin.upgradestrategies.interface"/>
<allow send_interface="com.kylin.UpgradeStrategies.interface"/>
</policy>
<!-- Allow anyone to invoke methods on the interfaces -->
<policy context="default">
<allow send_destination="com.kylin.upgradestrategies"
send_interface="com.kylin.upgradestrategies.interface"/>
<allow send_destination="com.kylin.upgradestrategies"
<allow send_destination="com.kylin.UpgradeStrategies"
send_interface="com.kylin.UpgradeStrategies.interface"/>
<allow send_destination="com.kylin.UpgradeStrategies"
send_interface="org.freedesktop.DBus.Introspectable"/>
<allow send_destination="com.kylin.upgradestrategies"
<allow send_destination="com.kylin.UpgradeStrategies"
send_interface="org.freedesktop.DBus.Properties"/>
</policy>

View File

@ -70,7 +70,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGINT,signal_handler_term)
if options.debug:
logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S',filename = logfile(),filemode = 'a')
logging.basicConfig(format=FORMAT,level=logging.INFO,datefmt='%m-%d,%H:%M:%S')
else:
logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S',filename = logfile(),filemode = 'a')