Added api support to packager
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
8450b7ae81
commit
d379ffe25d
1 changed files with 26 additions and 7 deletions
|
@ -27,6 +27,8 @@ from common import norm, send_status, get_job
|
||||||
|
|
||||||
host = socket.gethostname()
|
host = socket.gethostname()
|
||||||
port = 12345
|
port = 12345
|
||||||
|
api = None
|
||||||
|
api_token = None
|
||||||
output = ""
|
output = ""
|
||||||
|
|
||||||
argc = len(sys.argv)
|
argc = len(sys.argv)
|
||||||
|
@ -42,14 +44,22 @@ while i < argc:
|
||||||
elif sys.argv[i] == "-o" or sys.argv[i] == "--output":
|
elif sys.argv[i] == "-o" or sys.argv[i] == "--output":
|
||||||
i += 1
|
i += 1
|
||||||
output = sys.argv[i]
|
output = sys.argv[i]
|
||||||
|
elif sys.argv[i] == "-a" or sys.argv[i] == "--api":
|
||||||
|
i += 1
|
||||||
|
api = sys.argv[i]
|
||||||
|
elif sys.argv[i] == "-t" or sys.argv[i] == "--api-token":
|
||||||
|
i += 1
|
||||||
|
api_token = sys.argv[i]
|
||||||
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
|
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
|
||||||
print("usage: worldbuild-packager.py [OPTIONS]")
|
print("usage: worldbuild-packager.py [OPTIONS]")
|
||||||
print("Retrives done tiles from the manager and packages them")
|
print("Retrives done tiles from the manager and packages them")
|
||||||
print("")
|
print("")
|
||||||
print(" -o, --output Output directory. Path MUST be absolute")
|
print(" -o, --output Output directory. Path MUST be absolute")
|
||||||
print(" --host Manager host")
|
print(" --host Manager host")
|
||||||
print(" --port Manager port")
|
print(" --port Manager port")
|
||||||
print(" -h, --help Shows this help and exit")
|
print(" -a, --api Manager api url")
|
||||||
|
print(" -t, --api-token Manager api token")
|
||||||
|
print(" -h, --help Shows this help and exit")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
if first == 1:
|
if first == 1:
|
||||||
|
@ -136,7 +146,10 @@ while running:
|
||||||
try:
|
try:
|
||||||
name = "None"
|
name = "None"
|
||||||
while name == "None":
|
while name == "None":
|
||||||
name = get_job("done", host, port, none_exit=False)
|
if api == None:
|
||||||
|
name = get_job("done", host, port, none_exit=False)
|
||||||
|
else:
|
||||||
|
name = api_get_job("done", api, token, none_exit=False)
|
||||||
if name == "None":
|
if name == "None":
|
||||||
print("No job got asigned. Trying again in one hour.")
|
print("No job got asigned. Trying again in one hour.")
|
||||||
sleep(3600)
|
sleep(3600)
|
||||||
|
@ -176,7 +189,10 @@ while running:
|
||||||
|
|
||||||
print("Packaging " + name + " done")
|
print("Packaging " + name + " done")
|
||||||
|
|
||||||
send_status(name, "packaged", host, port)
|
if api == None:
|
||||||
|
send_status(name, "packaged", host, port)
|
||||||
|
else:
|
||||||
|
api_send_status(name, "packaged", api, token)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Graceful shutdown triggered. To force immedate stop, press Ctrl+C again")
|
print("Graceful shutdown triggered. To force immedate stop, press Ctrl+C again")
|
||||||
|
@ -184,7 +200,10 @@ while running:
|
||||||
try:
|
try:
|
||||||
package.wait()
|
package.wait()
|
||||||
update_index(output, name, name_major)
|
update_index(output, name, name_major)
|
||||||
send_status(name, "packaged")
|
if api == None:
|
||||||
|
send_status(name, "packaged", host, port)
|
||||||
|
else:
|
||||||
|
api_send_status(name, "packaged", api, token)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# TODO doesn't work
|
# TODO doesn't work
|
||||||
print("Forcing shutdown...")
|
print("Forcing shutdown...")
|
||||||
|
|
Loading…
Reference in a new issue