def __init__(self, logname): try: configfile = 'config.ini' config = ConfigObj(configfile, file_error=True) self.config = config self.files = dict() self.files['log'] = config['samsung']['log'] self.keywords = dict() self.keywords['recvrsp'] = config['samsung']['keywords']['recvrsp'] self.keywords['recvreq'] = config['samsung']['keywords']['recvreq'] self.keywords['sendreq'] = config['samsung']['keywords']['sendreq'] self.keywords['sendrsp'] = config['samsung']['keywords']['sendrsp'] self.keywords['ikemsg'] = config['samsung']['keywords']['ikemsg'] self.logtags = config['samsung']['pattern']['logtags'] #TODO: add a state machine self.keywords['statechange'] = config['samsung']['keywords'][ 'statechange'] self.keywords['wifichange'] = config['samsung']['keywords'][ 'wifichange'] self.keywords['wfcchange'] = config['samsung']['keywords'][ 'wfcchange'] self.keywords['airplanechange'] = config['samsung']['keywords'][ 'airplanechange'] self.loglevel = config['logging']['loglevel'] #have to set loglevel to interger... self.logger = logConf( debuglevel=logging.getLevelName(self.loglevel)) self.utils = utils(configpath='./') self.diagstr = '' realpath = os.path.realpath(logname) self.log = realpath self.diagdir = os.path.realpath(os.path.dirname(logname)) + '/' self.diagtempdir = self.diagdir + 'temp/' #first of all, create the tempdir self.utils.mkdirp(self.diagtempdir) #all msgs will be included self.msgs = list() self.lines = list() #will split the msg into list self.diagstrList = None self.pdfList = list() self.splitgate = 40 with open(self.log) as samsungfile: self.lines = samsungfile.readlines() except (ConfigObjError, IOError) as e: print('Could not read "%s": %s' % (configfile, e))
def __init__(self,logname): try: configfile = 'config.ini' config = ConfigObj(configfile, file_error=True) self.config = config self.files = dict() self.files['log'] = config['samsung']['log'] self.keywords = dict() self.keywords['recvrsp'] = config['samsung']['keywords']['recvrsp'] self.keywords['recvreq'] = config['samsung']['keywords']['recvreq'] self.keywords['sendreq'] = config['samsung']['keywords']['sendreq'] self.keywords['sendrsp'] = config['samsung']['keywords']['sendrsp'] self.keywords['ikemsg'] = config['samsung']['keywords']['ikemsg'] self.logtags = config['samsung']['pattern']['logtags'] #TODO: add a state machine self.keywords['statechange'] = config['samsung']['keywords']['statechange'] self.keywords['wifichange'] = config['samsung']['keywords']['wifichange'] self.keywords['wfcchange'] = config['samsung']['keywords']['wfcchange'] self.keywords['airplanechange'] = config['samsung']['keywords']['airplanechange'] self.loglevel = config['logging']['loglevel'] #have to set loglevel to interger... self.logger = logConf(debuglevel=logging.getLevelName(self.loglevel)) self.utils = utils(configpath='./') self.diagstr = '' realpath = os.path.realpath(logname) self.log = realpath self.diagdir = os.path.realpath(os.path.dirname(logname)) + '/' self.diagtempdir = self.diagdir + 'temp/' #first of all, create the tempdir self.utils.mkdirp(self.diagtempdir) #all msgs will be included self.msgs = list() self.lines = list() #will split the msg into list self.diagstrList = None self.pdfList = list() self.splitgate = 40 with open(self.log) as samsungfile: self.lines = samsungfile.readlines() except (ConfigObjError, IOError) as e: print('Could not read "%s": %s' % (configfile, e))
def __init__(self): try: configfile = path + '/config.ini' config = ConfigObj(configfile, file_error=True) self.config = config self.loglevel = config['logging']['loglevel'] self.version = config['utils']['version'] self.msglen = 0 print self.loglevel print logging.getLevelName(self.loglevel) self.logger = logConf(debuglevel=logging.getLevelName(self.loglevel)) #one sip msg to render diagram's time self.estimatetime = config['utils']['estimate'] self.threadlist = list() self.utils = utils(configpath='./') self.atmsgs = '' except (ConfigObjError, IOError) as e: print 'Could not read "%s": %s' % (configfile, e)
def __init__(self): try: configfile = path + '/config.ini' config = ConfigObj(configfile, file_error=True) self.config = config self.loglevel = config['logging']['loglevel'] self.version = config['utils']['version'] self.msglen = 0 print self.loglevel print logging.getLevelName(self.loglevel) self.logger = logConf(debuglevel=logging.getLevelName(self.loglevel)) #one sip msg to render diagram's time self.estimatetime = config['utils']['estimate'] self.threadlist = list() self.utils = utils(configpath='./') self.atmsgs = '' except (ConfigObjError, IOError) as e: print 'Could not read "%s": %s' % ('config.ini', e)
def __init__(self, logname, filterlevel='low', outputdir= './'): try: configfile = 'config.ini' config = ConfigObj(configfile, file_error=True) self.config = config self.files = dict() #self.files['log'] = config['files']['log'] self.files['process'] = config['files']['process'] filterinfo = config['filterlevels'][filterlevel] #if only str, convert to list if type(filterinfo['juphoon']) is str: filterinfo['juphoon'] = filterinfo['juphoon'].split() if type(filterinfo['android']) is str: filterinfo['android'] = filterinfo['android'].split() self.process = filterinfo['juphoon'] + filterinfo['android'] self.switch = dict() self.switch['trimlog'] = config['switch']['trimlog'] #pid array, it will be used to grep pid logs self.pids = list() #struct to contain 'process'(str), 'tags'(list) self.piddb = dict() #FIXME: ugly code for searchEvent in flowParser.py self.pidpair = dict() self.tags = dict() self.words = dict() #keywords may be in wrong place, each self.priority = dict() self.keywords = config['keywords']['keywords'] self.utils = utils(configpath='./') #prepare the log file handle ''' logList = glob.glob(self.files['log'])[0] if not logList: print 'no log file found.' return ''' self.loglevel = config['logging']['loglevel'] #have to set loglevel to interger... self.logger = logConf(debuglevel=logging.getLevelName(self.loglevel)) self.utils = utils(configpath='./') realpath = os.path.realpath(logname) self.log = realpath self.trimlog = outputdir + 'logs/'+filterlevel + '_' + os.path.basename(realpath) with open(self.trimlog, 'w') as tlog: tlog.truncate()#index = 0 self.processout = outputdir + 'logs/' + 'processout.log' self.keylog = outputdir + 'logs/' + 'key_' + os.path.basename(realpath) self.elog = outputdir + 'logs/' + 'error_' + os.path.basename(realpath) self.diagdir = outputdir + 'diagrams/' self.diagstr = '' #read errorpattern and keys self.errorpattern = dict() self.keys = dict() self.errorpattern['lemon'] = lemonmsg.errorpattern self.errorpattern['imscm'] = imscmmsg.errorpattern self.errorpattern['adapter'] = adaptermsg.errorpattern self.errorpattern['service'] = servicemsg.errorpattern self.keys = dict() self.keys['imscmkey'] = self.utils.getPattern(imscmmsg.keys) self.logger.logger.error('imscmkey is ' + self.keys['imscmkey']) self.keys['adapterkey'] = self.utils.getPattern(adaptermsg.keys) self.logger.logger.error('adapterkey is ' + self.keys['adapterkey'] ) self.keys['lemonkey'] = self.utils.getPattern(lemonmsg.keys) self.logger.logger.error('lemonkey is ' + self.keys['lemonkey']) self.keys['servicekey'] = self.utils.getPattern(servicemsg.keys) self.logger.logger.error('servicekey is ' + self.keys['servicekey']) self.keys['s2bkey'] = self.utils.getPattern(s2bmsg.keys) self.logger.logger.error('s2bkey is ' + self.keys['s2bkey']) with open(self.keylog, 'w') as klog: klog.truncate()#index = 0 with open(self.elog, 'w') as elog: elog.truncate()#index = 0 self.tagfile = "processtags" self.defaultoccurnum = 1 self.lemonoccurnum = 50 except (ConfigObjError, IOError) as e: print('Could not read "%s": %s' % ('config.ini', e))
def run(self): # util will do the search # util will create result dir # flowParser only parse one file title = 'VoWifi log tool by zhihua.ye, version: ' + str(self.version) buttonboxmsg = 'Please open a directory which contains slog.' slogstring = 'Open the slog dir' samsungfile = "Open Samsung log file" choices = [slogstring, samsungfile , 'Exit'] choice = buttonbox(buttonboxmsg, title = title, choices = choices) if choice != 'Exit': if choice == slogstring: folder = diropenbox() if not folder: msgbox('please relaunch and open a directory.') exit else: helper = utils(configpath='./') matches = helper.findlogs(folder) for index,filedict in enumerate(matches): #call the real parser self.curtimestamp = strftime("%Y_%m_%d_%H_%M_%S", gmtime()) mainlog = filedict['mainlog'] radiolog = filedict['radiolog'] kernellog = filedict['kernellog'] #actually mainlog will always exist #first of all , get radio log , if exist if not mainlog: continue mainlogrealpath = os.path.realpath(mainlog) shortname = os.path.basename(mainlogrealpath) dirname = os.path.dirname(mainlogrealpath) outputdir = dirname + '/' + shortname.split('.')[0] self.utils.mkdirp(outputdir) if kernellog: print 'kernel log is ' + kernellog krealpath = os.path.realpath(kernellog) kshortname = os.path.basename(kernellog) kernel_results = parse_imsbr(krealpath) #FIXME: output imsbr log to diagrams kernel_outputdir = outputdir + '/diagrams/' self.utils.mkdirp(kernel_outputdir) imsbrlog = kernel_outputdir + '/'+ kshortname.split('.')[0] +'-imsbr.log' with open(imsbrlog, 'w') as imsbrlog: for dict in kernel_results: imsbrlog.write("line%d: %s %s \n" %(dict["lineno"], dict["timestamp"], dict["msg"])) if radiolog: rp = radioParser(logname = radiolog, outputdir = outputdir) self.atmsgs = rp.getflow() rp.assembleStr() rp.drawAllDiag() fp = flowParser(logname = mainlog, atmsgs=self.atmsgs) len = fp.getFlow() self.msglen = len self.logger.logger.info('sip msgs len is ' + str(len)) #self.popupmsg(file) #msgbox(msg) #t = ThreadWithExc(target=self.popupthread,args=(currentfile,)) #t.start() fp.parseFlow() fp.drawAllDiag() #fp.drawLemonDiag() #t.raiseExc(SystemExit) msgbox('Finish parsing sprd log file') elif choice == samsungfile: file = fileopenbox() if not file: msgbox('please relaunch and open a valid samsung log.') exit else: sp = samsungParser(logname=file) sp.getflow() msgbox('Finish parsing file ' + file) else: return
def run(self): # util will do the search # util will create result dir # flowParser only parse one file title = 'VoWifi log tool version: ' + str(self.version) buttonboxmsg = 'Please open a directory which contains slog.' ylogstring = 'Open the ylog dir' samsungfile = "Open Samsung log file" choices = [ylogstring, samsungfile , 'Exit'] choice = buttonbox(buttonboxmsg, title = title, choices = choices) if choice != 'Exit': if choice == ylogstring: takestime = 'NA' realmainlog = None folder = diropenbox() if not folder: msgbox('please relaunch and open a directory.') exit() else: helper = utils(configpath='./') self.logger.logger.info('folder is ' + folder) matches = helper.findlogs(folder) ''' print matches import time time.sleep(50) ''' for index, filedict in enumerate(matches): #call the real parser self.curtimestamp = strftime("%Y_%m_%d_%H_%M_%S", gmtime()) mainlog = filedict['mainlog'] radiolog = filedict['radiolog'] kernellog = filedict['kernellog'] #actually mainlog will always exist #first of all , get radio log , if exist if not mainlog: continue self.logger.logger.info('mainlog is ' + mainlog); mainlogrealpath = os.path.realpath(mainlog) shortname = os.path.basename(mainlogrealpath) dirname = os.path.dirname(mainlogrealpath) outputdir = dirname + '/' + shortname.split('.')[0] self.utils.mkdirp(outputdir) if kernellog: print 'kernel log is ' + kernellog krealpath = os.path.realpath(kernellog) kshortname = os.path.basename(kernellog) kernel_results = parse_imsbr(krealpath) #FIXME: output imsbr log to diagrams kernel_outputdir = outputdir + '/diagrams/' self.utils.mkdirp(kernel_outputdir) imsbrlog = kernel_outputdir + '/'+ kshortname.split('.')[0] +'-imsbr.log' with open(imsbrlog, 'w') as imsbrlog: for dict in kernel_results: imsbrlog.write("line%d: %s %s \n" %(dict["lineno"], dict["timestamp"], dict["msg"])) if radiolog: rp = radioParser(logname = radiolog, outputdir = outputdir) self.atmsgs = rp.getflow() rp.assembleStr() rp.drawAllDiag() realmainlog = mainlog #add other log's parsing, like crash #try to add crash log, crashlog = os.path.dirname(mainlog) + '/crash.log' crashp = crashParser(logname=crashlog) crashp.parselog() cmsgs = crashp.getmsgs() fp = flowParser(logname = mainlog, atmsgs=self.atmsgs, crashmsgs=cmsgs) len = fp.getFlow() self.msglen = len self.logger.logger.info('sip msgs len is ' + str(len)) #self.popupmsg(file) #msgbox(msg) #t = ThreadWithExc(target=self.popupthread,args=(currentfile,)) #t.start() fp.parseFlow() takestime = fp.drawAllDiag() if takestime == -1: self.logger.logger.info('exit the parser unexpectedly!') exit(-1) #fp.drawLemonDiag() #t.raiseExc(SystemExit) popupstr = '' filestr = '' if realmainlog: fsize = os.path.getsize(realmainlog) name = os.path.basename(realmainlog) filestr = "file is " + name + '\n' + "file size is " + str(self.utils.humansize(fsize)) + '\n' popupstr = "Finishing parsing\n" popupstr += filestr popupstr += "It takes "+ takestime + " seconds" self.logger.logger.info(popupstr) msgbox(popupstr) elif choice == samsungfile: file = fileopenbox() if not file: msgbox('please relaunch and open a valid samsung log.') exit() else: sp = samsungParser(logname=file) sp.getflow() msgbox('Finish parsing file ' + file) else: return
def __init__(self, logname, outputdir='./'): try: configfile = path + '/config.ini' config = ConfigObj(configfile, file_error=True) self.radiolog = logname self.config = config self.pattern = dict() self.pattern['pdnpattern'] = config['radioParser']['pdnpattern'] self.pattern['hopattern'] = config['radioParser']['hopattern'] self.pattern['wifienpattern'] = config['radioParser'][ 'wifienpattern'] #self.pattern['repregpattern'] = config['radioParser']['repregpattern'] self.pattern['qryregpattern'] = config['radioParser'][ 'qryregpattern'] self.pattern['regstspattern'] = config['radioParser'][ 'regstspattern'] self.pattern['attachpattern'] = config['radioParser'][ 'attachpattern'] self.pattern['vowfregpattern'] = config['radioParser'][ 'vowfregpattern'] self.pattern['wifiinfopattern'] = config['radioParser'][ 'wifiinfopattern'] self.pattern['lteinfopattern'] = config['radioParser'][ 'lteinfopattern'] self.pattern['callendpattern'] = config['radioParser'][ 'callendpattern'] self.pattern['errorpattern'] = config['radioParser'][ 'errorpattern'] self.pattern['updatedrpattern'] = config['radioParser'][ 'updatedrpattern'] self.pattern['rtppattern'] = config['radioParser']['rtppattern'] self.pattern['volteimspattern'] = config['radioParser'][ 'volteimspattern'] self.pattern['volteregaddrpattern'] = config['radioParser'][ 'volteregaddrpattern'] self.initkeypattern() self.atmsgs = list() self.logger = logConf() #diagstr self.diagstr = '' #will split the msg into list self.diagstrList = None self.pdfList = list() self.splitgate = 30 self.utils = utils(configpath='./') prefix = outputdir self.utils.createdirs(outputdir) self.diagdir = prefix + '/diagrams/' self.diagdirdiag = prefix + '/diagrams/diag/' self.diagdirpdf = prefix + '/diagrams/pdf/' self.logdir = prefix + '/logs/' realpath = os.path.realpath(logname) basename = os.path.basename(realpath) self.trimlog = self.logdir + 'trim_' + basename with open(self.trimlog, 'w') as tlog: tlog.truncate() self.starttime = datetime.now() except (ConfigObjError, IOError) as e: print 'Could not read "%s": %s' % (configfile, e)
def run(self): # util will do the search # util will create result dir # flowParser only parse one file title = 'VoWifi log tool version: ' + str(self.version) buttonboxmsg = 'Please open a directory which contains slog.' ylogstring = 'Open the ylog dir' samsungfile = "Open Samsung log file" choices = [ylogstring, samsungfile, 'Exit'] choice = buttonbox(buttonboxmsg, title=title, choices=choices) if choice != 'Exit': if choice == ylogstring: takestime = 'NA' realmainlog = None folder = diropenbox() if not folder: msgbox('please relaunch and open a directory.') exit() else: helper = utils(configpath='./') self.logger.logger.info('folder is ' + folder) matches = helper.findlogs(folder) ''' print matches import time time.sleep(50) ''' for index, filedict in enumerate(matches): #call the real parser self.curtimestamp = strftime("%Y_%m_%d_%H_%M_%S", gmtime()) mainlog = filedict['mainlog'] radiolog = filedict['radiolog'] kernellog = filedict['kernellog'] #actually mainlog will always exist #first of all , get radio log , if exist if not mainlog: continue self.logger.logger.info('mainlog is ' + mainlog) mainlogrealpath = os.path.realpath(mainlog) shortname = os.path.basename(mainlogrealpath) dirname = os.path.dirname(mainlogrealpath) outputdir = dirname + '/' + shortname.split('.')[0] self.utils.mkdirp(outputdir) if kernellog: print 'kernel log is ' + kernellog krealpath = os.path.realpath(kernellog) kshortname = os.path.basename(kernellog) kernel_results = parse_imsbr(krealpath) #FIXME: output imsbr log to diagrams kernel_outputdir = outputdir + '/diagrams/' self.utils.mkdirp(kernel_outputdir) imsbrlog = kernel_outputdir + '/' + kshortname.split( '.')[0] + '-imsbr.log' with open(imsbrlog, 'w') as imsbrlog: for dict in kernel_results: imsbrlog.write( "line%d: %s %s \n" % (dict["lineno"], dict["timestamp"], dict["msg"])) if radiolog: rp = radioParser(logname=radiolog, outputdir=outputdir) self.atmsgs = rp.getflow() rp.assembleStr() rp.drawAllDiag() realmainlog = mainlog #add other log's parsing, like crash #try to add crash log, crashlog = os.path.dirname(mainlog) + '/crash.log' crashp = crashParser(logname=crashlog) crashp.parselog() cmsgs = crashp.getmsgs() fp = flowParser(logname=mainlog, atmsgs=self.atmsgs, crashmsgs=cmsgs) len = fp.getFlow() self.msglen = len self.logger.logger.info('sip msgs len is ' + str(len)) #self.popupmsg(file) #msgbox(msg) #t = ThreadWithExc(target=self.popupthread,args=(currentfile,)) #t.start() fp.parseFlow() takestime = fp.drawAllDiag() if takestime == -1: self.logger.logger.info( 'exit the parser unexpectedly!') exit(-1) #fp.drawLemonDiag() #t.raiseExc(SystemExit) popupstr = '' filestr = '' if realmainlog: fsize = os.path.getsize(realmainlog) name = os.path.basename(realmainlog) filestr = "file is " + name + '\n' + "file size is " + str( self.utils.humansize(fsize)) + '\n' popupstr = "Finishing parsing\n" popupstr += filestr popupstr += "It takes " + takestime + " seconds" self.logger.logger.info(popupstr) msgbox(popupstr) elif choice == samsungfile: file = fileopenbox() if not file: msgbox('please relaunch and open a valid samsung log.') exit() else: sp = samsungParser(logname=file) sp.getflow() msgbox('Finish parsing file ' + file) else: return