Enable uploads of new-style campaigns.
This commit is contained in:
parent
1d1e49fb5b
commit
1312c5187e
2 changed files with 20 additions and 8 deletions
|
@ -319,7 +319,10 @@ class CampaignClient:
|
|||
data.insert(sub)
|
||||
return data
|
||||
|
||||
data.insert(put_file(name + ".cfg", file(cfgfile)))
|
||||
# Only used if it's an old-style campaign directory
|
||||
# with an external config.
|
||||
if os.path.exists(cfgfile):
|
||||
data.insert(put_file(name + ".cfg", file(cfgfile)))
|
||||
data.insert(put_dir(name, directory))
|
||||
request.insert(data)
|
||||
|
||||
|
|
|
@ -40,8 +40,11 @@ if __name__ == "__main__":
|
|||
"(specify the path where to put it with -c, " +
|
||||
"current directory will be used by default)")
|
||||
optionparser.add_option("-u", "--upload",
|
||||
help = "upload campaign " +
|
||||
"(UPLOAD specifies the path to the .pbl file)")
|
||||
help = "Upload campaign. " +
|
||||
"UPLOAD should be either the name of a campaign subdirectory," +
|
||||
"(in which case the client looks for _server.pbl beneath it) " +
|
||||
"or a path to the .pbl file (in which case the name of the " +
|
||||
"campaign subdirectory is the basename of the path with .pbl removed)")
|
||||
optionparser.add_option("-s", "--status",
|
||||
help = "Display the status of addons installed in the given " +
|
||||
"directory.")
|
||||
|
@ -196,9 +199,16 @@ if __name__ == "__main__":
|
|||
print message.get_text_val("message")
|
||||
elif options.upload:
|
||||
cs = CampaignClient(address)
|
||||
pbl = wmldata.read_file(options.upload, "PBL")
|
||||
name = os.path.basename(options.upload)
|
||||
name = os.path.splitext(name)[0]
|
||||
if os.path.isdir(os.path.join(options.campaigns_dir, options.upload)): # New style with _server.pbl
|
||||
pblfile = os.path.join(options.campaigns_dir, options.upload, "_server.pbl")
|
||||
name = os.path.basename(options.upload)
|
||||
wmldir = os.path.join(options.campaigns_dir, name)
|
||||
else: # Old style with external .pbl file
|
||||
pblfile = options.upload
|
||||
name = os.path.basename(options.upload)
|
||||
name = os.path.splitext(name)[0]
|
||||
wmldir = os.path.join(os.path.dirname(options.upload), name)
|
||||
pbl = wmldata.read_file(pblfile, "PBL")
|
||||
mythread = cs.put_campaign_async(
|
||||
pbl.get_text_val("title"),
|
||||
name,
|
||||
|
@ -208,8 +218,7 @@ if __name__ == "__main__":
|
|||
pbl.get_text_val("version"),
|
||||
pbl.get_text_val("icon"),
|
||||
options.upload.replace(".pbl", ".cfg"),
|
||||
os.path.join(os.path.dirname(options.upload), name)
|
||||
)
|
||||
wmldir)
|
||||
while not mythread.event.isSet():
|
||||
mythread.event.wait(1)
|
||||
print "%d/%d" % (cs.counter, cs.length)
|
||||
|
|
Loading…
Add table
Reference in a new issue