本文整理汇总了Python中util.Log.printError方法的典型用法代码示例。如果您正苦于以下问题:Python Log.printError方法的具体用法?Python Log.printError怎么用?Python Log.printError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Log
的用法示例。
在下文中一共展示了Log.printError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: work_png
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import printError [as 别名]
def work_png(filename):
filepath = FileHelper.realpath(filename)
filedir = FileHelper.dirname(filepath)
os.chdir(tpDir)
isSaveTransFile = False
isPng = True
useGZIP = False
if isPng:
jpgCMD = """%s %s -background black %s """ % (convertBin, filepath, filepath.replace(".png", ".rgb.jpg"))
alphaCMD = """%s %s -alpha extract %s """ % (convertBin, filepath, filepath.replace(".png", ".alpha.jpg"))
try:
os.system(jpgCMD)
os.system(alphaCMD)
except Exception:
Log.printDetailln ("error33 !!!", filename, "cannot convert.")
return 2
finally:
pass
tmpfilename = filepath.replace(".png", ".tmp")
FileHelper.remove(tmpfilename)
isSuccess = True
with open(tmpfilename, 'wb+') as tmpFile:
try:
tmpFile.write(b'MNG')
rgbname = filepath.replace(".png", ".rgb.jpg")
FileHelper.writeWithSize(tmpFile, rgbname)
alphaname = filepath.replace(".png", ".alpha.jpg")
FileHelper.writeWithSize(tmpFile, alphaname)
if not isSaveTransFile:
FileHelper.remove(rgbname)
FileHelper.remove(alphaname)
except Exception:
Log.printError()
isSuccess = False
pass
finally:
pass
if isSuccess:
if useGZIP:
gzip_cmd = gzipBin + tmpfilename + " -n -f -9"
os.system(gzip_cmd)
FileHelper.remove(tmpfilename.replace(".tmp", ".png"))
FileHelper.rename(tmpfilename + ".gz", tmpfilename.replace(".tmp", ".png"))
return 3
else:
FileHelper.remove(tmpfilename.replace(".tmp", ".png"))
FileHelper.rename(tmpfilename, tmpfilename.replace(".tmp", ".png"))
return 5
else:
return 2
示例2: work_file_PVR
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import printError [as 别名]
def work_file_PVR(filename, isDTC4Module = False, isTC4 = False):
filepath = FileHelper.realpath(filename)
filedir = FileHelper.dirname(filepath)
sys.stdout.flush()
os.chdir(toolsPath)
isTC4 = True
isAlphaJPG = False
if isDTC4Module:
isTC4 = False
preCMD = " -p "
preCMD = ""
info = ImageInfo.size(filepath)
# 只支持png纹理
if info[0] != 'PNG':
return 2
width = info[1]
height = info[2]
# 只支持正方形2的幂纹理
if width & (width-1) != 0 or width != height:
return 2
rgbCMD = """ %s -f PVRTC1_4_RGB %s -q pvrtcbest -i %s -o %s """ % (pvrTexToolBin, preCMD, filepath, filepath.replace(".png", ".pvr"))
alphaCMD = """%s %s -alpha extract %s """ % (convertBin, filepath, filepath.replace(".png", ".alpha.jpg"))
alphaJPGCMD = """ %s -f PVRTC1_4_RGB -q pvrtcbest -i %s -o %s """ % (pvrTexToolBin, filepath.replace(".png", ".alpha.jpg"), filepath.replace(".png", ".alpha.pvr"))
if isTC4:
rgbCMD = """ %s -f PVRTC1_4 %s -q pvrtcbest -i %s -o %s """ % (pvrTexToolBin, preCMD, filepath, filepath.replace(".png", ".pvr"))
try:
FileHelper.remove(filepath.replace(".png", ".pkm"))
FileHelper.remove(filepath.replace(".png", "_alpha.pkm"))
os.system(rgbCMD)
if not isTC4:
os.system(alphaCMD)
if not isAlphaJPG and not isTC4:
os.system(alphaJPGCMD)
if not FileHelper.exists(filepath.replace(".png", ".pvr")):
return 2
os.rename(filepath.replace(".png", ".pvr"), filepath.replace(".png", ".pkm"))
if not isTC4:
if not isAlphaJPG:
os.rename(filepath.replace(".png", ".alpha.jpg"), filepath.replace(".png", "_alpha.pkm"))
else:
os.rename(filepath.replace(".png", ".alpha.pvr"), filepath.replace(".png", "_alpha.pkm"))
FileHelper.remove(filepath.replace(".png", ".alpha.jpg"))
FileHelper.remove(filepath.replace(".png", ".alpha.pvr"))
except Exception:
Log.printError()
return 2
finally:
pass
tmpfilename = filepath.replace(".png", ".tmp")
FileHelper.remove(tmpfilename)
isSuccess = True
with open(tmpfilename, 'wb+') as tmpFile:
try:
tmpFile.write(b'MNG')
rgbname = filepath.replace(".png", ".pkm")
statinfo = os.stat(rgbname)
fileSize = statinfo.st_size
tmpFile.write(pack("i", fileSize))
rgbfile = open(rgbname, "rb")
tmpFile.write(rgbfile.read())
rgbfile.close()
alphaname = filepath.replace(".png", "_alpha.pkm")
if not isTC4:
statinfo = os.stat(alphaname)
fileSize = statinfo.st_size
tmpFile.write(pack("i", fileSize))
alphafile = open(alphaname, "rb")
tmpFile.write(alphafile.read())
alphafile.close()
# if preAlpha:
# tmpFile.write('p')
# else:
#.........这里部分代码省略.........
示例3: work_file_ETC
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import printError [as 别名]
def work_file_ETC(filename, isAlphaJPG = False, isFast = False):
filepath = FileHelper.realpath(filename)
filedir = FileHelper.dirname(filepath)
sys.stdout.flush()
#preAlpha = needPreAplha(filedir)
preAlpha = False
preCMD = " -p "
if not preAlpha:
preCMD = ""
os.chdir(toolsPath)
isPng = True
if filename.find(".png") != -1:
isPng = True
elif filename.find(".jpg") != -1:
isPng = False
else:
return 2
if isFast:
quality = 'etcfast'
else:
quality = 'etcslow'
rgbCMD = """ %s -f ETC1 %s -q %s -i %s -o %s """ % (pvrTexToolBin, preCMD, quality, filepath, filepath.replace(".png", ".pvr"))
alphaCMD = """%s %s -alpha extract %s """ % (convertBin, filepath, filepath.replace(".png", ".alpha.jpg"))
alphaJPGCMD = """ %s -f ETC1 -q %s -i %s -o %s """ % (pvrTexToolBin, quality, filepath.replace(".png", ".alpha.jpg"), filepath.replace(".png", ".alpha.pvr"))
try:
if isPng:
FileHelper.remove(filepath.replace(".png", ".pkm"))
FileHelper.remove(filepath.replace(".png", "_alpha.pkm"))
os.system(rgbCMD)
os.system(alphaCMD)
if not isAlphaJPG:
os.system(alphaJPGCMD)
FileHelper.rename(filepath.replace(".png", ".pvr"), filepath.replace(".png", ".pkm"))
if isAlphaJPG:
FileHelper.rename(filepath.replace(".png", ".alpha.jpg"), filepath.replace(".png", "_alpha.pkm"))
else:
FileHelper.rename(filepath.replace(".png", ".alpha.pvr"), filepath.replace(".png", "_alpha.pkm"))
FileHelper.remove(filepath.replace(".png", ".alpha.jpg"))
FileHelper.remove(filepath.replace(".png", ".alpha.pvr"))
else:
FileHelper.remove(filepath.replace(".jpg", ".pkm"))
rgbCMD = """ %s -f ETC1 -p -q %s -i %s -o %s """ % (pvrTexToolBin, quality, filepath, filepath.replace(".jpg", ".pvr"))
os.system(rgbCMD)
FileHelper.rename(filepath.replace(".jpg", ".pvr"), filepath.replace(".jpg", ".pkm"))
except Exception:
t, v, tb = sys.exc_info()
Log.printDetailln(t, v)
pass
finally:
pass
if isPng:
tmpfilename = filepath.replace(".png", ".tmp")
FileHelper.remove(tmpfilename)
isSuccess = True
with open(tmpfilename, 'wb+') as tmpFile:
try:
tmpFile.write(b'MNG')
rgbname = filepath.replace(".png", ".pkm")
alphaname = filepath.replace(".png", "_alpha.pkm")
FileHelper.writeWithSize(tmpFile, rgbname)
FileHelper.writeWithSize(tmpFile, alphaname)
# if preAlpha:
# tmpFile.write('p')
# else:
# tmpFile.write('P')
if not isSaveTransFile:
FileHelper.remove(rgbname)
FileHelper.remove(alphaname)
except Exception:
Log.printError()
isSuccess = False
pass
finally:
pass
if isSuccess:
if isUseGzip:
gzip_cmd = gzipBin + tmpfilename + " -n -f -9"
os.system(gzip_cmd)
#.........这里部分代码省略.........