# -*- coding: utf-8 -*-
#!/usr/local/bin/python
import os, sys,time,datetime,time,subprocess,pdb,fnmatch
from threading import Thread
def commandline_invoke(command_list):
#stdin_value ="./" + command + " ".join(parameter_list)
stdin_value = command_list
child1 = subprocess.Popen(stdin_value, stdout=subprocess.PIPE)
#print "ExcuteCommand: " + " ".join(stdin_value)
#print "ExcuteResult: "
while True :
line = child1.stdout.readline()
if not line :
break
print line
def translate(fileList):
commandLine = ["./performanceLogAnalyze.pl", "","QQ.app.dSYM"]
for fileName in fileList:
commandLine[1] = fileName
commandline_invoke(commandLine)
def get_dst_files(root,patterns='*' , single_level=False ,yieild_folders= False):
#将模式从字符串中取出放入列表中
patterns = patterns.split(';')
for path ,subdirs ,files in os.walk(root):
if yieild_folders :
files.extend(subdirs)
files.sort()
for name in files:
for pattern in patterns:
if fnmatch.fnmatch(name,pattern):
yield os.path.join(path,name)
break
if single_level:
break
def test_demo_1():
for i in range(0,1):
commandline_invoke(["./performanceLogAnalyze.pl", "BluePerformance.log","QQ.app.dSYM"])
def test_demo_2():
search_path = './'
#/Users/wenlezhou/Desktop/transfer
#只搜索一层目录,single_level=True
#pdb.set_trace()
for path in get_dst_files(search_path,'*.log',True):
print path
def execute_1():
print "把要翻译的blue日志文件,performanceLogAnalyze.pl文件,perforTransBat.py 文件放在同一文件夹下。会翻译所有的.log文件"
fileList = []
search_path = './'
for path in get_dst_files(search_path,'*.log',True):
fileList.append(path)
translate(fileList)
if __name__ == '__main__':
execute_1()