Back-ported wesnoth_addons_manager updates to campaigns_client.py.
This commit is contained in:
parent
b2ca482166
commit
0903427cbf
2 changed files with 23 additions and 4 deletions
|
@ -18,7 +18,7 @@ if __name__ == "__main__":
|
|||
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 @@ if __name__ == "__main__":
|
|||
"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 @@ if __name__ == "__main__":
|
|||
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 @@ if __name__ == "__main__":
|
|||
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 @@ if __name__ == "__main__":
|
|||
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:
|
||||
|
|
|
@ -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 @@ Select the add-on you want to install from the list and click "OK". The download
|
|||
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")))
|
||||
|
|
Loading…
Add table
Reference in a new issue