Switched to api
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
d5471dacf5
commit
f113d3e779
2 changed files with 20 additions and 11 deletions
|
@ -18,10 +18,10 @@
|
||||||
import socket
|
import socket
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from common import send_status, get_status
|
from common import api_send_status, api_get_status
|
||||||
|
|
||||||
host = socket.gethostname()
|
api = None
|
||||||
port = 12345
|
api_token = None
|
||||||
tile = ""
|
tile = ""
|
||||||
status = ""
|
status = ""
|
||||||
verbose = False
|
verbose = False
|
||||||
|
@ -30,12 +30,12 @@ argc = len(sys.argv)
|
||||||
first = True
|
first = True
|
||||||
i = 1
|
i = 1
|
||||||
while i < argc:
|
while i < argc:
|
||||||
if sys.argv[i] == "--port":
|
if sys.argv[i] == "-a" or sys.argv[i] == "--api":
|
||||||
i += 1
|
i += 1
|
||||||
port = int(sys.argv[i])
|
api = sys.argv[i]
|
||||||
elif sys.argv[i] == "--host":
|
elif sys.argv[i] == "-t" or sys.argv[i] == "--api-token":
|
||||||
i += 1
|
i += 1
|
||||||
host = sys.argv[i]
|
api_token = sys.argv[i]
|
||||||
elif sys.argv[i] == "-v" or sys.argv[i] == "--verbose":
|
elif sys.argv[i] == "-v" or sys.argv[i] == "--verbose":
|
||||||
verbose = True
|
verbose = True
|
||||||
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
|
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
|
||||||
|
@ -44,8 +44,8 @@ while i < argc:
|
||||||
print("")
|
print("")
|
||||||
print(" <file> Terrasync log file")
|
print(" <file> Terrasync log file")
|
||||||
print("OPTIONS")
|
print("OPTIONS")
|
||||||
print(" , --host Manager host")
|
print(" -a, --api Manager api url")
|
||||||
print(" , --port Manager port")
|
print(" -t, --api-token Manager api token")
|
||||||
print(" -v, --verbose Verbose printouts")
|
print(" -v, --verbose Verbose printouts")
|
||||||
print(" -h, --help Shows this help and exit")
|
print(" -h, --help Shows this help and exit")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -61,6 +61,14 @@ if lfile == "":
|
||||||
print("ERROR: No file given")
|
print("ERROR: No file given")
|
||||||
sys.exit(1)
|
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:
|
try:
|
||||||
tiles = []
|
tiles = []
|
||||||
with open(lfile) as f:
|
with open(lfile) as f:
|
||||||
|
@ -75,10 +83,10 @@ except IOError:
|
||||||
tiles = set(tiles)
|
tiles = set(tiles)
|
||||||
|
|
||||||
for tile in 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 status == "done" or status == "packaged":
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Flagging " + tile)
|
print("Flagging " + tile)
|
||||||
send_status(tile, "rebuild", host, port)
|
api_send_status(tile, "rebuild", api, api_token)
|
||||||
elif verbose:
|
elif verbose:
|
||||||
print("Skipping " + tile + ". Not yet build")
|
print("Skipping " + tile + ". Not yet build")
|
||||||
|
|
|
@ -82,6 +82,7 @@ if not api:
|
||||||
|
|
||||||
if not api_token:
|
if not api_token:
|
||||||
print("ERROR: No api token given")
|
print("ERROR: No api token given")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def get_sha1(fname):
|
def get_sha1(fname):
|
||||||
if os.path.isfile(fname):
|
if os.path.isfile(fname):
|
||||||
|
|
Loading…
Reference in a new issue