本文整理汇总了Python中util.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
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)
示例2: process
def process(self):
try:
self._clear_result()
self._reduce_comments()
self._reduce_favers()
except Exception, ex:
Log.error(ex, "mapreduce")
示例3: __init__
def __init__(self, filename):
if(filename[0] != '/'):
Log.w(TAG, "Filename is not absolute, this may cause issues dispatching jobs.")
ffprobe = subprocess.Popen(["ffprobe","-v", "quiet", "-print_format", "json", "-show_format", "-show_streams",filename], stdout=subprocess.PIPE)
#Get everything from stdout once ffprobe exits, and
try:
ffprobe_string = ffprobe.communicate()[0]
self.ffprobe_dict=json.loads(ffprobe_string)
except ValueError:
Log.e(TAG, "File could not be read, are you sure it exists?")
ffmpeg_interlace = subprocess.Popen(["ffmpeg", "-filter:v", "idet", "-frames:v", "400", "-an", "-f", "null", "-", "-i", filename],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
interlaced_details = ffmpeg_interlace.communicate()[1]
interlaced_lines = interlaced_details.split("\n")
num_progressive = 0
for line in interlaced_lines:
if line.find("idet") != -1 and line.find("Progressive") != -1:
#find the number of progressive frames in this line.
nframes = line.split("Progressive:")[1].split("Undetermined")[0]
num_progressive = num_progressive + int(nframes)
if num_progressive < 20:
self.is_interlaced = True
self.video_stream = self.parse_video(self.ffprobe_dict)
self.audio_streams = self.parse_audio(self.ffprobe_dict)
self.sub_streams = self.parse_subs(self.ffprobe_dict)
self.file_format = self.ffprobe_dict["format"]["format_name"]
self.duration = float(self.ffprobe_dict["format"]["duration"])
示例4: getOptions
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
示例5: popLayer
def popLayer(self, layer):
Log.debug("View: Pop: %s" % layer.__class__.__name__)
if layer in self.incoming:
self.incoming.remove(layer)
if layer in self.layers and not layer in self.outgoing:
self.outgoing.append(layer)
示例6: keyName
def keyName(value):
if value in CONTROL1:
name = "Controller 1"
control = CONTROL1
n = 0
elif value in CONTROL2:
name = "Controller 2"
control = CONTROL2
n = 1
elif value in CONTROL3:
name = "Controller 3"
control = CONTROL3
n = 2
else:
name = "Controller 4"
control = CONTROL4
n = 3
for j in range(20):
if value == control[j]:
if self.type[n] == 2:
return name + " " + drumkey4names[j]
elif self.type[n] == 3:
return name + " " + drumkey5names[j]
else:
return name + " " + guitarkeynames[j]
else:
Log.notice("Key value not found.")
return "Error"
示例7: __init__
def __init__(self, engine, controlnum, samprate=44100):
Task.__init__(self)
self.engine = engine
self.controlnum = controlnum
devnum = self.engine.input.controls.micDevice[controlnum]
if devnum == -1:
devnum = None
self.devname = pa.get_default_input_device_info()['name']
else:
self.devname = pa.get_device_info_by_index(devnum)['name']
self.mic = pa.open(samprate, 1, pyaudio.paFloat32, input=True, input_device_index=devnum, start=False)
self.analyzer = pypitch.Analyzer(samprate)
self.mic_started = False
self.lastPeak = 0
self.detectTaps = True
self.tapStatus = False
self.tapThreshold = -self.engine.input.controls.micTapSensitivity[controlnum]
self.passthroughQueue = []
passthroughVolume = self.engine.input.controls.micPassthroughVolume[controlnum]
if passthroughVolume > 0.0:
Log.debug('Microphone: creating passthrough stream at %d%% volume' % round(passthroughVolume * 100))
self.passthroughStream = Audio.MicrophonePassthroughStream(engine, self)
self.passthroughStream.setVolume(passthroughVolume)
else:
Log.debug('Microphone: not creating passthrough stream')
self.passthroughStream = None
示例8: icon_crop
def icon_crop(user_id, icon_path, coords):
response = {}
if not os.path.exists(icon_path):
response["status"] = False
response["message"] = "Not Found: %s" % icon_path
return response
image_path, ext = os.path.splitext(icon_path)
store_dir = _get_image_dir(ICON_PATH)
thumb_name = "u%s%s%s" % (user_id, str(int(time.time())), ext)
thumb_path = os.path.join(store_dir, thumb_name)
middle_name = "u%s%sb%s" % (user_id, str(int(time.time())), ext)
middle_path = os.path.join(store_dir, middle_name)
img = Image.open(icon_path)
left, top, width, height = tuple([int(i) for i in coords.split("|")])
box = (left, top, left+width, top+height)
img_thumb = img.crop(box)
big_size = (ICON_BIG_WIDTH, ICON_BIG_WIDTH)
img_thumb = img_thumb.resize(big_size, Image.ANTIALIAS)
img_thumb.save(middle_path, quality=150)
thumb_size = (ICON_WIDTH, ICON_WIDTH)
img_thumb = img_thumb.resize(thumb_size, Image.ANTIALIAS)
img_thumb.save(thumb_path, quality=150)
try:
os.remove(icon_path)
except Exception, ex:
Log.info(ex)
示例9: post
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
示例10: loadVideo
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):")
示例11: work2JPG
def work2JPG(filename, isPng = False):
filepath = FileHelper.realpath(filename)
filedir = FileHelper.dirname(filepath)
name = FileHelper.basename(filepath)
os.chdir(tpDir)
jpgCMD = """%s -quality 90 %s %s """ % (convertBin, filepath, filepath)
os.system(jpgCMD)
#return
tmpfilename = FileHelper.join(filedir, hashlib.md5(name.encode('utf-8')).hexdigest())
isSuccess = True
with open(tmpfilename, 'wb+') as tmpFile:
try:
tmpFile.write(b'MNG')
rgbname = filepath
FileHelper.writeWithSize(tmpFile, filepath)
except Exception:
Log.printDetailln ("error00 !!!", filename, "cannot convert.")
isSuccess = False
finally:
pass
if isSuccess:
FileHelper.remove(filepath)
FileHelper.rename(tmpfilename, filepath)
return 5
else:
return 2
示例12: print
def print(self):
if self.empty():
return
Log.printDetailln("%s.print:" % (self.name))
while not self.empty():
task = self.get()
ret, *args = task.param
Log.printDetailln('\t', ret, *args)
示例13: finishGame
def finishGame(self):
if not self.world:
Log.notice("GameEngine.finishGame called before World created.")
return
self.world.finishGame()
self.world = None
self.gameStarted = False
self.view.pushLayer(self.mainMenu)
示例14: start
def start(self):
if not self.mic_started:
self.mic_started = True
self.mic.start_stream()
self.engine.addTask(self, synchronized=False)
Log.debug('Microphone: started %s' % self.devname)
if self.passthroughStream is not None:
Log.debug('Microphone: starting passthrough stream')
self.passthroughStream.play()
示例15: remove
def remove(self):
""" Remove component with given name.
Returns True if the component successfully removed.
"""
Log.debug("Pubkey.remove(): removing")
self._remove_key()
super().remove()
return True