mail[Wesnoth-commits] r29056 - in /trunk/data/tools/wesnoth: campaignserver_client.py wmlparser.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by elias on August 28, 2008 - 19:24:
Author: elias
Date: Thu Aug 28 19:24:02 2008
New Revision: 29056

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29056&view=rev
Log:
- Adjusted campaignserver_client.py for upstream fix of random 0 bytes.
- Don't stop downloading on addons which contain files without any contents.

Modified:
    trunk/data/tools/wesnoth/campaignserver_client.py
    trunk/data/tools/wesnoth/wmlparser.py

Modified: trunk/data/tools/wesnoth/campaignserver_client.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/campaignserver_client.py?rev=29056&r1=29055&r2=29056&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/campaignserver_client.py (original)
+++ trunk/data/tools/wesnoth/campaignserver_client.py Thu Aug 28 19:24:02 2008
@@ -105,11 +105,10 @@
         z.close()
         zdata = io.getvalue()
 
-        # Wesnoth expects a 0 byte after each packet (according to suokko)
-        zpacket = struct.pack("!i", len(zdata) + 1) + zdata + "\0"
+        zpacket = struct.pack("!i", len(zdata)) + zdata
         self.sock.sendall(zpacket)
 
-    def read_packet(self, skip_last_0_hack = True):
+    def read_packet(self):
         """
         Read binary data from the server.
         """
@@ -130,12 +129,6 @@
         global dumpi
         dumpi += 1
         open("dump%d" % dumpi, "wb").write(packet)
-
-        # There's a bug in the C++ code, so sometimes a 0 byte is sent.
-        if skip_last_0_hack:
-            packet = packet[:-1]
-        else:
-            self.sock.recv(1)
 
         if packet.startswith("\x1F\x8B"):
             sys.stderr.write("GZIP compression found...\n")
@@ -368,7 +361,7 @@
         request = wmldata.DataSub("request_campaign")
         request.insert(wmldata.DataText("name", name))
         self.send_packet(self.makePacket(request))
-        raw_packet = self.read_packet(skip_last_0_hack = False)
+        raw_packet = self.read_packet()
 
         if self.canceled:
             return None
@@ -523,7 +516,13 @@
             pass
         for f in data.get_all("file"):
             name = f.get_text_val("name", "?")
-            contents = f.get_text("contents").get_value()
+            contents = f.get_text("contents")
+            if not contents:
+                contents = ""
+                sys.stderr.write("File %s is empty.\n" % name)
+                sys.stderr.write(f.debug(write = False) + "\n")
+            if contents:
+                contents = contents.get_value()
             if verbose:
                 print i * " " + name + " (" +\
                       str(len(contents)) + ")"

Modified: trunk/data/tools/wesnoth/wmlparser.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmlparser.py?rev=29056&r1=29055&r2=29056&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmlparser.py (original)
+++ trunk/data/tools/wesnoth/wmlparser.py Thu Aug 28 19:24:02 2008
@@ -494,7 +494,7 @@
             if self.macro_not_found_callback:
                 keep_macro = self.macro_not_found_callback(self, name, 
params)
                 if keep_macro: return keep_macro
-            sys.stderr.write("No macro %s.\n" % name)
+            sys.stderr.write("No macro %s.\n" % name.encode("utf8"))
             if self.verbose:
                 sys.stderr.write(" (%s:%d)\n" % (self.filename, self.line))
             return name




Related Messages


Powered by MHonArc, Updated Thu Aug 28 19:41:03 2008