本文整理匯總了Python中log.log方法的典型用法代碼示例。如果您正苦於以下問題:Python log.log方法的具體用法?Python log.log怎麽用?Python log.log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類log
的用法示例。
在下文中一共展示了log.log方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: process_config_model
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_model(self):
log.log(log.LOG_INFO, "Processing Models")
for model in self.get_config_section('model'):
try:
self.validator.model(model)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot create Model '{0}': YAML validation Error: {1}".format(model['name'], e))
continue
try:
model_id = self.fm.models.show(model['name'])['id']
log.log(log.LOG_DEBUG, "Model '{0}' (id={1}) already present.".format(model['name'], model_id))
except:
log.log(log.LOG_INFO, "Create Model '{0}'".format(model['name']))
model_tpl = {
'name': model['name'],
'info': model['info'],
'vendor_class': model['vendor-class'],
'hardware_model': model['hardware-model']
}
self.fm.models.create( model = model_tpl )
示例2: process_config_medium
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_medium(self):
log.log(log.LOG_INFO, "Processing Media")
medialist = self.fm.media.index(per_page=99999)['results']
for medium in self.get_config_section('medium'):
try:
self.validator.medium(medium)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot create Media '{0}': YAML validation Error: {1}".format(medium['name'], e))
continue
medium_id = False
# fm.media.show(name) does not work, we need to iterate over fm.media.index()
for mediac in medialist:
if (mediac['name'] == medium['name']):
medium_id = mediac['id']
log.log(log.LOG_DEBUG, "Medium '{0}' (id={1}) already present.".format(medium['name'], medium_id))
if not medium_id:
log.log(log.LOG_INFO, "Create Medium '{0}'".format(medium['name']))
medium_tpl = {
'name': medium['name'],
'path': medium['path'],
'os_family': medium['os-family']
}
self.fm.media.create( medium = medium_tpl )
示例3: process_config_settings
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_settings(self):
log.log(log.LOG_INFO, "Processing Foreman Settings")
for setting in self.get_config_section('setting'):
try:
self.validator.setting(setting)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot update Setting '{0}': YAML validation Error: {1}".format(setting['name'], e))
continue
setting_id = False
try:
setting_id = self.fm.settings.show(setting['name'])['id']
except:
log.log(log.LOG_WARN, "Cannot get ID of Setting '{0}', skipping".format(setting['name']))
setting_tpl = {
'value': setting['value']
}
if setting_id:
log.log(log.LOG_INFO, "Update Setting '{0}'".format(setting['name']))
self.fm.settings.update(setting_tpl, setting_id)
示例4: process_config_smartproxy
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_smartproxy(self):
log.log(log.LOG_INFO, "Processing Smart Proxies")
for proxy in self.get_config_section('smart-proxy'):
try:
proxy_id = self.fm.smart_proxies.show(proxy['name'])['id']
log.log(log.LOG_DEBUG, "Proxy '{0}' (id={1}) already present.".format(proxy['name'], proxy_id))
except:
log.log(log.LOG_INFO, "Create Smart Proxy '{0}'".format(proxy['name']))
proxy_tpl = {
'name': proxy['name'],
'url': proxy['url'],
}
try:
self.fm.smart_proxies.create( smart_proxy = proxy_tpl )
except:
log.log(log.LOG_WARN, "Cannot create Smart Proxy '{0}'. Is the Proxy online? ".format(proxy['name']))
示例5: process_config_ptable
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_ptable(self):
log.log(log.LOG_INFO, "Processing Partition Tables")
for ptable in self.get_config_section('partition-table'):
try:
self.validator.ptable(ptable)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot create Partition Table '{0}': YAML validation Error: {1}".format(ptable['name'], e))
continue
try:
ptable_id = self.fm.ptables.show(ptable['name'])['id']
log.log(log.LOG_DEBUG, "Partition Table '{0}' (id={1}) already present.".format(ptable['name'], ptable_id))
except:
log.log(log.LOG_INFO, "Create Partition Table '{0}'".format(ptable['name']))
ptable_tpl = {
'name': ptable['name'],
'layout': ptable['layout'],
'snippet': ptable['snippet'],
'audit_comment': ptable['audit-comment'],
'locked': ptable['locked'],
'os_family': ptable['os-family']
}
self.fm.ptables.create( ptable = ptable_tpl )
示例6: process_auth_sources_ldap
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_auth_sources_ldap(self):
log.log(log.LOG_INFO, "Processing LDAP auth sources")
for auth in self.get_config_section('auth-source-ldap'):
# validate yaml
try:
self.validator.auth_source_ldaps(auth)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot create LDAP source '{0}': YAML validation Error: {1}".format(auth['name'], e))
continue
try:
as_id = self.fm.auth_source_ldaps.show(auth['name'])['id']
log.log(log.LOG_WARN, "LDAP source {0} allready exists".format(auth['name']))
continue
except TypeError:
pass
ldap_auth_obj = self.dict_underscore(auth)
try:
self.fm.auth_source_ldaps.create( auth_source_ldap=ldap_auth_obj )
except:
log.log(log.LOG_ERROR, "Something went wrong creating LDAP source {0}".format(auth['name']))
示例7: process_cleanup_arch
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_cleanup_arch(self):
log.log(log.LOG_INFO, "Processing Cleanup of Architectures")
for arch in self.get_config_section('cleanup-architecture'):
try:
self.validator.cleanup_arch(arch)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot delete Architecture '{0}': YAML validation Error: {1}".format(arch['name'], e))
continue
try:
self.fm.architectures.show(arch['name'])['id']
log.log(log.LOG_INFO, "Delete Architecture '{0}'".format(arch['name']))
self.fm.architectures.destroy( arch['name'] )
except:
log.log(log.LOG_WARN, "Architecture '{0}' already absent.".format(arch['name']))
示例8: process_cleanup_medium
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_cleanup_medium(self):
log.log(log.LOG_INFO, "Processing Cleanup of Media")
medialist = self.fm.media.index(per_page=99999)['results']
for medium in self.get_config_section('cleanup-medium'):
try:
self.validator.cleanup_medium(medium)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot delete Medium '{0}': YAML validation Error: {1}".format(medium['name'], e))
continue
medium_deleted = False
# fm.media.show(name) does not work, we need to iterate over fm.media.index()
for mediac in medialist:
if (mediac['name'] == medium['name']):
medium_deleted = True
log.log(log.LOG_INFO, "Delete Medium '{0}'".format(medium['name']))
self.fm.media.destroy( medium['name'] )
continue
if not medium_deleted:
log.log(log.LOG_WARN, "Medium '{0}' already absent.".format(medium['name']))
示例9: process_cleanup_ptable
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_cleanup_ptable(self):
log.log(log.LOG_INFO, "Processing Cleanup of Partition Tables")
for ptable in self.get_config_section('cleanup-partition-table'):
try:
self.validator.cleanup_ptable(ptable)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot delete Partition Table '{0}': YAML validation Error: {1}".format(ptable['name'], e))
continue
try:
self.fm.ptables.show(ptable['name'])['id']
log.log(log.LOG_INFO, "Delete Partition Table '{0}'".format(ptable['name']))
self.fm.ptables.destroy( ptable['name'] )
except:
log.log(log.LOG_WARN, "Partition Table '{0}' already absent.".format(ptable['name']))
示例10: _one_thread
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def _one_thread(self) -> None:
current_thread_id = threading.get_ident()
if current_thread_id == self._ThreadID:
return
log.show_value(
self.config,
log.level.DEBUG,
'ThreadID',
self._ThreadID
)
log.show_value(
self.config,
log.level.DEBUG,
'Current thread id',
current_thread_id
)
raise exceptions.MultiThreadOperated()
示例11: _get_user
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def _get_user(self, user_id) -> data_type.UserInfo:
check_value.check(self.config, str, 'UserID', user_id)
if len(user_id) < 2:
raise ValueError(log.merge(
self.config,
[
'UserID',
i18n.ErrorParameter,
user_id
]))
try:
from . import _api_get_user
except ModuleNotFoundError:
import _api_get_user
return _api_get_user.get_user(self, user_id)
示例12: add_details
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def add_details(file_name, title, artist, album, lyrics=""):
'''
Adds the details to song
'''
tags = EasyMP3(file_name)
tags["title"] = title
tags["artist"] = artist
tags["album"] = album
tags.save()
tags = ID3(file_name)
uslt_output = USLT(encoding=3, lang=u'eng', desc=u'desc', text=lyrics)
tags["USLT::'eng'"] = uslt_output
tags.save(file_name)
log.log("> Adding properties")
log.log_indented("[*] Title: %s" % title)
log.log_indented("[*] Artist: %s" % artist)
log.log_indented("[*] Album: %s " % album)
示例13: __init__
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def __init__(self, config, loglevel=logging.INFO):
logging.basicConfig(level=loglevel)
log.LOGLEVEL = loglevel
self.config = config['foreman']
self.loglevel = loglevel
self.validator = Validator()
示例14: connect
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def connect(self):
try:
urllib3.disable_warnings()
logging.disable(logging.WARNING)
self.fm = Foreman(self.config['auth']['url'], (self.config['auth']['user'], self.config['auth']['pass']), api_version=2, use_cache=False, strict_cache=False)
# this is nescesary for detecting faulty credentials in yaml
self.fm.architectures.index()
logging.disable(self.loglevel-1)
except:
log.log(log.LOG_ERROR, "Cannot connect to Foreman-API")
sys.exit(1)
示例15: process_config_arch
# 需要導入模塊: import log [as 別名]
# 或者: from log import log [as 別名]
def process_config_arch(self):
log.log(log.LOG_INFO, "Processing Architectures")
for arch in self.get_config_section('architecture'):
try:
self.validator.arch(arch)
except MultipleInvalid as e:
log.log(log.LOG_WARN, "Cannot create Architecture '{0}': YAML validation Error: {1}".format(arch['name'], e))
continue
try:
arch_id = self.fm.architectures.show(arch['name'])['id']
log.log(log.LOG_DEBUG, "Architecture '{0}' (id={1}) already present.".format(arch['name'], arch_id))
except:
log.log(log.LOG_INFO, "Create Architecture '{0}'".format(arch['name']))
self.fm.architectures.create( architecture = { 'name': arch['name'] } )