From: W. Trevor King Date: Sun, 28 Mar 2010 04:38:15 +0000 (-0400) Subject: Fix outdated log usage in EmailPlayer._log_part + broken email rendering from previou... X-Git-Tag: 0.1~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e841eacaa731ee9ca53ff9a2352c21402d5ae13a;p=pyrisk.git Fix outdated log usage in EmailPlayer._log_part + broken email rendering from previous commit. --- 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.