in bootstrap.py [0:0]
def main(args):
print(get_distro())
binaries = []
try:
local_repo = args.mirror if args.mirror else find_closest_mirror()
print(local_repo)
host, dir = local_repo.replace('ftp://', '').split('/', 1)
latest_release, binaries = get_release_and_binaries_from_ftp(host, dir, args.version if args.version else None)
except Exception:
print("Failed to get binaries from Apache mirror")
return -1
matching_binaries = []
for binary in binaries:
distro, release = mapped_distro()
if release and release in binary:
matching_binaries.append(binary)
elif distro and distro in binary:
matching_binaries.append(binary)
if not matching_binaries:
print("No compatible binary found, MiNiFi needs to be compiled locally")
return 1
invalid_input = True
download = None
selected_binary = None
if len(matching_binaries) == 1:
print("A binary in Apache repo seems to match your system: " + matching_binaries[0])
while invalid_input:
try:
download = strtobool(input("Would you like to download? [y/n]"))
invalid_input = False
if download:
selected_binary = matching_binaries[0]
except Exception:
pass
else:
print("The following binaries in Apache repo seem to match your system: ")
for i, item in enumerate(matching_binaries):
print(str(i + 1) + " - " + item)
print()
while invalid_input:
try:
user_input = input("Please select one to download (1 to " + str(len(matching_binaries)) + ") or \"s\" to skip and compile locally\n")
user_input.lower()
if user_input == "s":
invalid_input = False
download = False
break
idx = int(user_input) - 1
if (idx < 0):
continue
selected_binary = matching_binaries[idx]
download = True
invalid_input = False
except Exception:
pass
if not download:
return 1
if not download_binary_from_ftp(host, dir, latest_release, selected_binary):
return -1
try:
with tarfile.open(os.path.join(os.getcwd(), selected_binary), "r:gz") as tar:
tar.extractall()
except Exception:
print("Failed to extract tar file")
return -1
print("Successfully downloaded and extracted MiNiFi")
return 0