Fix outdated log usage in EmailPlayer._log_part + broken email rendering from previou...
authorW. Trevor King <wking@drexel.edu>
Sun, 28 Mar 2010 04:38:15 +0000 (00:38 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 28 Mar 2010 06:14:13 +0000 (02:14 -0400)
README
pyrisk/player/email.py

diff --git a/README b/README
index 5269607..1a1e176 100644 (file)
--- 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()
index 4feb957..b255aa7 100644 (file)
@@ -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.