From e841eacaa731ee9ca53ff9a2352c21402d5ae13a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 28 Mar 2010 00:38:15 -0400 Subject: [PATCH] Fix outdated log usage in EmailPlayer._log_part + broken email rendering from previous commit. --- README | 6 ++++-- pyrisk/player/email.py | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README b/README index 5269607..1a1e176 100644 --- a/README +++ b/README @@ -55,11 +55,13 @@ your game and go:: from pyrisk.base import generate_earth, Player, Engine from pyrisk.player.email import IncomingEmailDispatcher, \ OutgoingEmailDispatcher, EmailPlayer + from pyrisk.graphics import WorldRenderer world = generate_earth() ied = IncomingEmailDispatcher(fifo_path='/tmp/pyrisk.in') oed = OutgoingEmailDispatcher(return_address='server@example.com') - players = [EmailPlayer('Alice', 'alice@big.edu', ied, oed), - EmailPlayer('Bob', 'bob@fish.net', ied, oed), + wr = WorldRenderer() + players = [EmailPlayer('Alice', 'alice@big.edu', ied, oed, wr), + EmailPlayer('Bob', 'bob@fish.net', ied, oed, wr), Player('Charlie')] e = Engine(world, players) e.run() diff --git a/pyrisk/player/email.py b/pyrisk/player/email.py index 4feb957..b255aa7 100644 --- a/pyrisk/player/email.py +++ b/pyrisk/player/email.py @@ -32,7 +32,6 @@ import sys import tempfile from ..base import Player, PlayerError -from ..graphics import WorldRenderer # Configure alternative sendmail command in case smtplib is too @@ -271,17 +270,18 @@ class EmailPlayer (Player): else: body.append(' %s\t%s\t%d' % (terr, terr.player, terr.armies)) return encodedMIMEText('\n'.join(body), filename='world') - def _rendered_world_part(self, log, world): + def _rendered_world_part(self, world, log): start_event = log[0] players = start_event.players body = self.world_renderer.render(world, players) filename,subtype = \ self.world_renderer.filename_and_mime_image_type(world) part = MIMEImage(body, subtype) - part.add_header('Content-Disposition', 'attachment', filename) + part.add_header('Content-Disposition', 'attachment', filename=filename) return part def _log_part(self, log): - return encodedMIMEText('\n'.join(log), filename='log') + return encodedMIMEText('\n'.join([str(e) for e in log]), + filename='log') def report(self, world, log): """Send reports about death and game endings. -- 2.26.2