From f940691edfca5980b6e5a5e4db6fb4ce64918621 Mon Sep 17 00:00:00 2001 From: shnavid Date: Thu, 9 Aug 2007 20:03:14 +0000 Subject: slowly making it work.. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@347 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/extras/htmlog | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extras/htmlog b/src/extras/htmlog index 047a70d3..1fbab8bb 100755 --- a/src/extras/htmlog +++ b/src/extras/htmlog @@ -38,10 +38,13 @@ class host_class: def tell(self): sumsize = 0 if self.log_idx > 0: - for inc in range(0, self.log_idx - 1): + for inc in range(0, self.log_idx): sumsize += self.logs[inc].size() - return sumsize + self.logs[self.log_idx].fp.tell() - return toret + try: + sumsize += self.fp().tell() + except TypeError: + pass + return sumsize def size(self): sumsize = 0 @@ -51,6 +54,7 @@ class host_class: def eof(self): if self.tell() >= self.size(): + sys.exit("HOST IS EOF") return True return False @@ -74,7 +78,7 @@ class host_class: try: toret = time.strptime(self.readline()[0:15], "%b %d %H:%M:%S") except ValueError: - return None + toret = None self.seek(pos) return toret @@ -83,12 +87,23 @@ class host_class: def readline(self): if self.eof(): - return None + return "" while True: toret = self.fp().readline() + if len(toret) == 0: + if self.log_idx < len(self.logs): + self.log_idx += 1 + self.fp().seek(0) + continue + else: + sys.exit("HOST IS EOF") + return "" + if self.validate_line(toret) or toret == "": return toret + else: + print "invalid line" def validate_line(self, line): try: @@ -138,6 +153,9 @@ class logfile_class: def seek(self,pos): self.fp.seek(pos) + def tell(self): + return self.fp.tell() + def parse(self): self.seek(0) while not self.eof: @@ -187,6 +205,16 @@ for logname in __cmdLineOpts__.logfiles: hosts[log.hostname] = host_class() hosts[log.hostname].add_log(log) +#print hosts["moka"].readline() +#print hosts["moka"].readline() +#print "DIRECT", hosts["moka"].fp().fp.tell() +#print "HOST TELL", hosts["moka"].tell() +#print hosts["moka"].readline() +#print hosts["moka"].time() +#print hosts["moka"].readline() +#print hosts["moka"].time() +#print hosts["moka"].readline() + print """ -- cgit