diff --git a/flag-rebuild.py b/flag-rebuild.py index c74b3a7..35a550c 100755 --- a/flag-rebuild.py +++ b/flag-rebuild.py @@ -18,10 +18,10 @@ import socket import re import sys -from common import send_status, get_status +from common import api_send_status, api_get_status -host = socket.gethostname() -port = 12345 +api = None +api_token = None tile = "" status = "" verbose = False @@ -30,12 +30,12 @@ argc = len(sys.argv) first = True i = 1 while i < argc: - if sys.argv[i] == "--port": + if sys.argv[i] == "-a" or sys.argv[i] == "--api": i += 1 - port = int(sys.argv[i]) - elif sys.argv[i] == "--host": + api = sys.argv[i] + elif sys.argv[i] == "-t" or sys.argv[i] == "--api-token": i += 1 - host = sys.argv[i] + api_token = sys.argv[i] elif sys.argv[i] == "-v" or sys.argv[i] == "--verbose": verbose = True elif sys.argv[i] == "-h" or sys.argv[i] == "--help": @@ -44,8 +44,8 @@ while i < argc: print("") print(" Terrasync log file") print("OPTIONS") - print(" , --host Manager host") - print(" , --port Manager port") + print(" -a, --api Manager api url") + print(" -t, --api-token Manager api token") print(" -v, --verbose Verbose printouts") print(" -h, --help Shows this help and exit") sys.exit(0) @@ -61,6 +61,14 @@ if lfile == "": print("ERROR: No file given") sys.exit(1) +if not api: + print("ERROR: No api given") + sys.exit(1) + +if not api_token: + print("ERROR: No api token given") + sys.exit(1) + try: tiles = [] with open(lfile) as f: @@ -75,10 +83,10 @@ except IOError: tiles = set(tiles) for tile in tiles: - status = get_status(tile, host, port) + status = api_get_status(tile, api, api_token) if status == "done" or status == "packaged": if verbose: print("Flagging " + tile) - send_status(tile, "rebuild", host, port) + api_send_status(tile, "rebuild", api, api_token) elif verbose: print("Skipping " + tile + ". Not yet build") diff --git a/worldbuild-packager.py b/worldbuild-packager.py index 819f937..b376bea 100755 --- a/worldbuild-packager.py +++ b/worldbuild-packager.py @@ -82,6 +82,7 @@ if not api: if not api_token: print("ERROR: No api token given") + sys.exit(1) def get_sha1(fname): if os.path.isfile(fname):