print usage on no arguments - graceful handle CTRL+C
This commit is contained in:
parent
51d5517f6f
commit
9cb68feb9d
1 changed files with 17 additions and 7 deletions
24
get-iso
24
get-iso
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# @linux-aarhus - root.nix.dk
|
||||
# License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/gpl.html
|
||||
# License: GNU GPL, version 3 or later; https://www.gnu.org/licenses/gpl.html
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -14,6 +14,9 @@ from pathlib import Path
|
|||
|
||||
DEF_URL = "https://gitlab.manjaro.org/webpage/iso-info/-/raw/master/file-info.json"
|
||||
FOLDER = Path.home()
|
||||
PROG_NAME = os.path.basename(__file__)
|
||||
PROG_VERSION = "0.1"
|
||||
GNU_URL = "https://www.gnu.org/licenses/gpl.html"
|
||||
|
||||
|
||||
def download_file(url: str, folder_name: str) -> bool:
|
||||
|
@ -85,17 +88,15 @@ def download(url: str) -> bool:
|
|||
return success
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
prog_name = os.path.basename(__file__)
|
||||
prog_version = "0.1"
|
||||
def main():
|
||||
iso_files = init_iso_list(DEF_URL)
|
||||
choices = []
|
||||
for c in iso_files:
|
||||
choices.append(c["name"])
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=f"{prog_name}",
|
||||
prog=f"{PROG_NAME}",
|
||||
description="This tool will download a named Manjaro ISO and verify the signature",
|
||||
epilog=f"{prog_name} version {prog_version} - License GPL v3 or later")
|
||||
epilog=f"{PROG_NAME} v. {PROG_VERSION} - GPL v3 or later <{GNU_URL}>")
|
||||
parser.add_argument("edition",
|
||||
type=str,
|
||||
help="edition e.g. plasma or xfce",
|
||||
|
@ -105,7 +106,8 @@ if __name__ == '__main__':
|
|||
action="store_true",
|
||||
help="Download full ISO")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.edition is None:
|
||||
parser.print_usage()
|
||||
edition = [x for x in iso_files if args.edition == x["name"]]
|
||||
for x in edition:
|
||||
if args.full:
|
||||
|
@ -124,3 +126,11 @@ if __name__ == '__main__':
|
|||
print("Download ISO failed")
|
||||
sys.exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print("\n" + "Exit: interrupted by the user.")
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in a new issue