本文整理汇总了Python中util.Log.error方法的典型用法代码示例。如果您正苦于以下问题:Python Log.error方法的具体用法?Python Log.error怎么用?Python Log.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Log
的用法示例。
在下文中一共展示了Log.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadVideo
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def loadVideo(self, libraryName, songName):
vidSource = None
if self.songStage == 1:
songBackgroundVideoPath = os.path.join(libraryName, songName, "background.ogv")
if os.path.isfile(songBackgroundVideoPath):
vidSource = songBackgroundVideoPath
loop = False
else:
Log.warn("Video not found: %s" % songBackgroundVideoPath)
if vidSource is None:
vidSource = os.path.join(self.pathfull, "default.ogv")
loop = True
if not os.path.isfile(vidSource):
Log.warn("Video not found: %s" % vidSource)
Log.warn("Falling back to default stage mode.")
self.mode = 1 # Fallback
return
try: # Catches invalid video files or unsupported formats
Log.debug("Attempting to load video: %s" % vidSource)
self.vidPlayer = VideoLayer(self.engine, vidSource,
mute = True, loop = loop)
self.engine.view.pushLayer(self.vidPlayer)
except (IOError, VideoPlayerError):
self.mode = 1
Log.error("Failed to load song video (falling back to default stage mode):")
示例2: post
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def post(self):
if not self.request.files:
self.render("account/icon.html", error=151)
return
files = self.request.files["icon"]
if len(files) == 0:
self.render("account/icon.html", error=151)
return
if files[0]["content_type"].split("/")[1] not in self.image_types:
self.render("account/icon.html", error=152)
return
image_type = files[0]["content_type"].split("/")[1]
"""TODO头像分片存储"""
ext = os.path.splitext(files[0]["filename"])[1]
filepath = "u_%s_%s%s" % (self.current_user["_id"], str(int(time.time())), ext)
file_dir = "%s/%s" % (self.settings["icon_dir"], filepath)
try:
writer = open(file_dir, "wb")
writer.write(files[0]["body"])
writer.flush()
writer.close()
except Exception, ex:
Log.error(ex)
self.render("account/icon.html", error=153)
return
示例3: getOptions
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def getOptions(self, section, option):
"""
Read the preset options of a configuration key.
@param section: Section name
@param option: Option name
@return: Tuple of Key list and Values list
"""
try:
options = self.prototype[section][option].options.values()
keys = self.prototype[section][option].options.keys()
type = self.prototype[section][option].type
except KeyError:
Log.error("Config key %s.%s not defined while reading %s." % (section, option, self.fileName))
raise
optionList = []
if type != None:
for i in range(len(options)):
value = _convertValue(keys[i], type)
optionList.append(value)
return optionList, options
示例4: post
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def post(self):
user_id = self.get_argument("uid", None)
title = self.get_argument("title", "")
link = self.get_argument("link", "")
profile = self.get_argument("profile", True)
tags = self.get_argument("tags", "").split(" ")
description = self.get_argument("description", "")
image_path = self.get_argument("Filedata.path", None)
image_name = self.get_argument("Filedata.name", None)
image_md5 = self.get_argument("Filedata.md5", None)
image_size = self.get_argument("Filedata.size", None)
categories = self.get_argument("categories", None)
if not user_id: return
user_id = int(user_id)
if not image_path: return
name, ext = os.path.splitext(image_name)
response = upload_crop(image_path, ext)
if not response["status"]: return
source_path = response["source_path"].split("/upload/")[1]
thumb_path = response["thumb_path"].split("/upload/")[1]
middle_path = response["middle_path"].split("/upload/")[1]
width = response["width"]
height = response["height"]
entry = self.entry_dal.template()
entry["user_id"] = user_id
entry["user"] = self.entry_dal.dbref("users", user_id)
entry["title"] = title
entry["link"] = link
entry["profile"] = profile
entry["tags"] = tags
entry["description"] = description
entry["source"] = source_path
entry["thumb"] = thumb_path
entry["middle"] = middle_path
entry["height"] = height
entry["width"] = width
entry["md5"] = image_md5
entry["size"] = image_size
if categories:
entry["categories"] = [int(item.strip())
for item in categories.split(",")
if item.strip()]
if title:
title = title.encode("utf-8", "ignore")
keywords = [seg for seg in seg_txt_search(title) if len(seg) > 1]
if len(tags) and tags[0]:
keywords = keywords + tags
entry["_keywords"] = keywords
try:
self.entry_dal.save(entry)
self.user_dal.update_entries_count(user_id)
except Exception, ex:
Log.error(ex)
示例5: process
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def process(self):
try:
self._clear_result()
self._reduce_comments()
self._reduce_favers()
except Exception, ex:
Log.error(ex, "mapreduce")
示例6: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def __init__(self, name = None, target = GL_TEXTURE_2D, useMipmaps = True):
# Delete all pending textures
try:
func, args = cleanupQueue[0]
del cleanupQueue[0]
func(*args)
except IndexError:
pass
except Exception, e: #MFH - to catch "did you call glewInit?" crashes
Log.error("Texture.py texture deletion exception: %s" % e)
示例7: keyPressed
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def keyPressed(self, key, unicode):
if key == pygame.K_LALT:
self.altStatus = True
elif key == pygame.K_RETURN and self.altStatus:
if not self.engine.toggleFullscreen():
Log.error("Unable to toggle fullscreen mode.")
return True
elif key == pygame.K_d and self.altStatus:
self.engine.setDebugModeEnabled(not self.engine.isDebugModeEnabled())
return True
elif key == pygame.K_g and self.altStatus and self.engine.isDebugModeEnabled():
self.engine.debugLayer.gcDump()
return True
示例8: getTipText
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def getTipText(self, section, option):
"""
Return the tip text for a configuration key.
@param section: Section name
@param option: Option name
@return: Tip Text String
"""
try:
text = self.prototype[section][option].tipText
except KeyError:
Log.error("Config key %s.%s not defined while reading %s." % (section, option, self.fileName))
raise
return text
示例9: getDefault
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def getDefault(self, section, option):
"""
Read the default value of a configuration key.
@param section: Section name
@param option: Option name
@return: Key value
"""
try:
type = self.prototype[section][option].type
default = self.prototype[section][option].default
except KeyError:
Log.error("Config key %s.%s not defined while reading %s." % (section, option, self.fileName))
raise
value = _convertValue(default, type)
return value
示例10: remove
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def remove(self):
""" Remove component with given name.
Returns ComponentLog if the component successfully removed.
"""
Log.debug("Component.remove(): removing")
name = self.c_id
exe_hash = self.c_exe_hash
super().remove()
import os
try:
os.remove(self._component_file)
except IOError:
Log.error("Component.remove(): unable to remove component file.")
return False
try:
cl = ComponentLog.add(name, exe_hash)
except InstanceAlreadyExists as e:
cl = e.original()
return cl
示例11: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def __init__(self, context, ImgData):
self.ImgData = None
self.texture = None
self.context = context
self.cache = None
self.filename = ImgData
# Detect the type of data passed in
if isinstance(ImgData, file):
self.ImgData = ImgData.read()
elif isinstance(ImgData, basestring):
self.texture = Texture(ImgData)
elif isinstance(ImgData, Image.Image): #stump: let a PIL image be passed in
self.texture = Texture()
self.texture.loadImage(ImgData)
# Make sure we have a valid texture
if not self.texture:
if isinstance(ImgData, basestring):
e = "Unable to load texture for %s." % ImgData
else:
e = "Unable to load texture for SVG file."
Log.error(e)
raise RuntimeError(e)
self.pixelSize = self.texture.pixelSize #the size of the image in pixels (from texture)
self.position = [0.0,0.0] #position of the image in the viewport
self.scale = [1.0,1.0] #percentage scaling
self.angle = 0 #angle of rotation (degrees)
self.color = (1.0,1.0,1.0,1.0) #glColor rgba
self.rect = (0,1,0,1) #texture mapping coordinates
self.shift = -.5 #horizontal alignment
self.vshift = -.5 #vertical alignment
self.path = self.texture.name #path of the image file
self.texArray = np.zeros((4,2), dtype=np.float32)
self.createTex()
示例12: set
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def set(self, section, option, value):
"""
Set the value of a configuration key.
@param section: Section name
@param option: Option name
@param value: Value name
"""
try:
prototype[section][option]
except KeyError:
Log.error("Config key %s.%s not defined while writing %s." % (section, option, self.fileName))
raise
if not self.config.has_section(section):
self.config.add_section(section)
self.config.set(section, option, utf8(value))
f = open(self.fileName, "w")
self.config.write(f, self.type)
f.close()
示例13: loadImgDrawing
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
def loadImgDrawing(self, target, name, fileName, textureSize=None):
"""
Load an SVG drawing synchronously.
@param target: An object that will own the drawing
@param name: The name of the attribute the drawing will be assigned to
@param fileName: The name of the file in the data directory
@param textureSize: Either None or (x, y), in which case the file will
be rendered to an x by y texture
@return: L{ImgDrawing} instance
"""
imgDrawing = self.getImgDrawing(fileName)
if not imgDrawing:
if target and name:
setattr(target, name, None)
else:
Log.error("Image not found: " + fileName)
return None
if target:
drawing = self.resource.load(target, name, lambda: imgDrawing, synch=True)
else:
drawing = imgDrawing
return drawing
示例14: VideoLayer
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
engine.cmdMode = nbrplayers, mode, 0
else:
engine.cmdMode = nbrplayers, 0, mode
# Play the intro video if it is present, we have the capability, and
# we are not in one-shot mode.
videoLayer = False
if not engine.cmdPlay:
themename = Config.get("coffee", "themename")
vidSource = os.path.join(Version.dataPath(), 'themes', themename, \
'menu', 'intro.ogv')
if os.path.isfile(vidSource):
try:
vidPlayer = VideoLayer(engine, vidSource, cancellable=True)
except (IOError, VideoPlayerError):
Log.error("Error loading intro video:")
else:
vidPlayer.play()
engine.view.pushLayer(vidPlayer)
videoLayer = True
engine.ticksAtStart = pygame.time.get_ticks()
while not vidPlayer.finished:
engine.run()
engine.view.popLayer(vidPlayer)
engine.view.pushLayer(MainMenu(engine))
if not videoLayer:
engine.setStartupLayer(MainMenu(engine))
# Run the main game loop.
try:
engine.ticksAtStart = pygame.time.get_ticks()
示例15: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import error [as 别名]
#.........这里部分代码省略.........
self.spcount2 = 0
self.bgcount = 0
self.fourXcount = 0
self.ovrneckoverlay = self.engine.config.get("fretboard", "ovrneckoverlay")
self.ocount = 0
self.currentPeriod = 60000.0 / self.instrument.currentBpm
self.lastBpmChange = -1.0
self.baseBeat = 0.0
#myfingershurt:
self.bassGrooveNeckMode = self.engine.config.get("game", "bass_groove_neck")
self.guitarSoloNeckMode = self.engine.config.get("game", "guitar_solo_neck")
self.fourxNeckMode = self.engine.config.get("game", "4x_neck")
self.useMidiSoloMarkers = False
self.markSolos = 0
neckFind = True
themeNeckPath = os.path.join(self.engine.resource.fileName("themes", themename, "necks"))
if self.neckType == 1 and os.path.exists(themeNeckPath):
themeNeck = []
neckfiles = [ f for f in os.listdir(themeNeckPath) if os.path.isfile(os.path.join(themeNeckPath, f)) ]
neckfiles.sort()
for i in neckfiles:
themeNeck.append(str(i))
if len(themeNeck) > 0:
i = random.randint(0,len(themeNeck)-1)
if engine.loadImgDrawing(self, "neckDrawing", os.path.join("themes", themename, "necks", themeNeck[i]), textureSize = (256, 256)):
neckFind = False
Log.debug("Random theme neck chosen: " + themeNeck[i])
else:
Log.error("Unable to load theme neck: " + themeNeck[i])
# fall back to defaultneck
self.neck = "defaultneck"
if neckFind:
# evilynux - Fixed random neck -- MFH: further fixing random neck
if self.neck == "0" or self.neck == "Neck_0" or self.neck == "randomneck":
self.neck = []
# evilynux - improved loading logic to support arbitrary filenames
path = self.engine.resource.fileName("necks")
neckfiles = [ f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) ]
neckfiles.sort()
for i in neckfiles:
# evilynux - Special cases, ignore these...
if( os.path.splitext(i)[0] == "randomneck" or os.path.splitext(i)[0] == "overdriveneck" ):
continue
else:
self.neck.append(str(i)[:-4]) # evilynux - filename w/o extension
i = random.randint(0,len(self.neck)-1)
if engine.loadImgDrawing(self, "neckDrawing", os.path.join("necks",self.neck[i]+".png"), textureSize = (256, 256)):
Log.debug("Random neck chosen: " + self.neck[i])
else:
Log.error("Unable to load neck: " + self.neck[i])
self.neck = "defaultneck"
engine.loadImgDrawing(self, "neckDrawing", os.path.join("necks",self.neck+".png"), textureSize = (256, 256))
else:
# evilynux - first assume the self.neck contains the full filename
if not engine.loadImgDrawing(self, "neckDrawing", os.path.join("necks",self.neck+".png"), textureSize = (256, 256)):
if not engine.loadImgDrawing(self, "neckDrawing", os.path.join("necks","Neck_"+self.neck+".png"), textureSize = (256, 256)):
engine.loadImgDrawing(self, "neckDrawing", os.path.join("necks","defaultneck.png"), textureSize = (256, 256))
#blazingamer:
#this helps me clean up the code a bit