From a8887898544d472a68936b2e6aa18dcaa48a4478 Mon Sep 17 00:00:00 2001 From: andreas Date: Thu, 21 Jul 2005 17:01:28 +0000 Subject: [PATCH] more python 2.1 fixes --- hbd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hbd b/hbd index 4d65546..19c8e86 100755 --- a/hbd +++ b/hbd @@ -1,5 +1,5 @@ #!/usr/bin/env python -# $Id: hbd,v 1.5 2005/07/21 16:04:56 andreas Exp $ +# $Id: hbd,v 1.6 2005/07/21 17:01:28 andreas Exp $ # Wait for heartbeat messages and act on them (or their absence) # import time, os, string, sys, socket, curses, atexit, select, SocketServer, getopt @@ -146,9 +146,8 @@ def initwin(): # # def checkoverdue(): - global hosts - for h in hosts: + for h in hosts.keys(): if hosts[h].state == Host.down: continue if reportstrict: @@ -167,7 +166,7 @@ def displaytime(): maxY,maxX=stdscr.getmaxyx() stdscr.addstr(0,maxX-8, time.strftime("%H:%M:%S", time.localtime(now)), curses.A_BOLD) - for h in hosts: + for h in hosts.keys(): d=hosts[h].getstate() attr=0 if verbose and hosts[h].state != Host.down: @@ -197,7 +196,7 @@ def displayaddr(h, refresh=1): # # def displaybody(): - for h in hosts: + for h in hosts.keys(): win.addstr(hosts[h].num+1, 1, "%-24s" % (h)) if hosts[h].addr != None: displayaddr(h, 0) @@ -314,7 +313,7 @@ def readsock(): def updatestats(): global upcount upcount+=1 - for h in hosts: + for h in hosts.keys(): if upcount > 0: hosts[h].uppercent="%3.0f" % ((hosts[h].upcount*hosts[h].interval*100.0)/(upcount*interval)) # @@ -382,7 +381,7 @@ class HtmlHandler(SocketServer.BaseRequestHandler): res.append("

Heartbeat status at %s

" % time.strftime("%H:%M:%S", time.localtime(now))) res.append("") res.append("\n" ) - for h in hosts: + for h in hosts.keys(): res.append("\n" % (h, hosts[h].state, hosts[h].addr, hosts[h].uppercent, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(hosts[h].statetime)))) res.append("
HostStateIP AddrResLast change
%-24s%-7s%-16s%-3s%-17s
") res.append("

")