From d5eec1ef2fe76175294038cfd277b8bd2a8197e0 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 1 Nov 2009 11:15:37 +0000 Subject: [PATCH] Correct HTML generation (not finished) --- Src/network-broker/network-broker | 5 ++++- Src/network-broker/stats.py | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Src/network-broker/network-broker b/Src/network-broker/network-broker index 71cf4d1..423e52e 100755 --- a/Src/network-broker/network-broker +++ b/Src/network-broker/network-broker @@ -261,8 +261,10 @@ class Peer: self.srv.log_connection(self.name, self.country) try: - which = random.randrange(0,10) + # Save as one of the last few screenshots + which = random.randrange(0,12) img = image.image_from_data(self.screenshot) + print "Saving", which img.save("%s%d.png" % (self.srv.image_dir, which)) except Exception, e: log_info("Could not convert image data" + str(e)) @@ -459,6 +461,7 @@ if __name__ == "__main__": if len(sys.argv) != 4: usage() + random.seed(time.time()) ip2c = ip2country.IP2Country(verbose=0) syslog.openlog("frodo") diff --git a/Src/network-broker/stats.py b/Src/network-broker/stats.py index 1477184..b298484 100644 --- a/Src/network-broker/stats.py +++ b/Src/network-broker/stats.py @@ -41,11 +41,22 @@ class HtmlGenerator: outf.write("\n") outf.write("

Frodo-Wii network statistics

\n") outf.write("The total number of connections is %d
\n" % (self.container.total_connections)) - outf.write("

Last %d connections

\n" % (len(self.container.last_10)) ) - for item in self.container.last_10: - outf.write("%s
\n" % (item) ) + outf.write("\n") + outf.write("\n" % + (len(self.container.last_10)) ) - outf.write("

Country list

\n") + cnt = 0 + for item in self.container.last_10: + images = "" + if cnt % 4 == 0: + cur = cnt + images = "" % (cur, cur + 1, cur + 2, cur + 3) + outf.write("%s\n" % (item, images) ) + cnt = cnt + 1 + outf.write("

Last %d connections

Random screenshots

%s
\n") + + outf.write("\n") + outf.write("\n") count = 1 for country, num in sorted_countries: outf.write("%3d. %s (%d)
\n" % (count, country, num) )

Country list