-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
76 lines (67 loc) · 3.24 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys
from cli import run_cli
from gui import run_gui
def parse_arguments(args=None):
"""
Parse command-line arguments if provided. Return a dictionary of arguments.
"""
if args is None:
args = sys.argv[1:]
try:
import argparse
parser = argparse.ArgumentParser(description="Percona Installer Argument Parser")
parser.add_argument('-r', '--repository', type=str, help="release/testing/experimental")
parser.add_argument('-p', '--product', type=str, help="ppg-17.0/ps-80/pxc-80/psmdb-80")
parser.add_argument('-c', '--components', type=str, help="Comma-separated list of components")
parser.add_argument('-s', '--solution', type=str, help="pg_tde_demo")
parser.add_argument('--verbose', action='store_true', help="Enable verbose output")
parsed_args = parser.parse_args(args)
return vars(parsed_args)
except ImportError:
print("`argparse` module is not available. Running interactively...")
return None
def display_percona_ascii_art():
"""
Prints 'PERCONA' as ASCII art and provides a link to the support page and forum.
"""
ascii_art = r"""
██████╗ ███████╗██████╗ ██████╗ ██████ ███╗ ██╗ █████╗
██╔══██╗██╔════╝██╔══██╗██╔════╝ ██╔═██╗ ████╗ ██║██╔══██╗
██████╔╝█████╗ ██████╔╝██║ ██║ ██║ ██╔██╗ ██║███████║
██╔═══╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██║╚██╗██║██╔══██║
██║ ███████╗██║ ██║╚██████╗ ██████║ ██║ ╚████║██║ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝
"""
support_link = "For official support, visit: https://www.percona.com/services/support"
forum_link = "For community support, visit: https://forums.percona.com/"
print(ascii_art)
print(support_link)
print(forum_link)
def main():
"""
Main entry point for the installer.
"""
args = parse_arguments()
# If arguments are parsed but empty or invalid, fallback to interactive mode
if args and any(args.values()):
try:
run_cli(args)
display_percona_ascii_art()
except Exception as e:
print(f"Error in CLI mode: {e}")
sys.exit(1)
else:
# No arguments or invalid arguments: fallback to interactive mode
print("Welcome to the Percona Installer!")
print("1. CLI Mode")
print("2. GUI Mode (Console)")
choice = input("Select a mode (1 or 2): ").strip()
if choice == "1":
run_cli() # Interactive CLI mode
display_percona_ascii_art()
elif choice == "2":
run_gui()
else:
print("Invalid choice. Exiting.")
if __name__ == "__main__":
main()