[KERNEL][TEST] Inform about required packages

git-svn-id: svn://kolibrios.org@9310 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Magomed Kostoev (mkostoevr) 2021-11-25 20:26:22 +00:00
parent a0253bc1a6
commit 2510534664

View File

@ -6,6 +6,7 @@
import os import os
import sys import sys
from importlib.machinery import SourceFileLoader from importlib.machinery import SourceFileLoader
from shutil import which
import timeit import timeit
import urllib.request import urllib.request
import subprocess import subprocess
@ -31,6 +32,53 @@ def stage(name, command, mute = False):
execute(command, mute = mute) execute(command, mute = mute)
print("Done.") print("Done.")
def tool_exists(name):
assert(type(name) == str)
return which(name) != None
def check_tools(tools):
assert(type(tools) == tuple)
for name_package_pair in tools:
assert(type(name_package_pair) == tuple)
assert(len(name_package_pair) == 2)
assert(type(name_package_pair[0]) == str)
assert(type(name_package_pair[1]) == str)
not_exists = []
for name, package in tools:
if not tool_exists(name):
not_exists.append((name, package))
if len(not_exists) != 0:
log("Sorry, I can't find some tools:")
max_name_len = len("name")
max_package_name_len = len("package")
for name, package in not_exists:
if len(package) > max_package_name_len:
max_package_name_len = len(package)
if len(name) > max_name_len:
max_name_len = len(name)
def draw_row(name, package):
log(f" | {name.ljust(max_name_len)} | {package.ljust(max_package_name_len)} |")
def draw_line():
log(f" +-{'-' * max_name_len}-+-{'-' * max_package_name_len}-+")
draw_line()
draw_row("Name", "Package")
draw_line()
for name, package in not_exists:
draw_row(name, package)
draw_line()
exit()
# Check available tools
tools = (("mcopy", "mtools"),
("qemu-system-i386", "qemu-system-x86"),
("wget", "wget"))
check_tools(tools)
# Get IMG # Get IMG
if not os.path.exists("kolibri_test.img"): if not os.path.exists("kolibri_test.img"):
if len(sys.argv) == 1: if len(sys.argv) == 1: