kvm-test: don't execute code if module is imported

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-04-27 19:55:55 +02:00
parent 9ad7ff2747
commit 83dacb8c7c
1 changed files with 21 additions and 15 deletions

View File

@ -456,21 +456,27 @@ def help():
sys.exit(1)
try:
def main() -> None:
""" Entry point. """
try:
ctx = parse_args()
except TypeError:
except TypeError:
help()
if ctx.args.base and ctx.args.build:
if ctx.args.base and ctx.args.build:
raise Exception('cannot use base iso and build')
os.makedirs('/tmp/kvm-test', exist_ok=True)
os.makedirs('/tmp/kvm-test', exist_ok=True)
if ctx.args.build:
if ctx.args.build:
build(ctx)
if ctx.args.install:
if ctx.args.install:
install(ctx)
if ctx.args.boot:
if ctx.args.boot:
boot(ctx)
if True not in (ctx.args.build, ctx.args.install, ctx.args.boot):
if True not in (ctx.args.build, ctx.args.install, ctx.args.boot):
parser.print_help()
if __name__ == "__main__":
main()