Author: elias
Date: Thu Oct  9 21:25:35 2008
New Revision: 29983

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29983&view=rev
Log:
Back-ported wesnoth_addons_manager updates to campaigns_client.py.

Modified:
    branches/1.4/utils/campaigns_client.py
    branches/1.4/utils/campaigns_client/html.py

Modified: branches/1.4/utils/campaigns_client.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/utils/campaigns_client.py?rev=29983&r1=29982&r2=29983&view=diff
==============================================================================
--- branches/1.4/utils/campaigns_client.py (original)
+++ branches/1.4/utils/campaigns_client.py Thu Oct  9 21:25:35 2008
@@ -18,7 +18,7 @@
     optionparser.add_option("-a", "--address", help = "specify server address",
         default = "add-ons.wesnoth.org")
     optionparser.add_option("--html",
-        help = "Output HTML overview into the givendirectory.",)
+        help = "Output a HTML overview into the given directory.",)
     optionparser.add_option("-p", "--port",
         help = "specify server port or BfW version (%s)" % " or ".join(
         map(lambda x: x[1], CampaignClient.portmap)),
@@ -41,6 +41,9 @@
         "name may be a Python regexp matched against all campaign names " +
         "(specify the path where to put it with -c, " +
         "current directory will be used by default)")
+    optionparser.add_option("-t", "--tar", action = "store_true",
+        help = "When used together with --download, create tarballs of any " +
+        "downloaded addons.")
     optionparser.add_option("-u", "--upload",
         help = "Upload campaign. " +
         "UPLOAD should be either the name of a campaign subdirectory," +
@@ -67,6 +70,9 @@
     optionparser.add_option("-R", "--raw-download",
         action = "store_true",
         help = "download as a binary WML packet")
+    optionparser.add_option("--url", help = "When used with --html, " +
+        "a download link will be added for each campaign, with the given " +
+        "base URL.")
     optionparser.add_option("-U", "--unpack",
         help = "unpack the file UNPACK as a binary WML packet " +
         "(specify the campaign path with -c)")
@@ -113,6 +119,13 @@
             for message in mythread.data.find_all("message", "error"):
                 print message.get_text_val("message")
 
+            if options.tar:
+                tarname = cdir + "/" + name + ".tar.bz2"
+                if options.verbose:
+                    sys.stderr.write("Creating tarball %(tarname)s.\n" %
+                        locals())
+                os.system("tar cjf %(tarname)s %(dirname)s" % locals())
+
     def get_info(name):
         """
         Get info for a locally installed campaign. It expects a direct path
@@ -132,7 +145,7 @@
         data = cs.list_campaigns()
         if data:
             import campaigns_client.html
-            campaigns_client.html.output(options.html, data)
+            campaigns_client.html.output(options.html, options.url, data)
         else:
             sys.stderr.write("Could not connect.\n")
     elif options.list:

Modified: branches/1.4/utils/campaigns_client/html.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/utils/campaigns_client/html.py?rev=29983&r1=29982&r2=29983&view=diff
==============================================================================
--- branches/1.4/utils/campaigns_client/html.py (original)
+++ branches/1.4/utils/campaigns_client/html.py Thu Oct  9 21:25:35 2008
@@ -1,6 +1,6 @@
 import time, os, glob, sys
 
-def output(path, data):
+def output(path, url, data):
     try: os.mkdir(path)
     except OSError: pass
 
@@ -74,7 +74,13 @@
         w("<td><b>%s</b><br/>" % name)
         w("Version: %s<br/>" % v("version", "unknown"))
         w("Author: %s</td>" % v("author", "unknown"))
-        w("<td>%.1fMB</td>" % (float(v("size", "unknown")) / 1024 / 1024))
+        MB = 1024 * 1024
+        w("<td>%.2fMB" % (float(v("size", "unknown")) / MB))
+        if url:
+            link = url.rstrip("/") + "/" + v("name") + ".tar.bz2"
+            w("<br/><a href=\"%s\">download</a></td>" % link)
+        else:
+            w("</td>")
         w("<td><b>%s</b> down<br/>" % v("downloads", "unknown"))
         w("%s up</td>" % v("uploads", "unknown"))
         t = time.localtime(int(v("timestamp", "unknown")))


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to