- # import the Webstats package
- import webstats, webprocessor
- ####################################################################
- # create a subclass of WebStatistic
- class TestStat(webstats.WebStatistic):
- def __init__(self):
- self.id = 1
- self.counter = 0
- self.times = []
- self.unique = {}
- def addSession(self, session):
- for e in session:
- self.times.append(e.date)
- self.unique[e.date] = 1
- self.counter += len(session)
- def finish(self):
- line_parser = webprocessor.BaseLogEntryParser([webprocessor.LFE_REMOTE_HOST,
- webprocessor.LFE_RFC1413,
- webprocessor.LFE_USERID,
- webprocessor.LFE_DATE,
- webprocessor.LFE_URL,
- "uname",
- webprocessor.LFE_STATUS,
- webprocessor.LFE_SIZE,
- webprocessor.LFE_REFERRED,
- webprocessor.LFE_USER_INFO],
- separator = "|")
- f = file('combined.ppstat')
- line_count = 1
- print "Entries ignored by webprocessor:"
- print "line# url"
- print "--------------------------------------------------------------------
- for l in f.readlines():
- entry = line_parser.parseLine(l.strip())
- if entry.date not in self.times:
- print line_count, " ", entry.url
- line_count += 1
- print "# of requests found by webprocessor: ", self.counter
- print "true requests: ", (line_counter-1)
- ####################################################################
- # create a subclass of WebStatistic
- ## class Stat2(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 2
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat3(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 3
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat4(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 4
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat5(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 5
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat6(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 6
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat7(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 7
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat8(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 8
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat9(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 9
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat10(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 10
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
- ## ####################################################################
- ## # create a subclass of WebStatistic
- ## class Stat11(webstats.WebStatistic):
- ## def __init__(self):
- ## self.id = 11
- ## print self.id, ": __init__ called."
- ## # This method has to be overridden by subclasses.
- ## # It takes a user session as an entry. Based
- ## # on this the subclass can calculate the desired statistic.
- ## def addSession(self, session):
- ## print self.id, ": addSession called."
- ## # When all session are processes this class is to be
- ## # called to finalize the calculation of the statistic.
- ## def finish(self):
- ## print self.id, ": finish called."
Raw Paste