######################################################
#file_name : gather check
#
#function target: gather file error select
#
#author: zL
#time : 2018/04
#flow : get porcess path || (tar_file_analysis)
# : unprocess file || (un_cab, un_tar)
# : vol gather file check || (vogather_check)
# : get error line || (target_file_analysis, get_error_line)
# : agent lrt ensure || ()
#######################################################
#import rarfile
#import pandas
import os
#import time
#import sys
#import importlib
#importlib.reload(sys)
#reload(sys)
#sys.setdefaultencoding('utf8')
#importlib.setdefaultencoding('utf8')
#save CAB file
tarZ_path = []
tarZ_name = []
CAB_path = []
CAB_name = []
bz2_path = []
bz2_name = []
#add filename here
trace_file = ["aPP_Log.log", "aPPmaind.trc"]
trace_file.append("aPPmsgdd.trc");
#add check key worlds here
key_world = ["error", "warning"]#, "aPPwebd start", "aPPmaind", "aPPsvr start"
ignore_world = ["error=0", "errno=<2>", "errno=<16>"]
trace_path = []
#flag
result_file_flag = 1 # start
#######################################
#funtion: check if path exists
#in: dir
#out: 1: exists do nothing
# 0: not exists, mkdir
#######################################
def zl_WinRAR(file, path):
if os.path.exists("C:\Program Files\WinRAR\WinRAR.exe"):
cmd = "\"C:\Program Files\WinRAR\WinRAR.exe\" x " + file + " " + path
elif os.path.exists("C:\Program Files (x86)\WinRAR\WinRAR.exe"):
cmd = "\"C:\Program Files (x86)\WinRAR\WinRAR.exe\" x " + file + " " + path
else:
print("There is no WinRAR in your computer!\n")
exit(0)
os.system(cmd)
#######################################
#funtion: check if path exists
#in: dir
#out: 1: exists do nothing
# 0: not exists, mkdir
#######################################
def zl_mkdir(dir):
if os.path.isdir(dir):
return 1
else:
os.mkdir(dir)
return 0
#######################################
#funtion: check it is targetfile
#in: filename
#out: yes/no
#######################################
def isTargetFile(filename):
for value in trace_file:
if filename == value:
return 1
return 0
#######################################
#funtion: get compress file path and name
#in: now dir
#out: NULL
#######################################
def tar_file_analysis(file_dir):<