本文整理匯總了Python中log.logger.error方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.error方法的具體用法?Python logger.error怎麽用?Python logger.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類log.logger
的用法示例。
在下文中一共展示了logger.error方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: analysisCallTimes
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def analysisCallTimes(self, fileName):
try:
flag = False
call_record = []
f = open(fileName, 'r')
for line_content in f:
if flag:
call_record.append(line_content)
else:
if "Exclusive elapsed time for each method" in line_content:
flag = True
except IOError:
logger.error("The file don't exist, Please double check!")
regex = '(\d+?)\s+?([\d\.]+?)\s+?([\d\.]+?)\s+?([\d\.]+?)\s+?(\d+?)\+(\d+?)\s+?\[(\d+?)\]\s+?(.+?)$'
p = re.compile(regex)
call_data = {}
for each_excl in call_record:
result = p.findall(each_excl)
if len(result) != 0:
result = result[0]
tmp_method = self.trimPreStr(result[7].replace(" ", "").replace("/", "."), '.')
if re.search(WATCHER, tmp_method) is not None:
call_data[tmp_method] = int(result[4]) + int(result[5])
return call_data
示例2: __init__
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def __init__(self, url):
super(Song, self).__init__()
self.__dict__ = self
for key in TAG_KEYS:
if key in ['tracknumber', 'discnumber']:
self[key] = 0
elif key in ['title', 'artist', 'album']:
self[key] = "unknown"
from os.path import abspath, realpath, normpath
self['url'] = normpath(realpath(abspath(url)))
self['folder'] = os.path.dirname(self['url'])
if self.isExisted():
try:
self.getTags()
except Exception, e:
logger.error(e)
示例3: getMp3FontCover
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def getMp3FontCover(self):
from common import EasyMP3
ext = None
img_data = None
try:
audio = common.MutagenFile(self.url, common.FORMATS)
if isinstance(audio, EasyMP3):
if audio.tags:
apics = audio.tags.getID3().getall('APIC')
if len(apics) > 0:
apic = apics[0]
if apic.type == 3:
mine = apic.mime
ext = mine.split('/')[-1]
img_data = apic.data
except Exception, e:
logger.error(e)
示例4: support_continue
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def support_continue(self, url):
'''
check support continue download or not
'''
headers = {'Range': 'bytes=0-4'}
try:
r = requests.head(url, headers=headers)
if 'content-range' in r.headers:
crange = r.headers['content-range']
self.total = int(re.match(ur'^bytes 0-4/(\d+)$', crange).group(1))
self.songObj.sizeUpdated.emit(self.total)
return True
else:
self.total = 0
return False
except:
logger.error(traceback.print_exc())
try:
self.total = int(r.headers['content-length'])
self.songObj.sizeUpdated.emit(self.total)
except:
logger.error(traceback.print_exc())
self.total = 0
return False
示例5: addSong
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def addSong(self, songDict):
self._count += 1
def writeToDB():
try:
artistDict = {'name': songDict['artist']}
albumDict = {'name': songDict['album']}
folderDict = {'name': songDict['folder']}
fartist = Artist.get_create_Record(**artistDict)
falbum = Album.get_create_Record(**albumDict)
ffolder = Folder.get_create_Record(**folderDict)
songDict['fartist'] = fartist
songDict['falbum'] = falbum
songDict['ffolder'] = ffolder
song = Song.get_create_Record(**songDict)
print(song.id, threading.currentThread())
except Exception, e:
logger.error(songDict.pprint())
logger.error(e)
示例6: run
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def run(self):
try:
if CoverWorker.isOnlineSongCoverExisted(self.artist, self.title):
for media in self.medias:
artist = media['singerName']
title = media['songName']
localUrl = CoverWorker.onlineSongCoverPath(artist, title)
self.worker.download360SongCoverSuccessed.emit(
artist, title, localUrl)
return
r = requests.get(self.url)
for media in self.medias:
artist = media['singerName']
title = media['songName']
localUrl = CoverWorker.onlineSongCoverPath(artist, title)
with open(localUrl, "wb") as f:
f.write(r.content)
self.worker.download360SongCoverSuccessed.emit(
self.artist, self.title, localUrl)
except Exception, e:
logger.error(e)
示例7: retry_analysis
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def retry_analysis(restarts):
def wrapper(fn):
def try_analysis(*args, **kwargs):
if not isinstance(restarts, int) or not restarts:
return fn(*args, **kwargs)
for i in range(restarts):
try:
return fn(*args, **kwargs)
except Exception:
if restarts < i:
raise
logger.error("Exception during analysis, retrying analysis...")
return try_analysis
return wrapper
示例8: api_get
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def api_get(session, url, headers=None, params=None):
try:
resp = session.request(
'GET', url, headers=headers, timeout=TIME_OUT, params=params)
except Exception as e:
logger.error('request %s failed with error:%s' %
(url, str(e)))
return
if resp.status_code >= 300 or resp.status_code < 200:
logger.error('request %s failed with code:%d, info:%s' %
(url, resp.status_code, resp.text))
return
try:
return resp.json()
except Exception as e:
logger.error('Invalid Response!!')
示例9: list_apps
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def list_apps(cls, open_auth, groups, options=None):
def verify_options(options):
apptype, msg = '', ''
if options:
apptype = options.get('apptype', AppType.Normal)
return True, msg, apptype
is_valid, msg, apptype = verify_options(options)
if not is_valid:
return (400, None, msg, reverse('api_docs'))
try:
apps = App.all()
if open_auth:
app_datas = [AppApi.render_app(a) for a in apps if a.is_reachable()
and (True if apptype == '' else a.get_app_type() == apptype) and AuthApi.verify_app_access(groups, a.appname)]
else:
app_datas = [AppApi.render_app(a) for a in apps if a.is_reachable()
and (True if apptype == '' else a.get_app_type() == apptype)]
except Exception, e:
client.captureException()
return (500, None,
'fatal error when getting apps:\n%s\nplease contact with admin of lain\n' % e,
reverse('api_docs'))
示例10: list_app_procs
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def list_app_procs(cls, appname, options=None):
try:
app = App.get_or_none(appname)
if not app.is_reachable():
return (404, None,
'app with appname %s has not been deployd\n' % appname,
reverse('api_apps'))
proc_datas = []
for proc in app.lain_config.procs.values():
if proc.type != ProcType.portal:
pg_status = app.podgroup_status("%s.%s.%s" % (
appname, proc.type.name, proc.name
))
proc_datas.append(ProcApi.render_proc_data(
appname, proc, pg_status))
return (200, proc_datas, '', reverse('api_procs', kwargs={'appname': appname}))
except Exception, e:
client.captureException()
return (500, None,
'fatal error when get app %s procs:\n%s\nplease contact with admin of lain\n' % (
appname, e),
reverse('api_app', kwargs={'appname': appname}))
示例11: get_proc_history
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def get_proc_history(cls, appname, procname, instance, options=None):
try:
app = App.get_or_none(appname)
if not app.is_reachable():
return (404, None,
'app with appname %s has not been deployd\n' % appname,
reverse('api_apps'))
status_history = app.podgroup_status_history(procname, instance)
if status_history:
return (200, status_history,
'', reverse('api_proc_history',
kwargs={'appname': appname, 'procname': procname, 'instance': instance}))
else:
return (200, [],
'proc %s do not exists' % (procname),
reverse('api_proc_history',
kwargs={'appname': appname, 'procname': procname, 'instance': instance}))
except Exception, e:
client.captureException()
return (500, None,
'fatal error when get app %s proc %s:\n%s\nplease contact with admin of lain\n' % (
appname, procname, e),
reverse('api_procs', kwargs={'appname': appname}))
示例12: add_maintainer
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def add_maintainer(cls, access_token, appname, username, role):
try:
success, msg = Group.add_group_member(
access_token, appname, username, role)
if success:
return (200, MaintainApi.render_maintainer_data(appname, username, role),
'', reverse('api_maintainers', kwargs={'appname': appname}))
else:
return (500, None,
'error adding maintainer of app %s : \n%s\n' % (
appname, msg),
reverse('api_docs'))
except Exception, e:
return (500, None,
'fatal error when adding maintainer for %s:\n%s\nplease contact with admin of lain\n' % (
appname, e),
reverse('api_docs'))
示例13: delete_maintainer
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def delete_maintainer(cls, access_token, appname, username):
try:
success, msg = Group.delete_group_member(
access_token, appname, username)
if success:
return (204, None, msg,
reverse('api_maintainers', kwargs={'appname': appname}))
else:
return (500, None,
'error deleting maintainer of app %s : \n%s\n' % (
appname, msg),
reverse('api_docs'))
except Exception, e:
return (500, None,
'fatal error when deleting maintainer for %s:\n%s\nplease contact with admin of lain\n' % (
appname, e),
reverse('api_docs'))
示例14: get_maintainer
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def get_maintainer(cls, access_token, appname, username):
try:
success, msg = Group.get_group_members(appname)
if success:
for maintainer in msg:
if maintainer['name'] == username:
return (200, MaintainApi.render_maintainer_data(appname, maintainer['name'], maintainer['role']),
'', reverse('api_maintainer', kwargs={'appname': appname, 'username': username}))
return (404, None,
'user %s does not exist in the app %s\n' % (
username, appname),
reverse('api_maintainers', kwargs={'appname': appname}))
else:
return (500, None,
'error deleting maintainer of app %s : \n%s\n' % (
appname, msg),
reverse('api_docs'))
except Exception, e:
return (500, None,
'fatal error when getting maintainer for %s:\n%s\nplease contact with admin of lain\n' % (
appname, e),
reverse('api_docs'))
示例15: get_role
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import error [as 別名]
def get_role(cls, appname, access_token=None, username=None):
try:
if not AuthApi.need_auth(AUTH_TYPES['SSO']):
return (200, MaintainApi.render_role_data(appname, username if username else '', 'admin'), '',
reverse('api_role', kwargs={'appname': appname, 'username': ''}) if not access_token else
reverse('api_roles', kwargs={'appname': appname}))
if access_token and not username:
username = Authorize.get_username(access_token)
success, role = Group.get_user_role(username, appname)
if success:
return (200, MaintainApi.render_role_data(appname, username, role), '',
reverse('api_role', kwargs={'appname': appname, 'username': username}) if not access_token else
reverse('api_roles', kwargs={'appname': appname}))
else:
return (404, None,
'user %s does not exist in the maintainer list of app %s\n' % (
username, appname),
reverse('api_maintainers', kwargs={'appname': appname}))
except Exception, e:
return (500, None,
'fatal error when getting roles for %s:\n%s\nplease contact with admin of lain\n' % (
appname, e),
reverse('api_docs'))