kvm-test: don't execute code if module is imported
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
9ad7ff2747
commit
83dacb8c7c
|
@ -456,21 +456,27 @@ def help():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
try:
|
def main() -> None:
|
||||||
ctx = parse_args()
|
""" Entry point. """
|
||||||
except TypeError:
|
try:
|
||||||
help()
|
ctx = parse_args()
|
||||||
|
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')
|
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)
|
build(ctx)
|
||||||
if ctx.args.install:
|
if ctx.args.install:
|
||||||
install(ctx)
|
install(ctx)
|
||||||
if ctx.args.boot:
|
if ctx.args.boot:
|
||||||
boot(ctx)
|
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()
|
parser.print_help()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue