19a84db5a3ab471e75e3f257b86c81e7fee4d51efsubrata_modak# -*- coding: utf-8 -*- 29a84db5a3ab471e75e3f257b86c81e7fee4d51efsubrata_modak 3d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak################################################################################ 4d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 5d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## Copyright © International Business Machines Corp., 2007, 2008 ## 6d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 7d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## This program is free software; you can redistribute it and#or modify ## 8d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## it under the terms of the GNU General Public License as published by ## 9d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## the Free Software Foundation; either version 2 of the License, or ## 10d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## (at your option) any later version. ## 11d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 12d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## This program is distributed in the hope that it will be useful, but ## 13d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 14d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 15d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## for more details. ## 16d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 17d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## You should have received a copy of the GNU General Public License ## 18d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## along with this program; if not, write to the Free Software ## 194548c6cf9bcdd96d8303caa4130ab638b61f8a30Wanlong Gao## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 20d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 21d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## NAME: parser.py ## 22d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 23d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## DESCRIPTION: Base class for all log parsers ## 24d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 25d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## AUTHOR: Chirag <chirag@linux.vnet.ibm.com ## 26d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak## ## 27d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak################################################################################ 28d93eb3eeece016658bce9504009c30b71458e34dsubrata_modak 29ff3936a916d119d020cc2ab8da22460a34fca612Anders Roxellimport sys 306acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak 316acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modakclass Log: 326acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak def __init__(self,filename): 336acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak if filename: 346acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak log_file=filename 356acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak try: 366acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak self.__log_file = open(log_file, "r") 376acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak except IOError, errmsg: 386acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak sys.exit(errmsg) 396acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak 406acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak def read(self): 416acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak for line in self.__log_file.read().split("\n"): 426acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak yield line 436acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak self.__log_file.close() 446acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak 456acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak def eval(self): 466acdc8efa73ceb0c3b515cd34c333d929e8b4273subrata_modak pass 47