Exception handling on printing the banner

This commit is contained in:
Micah Lee 2021-11-15 18:16:10 -08:00
parent a4db0d26c9
commit 267e9eb1e4
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -87,197 +87,206 @@ class Common:
""" """
if self.platform == "Windows": try:
pass print(
else: Back.MAGENTA
pass + Fore.WHITE
+ "╭───────────────────────────────────────────╮"
print( )
Back.MAGENTA + Fore.WHITE + "╭───────────────────────────────────────────╮" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + "▄▄█████▄▄"
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "▄▄█████▄▄" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▄████▀▀▀████▄"
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ " ▄████▀▀▀████▄" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▀▀█▀ ▀██▄ "
+ Fore.WHITE + Fore.WHITE
+ " ▀▀█▀ ▀██▄ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + "▄█▄ ▀██▄ "
+ Fore.WHITE + Fore.WHITE
+ "▄█▄ ▀██▄ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▄█████▄ ███"
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ " ▄█████▄ ███" + " -+- "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " -+- " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ███ ▀█████▀ "
+ Fore.WHITE + Fore.WHITE
+ " ███ ▀█████▀ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▀██▄ ▀█▀ "
+ Fore.WHITE + Fore.WHITE
+ " ▀██▄ ▀█▀ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + "▀██▄ ▄█▄▄"
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "▀██▄ ▄█▄▄" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "" + " * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " * " + "▀████▄▄▄████▀ "
+ Fore.WHITE + Fore.WHITE
+ "▀████▄▄▄████▀ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▀▀█████▀▀ "
+ Fore.WHITE + Fore.WHITE
+ " ▀▀█████▀▀ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.LIGHTMAGENTA_EX
+ "" + " -+- * "
+ Fore.LIGHTMAGENTA_EX + Fore.WHITE
+ " -+- * " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▄▀▄ ▄▀▀ █ "
+ Fore.WHITE + Fore.WHITE
+ " ▄▀▄ ▄▀▀ █ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " █ █ ▀ ▀▄ █ "
+ Fore.WHITE + Fore.WHITE
+ " █ █ ▀ ▀▄ █ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " █ █ █▀▄ █ ▄▀▄ █▀▄ ▀▄ █▀▄ ▄▀▄ █▄▀ ▄█▄ "
+ Fore.WHITE + Fore.WHITE
+ " █ █ █▀▄ █ ▄▀▄ █▀▄ ▀▄ █▀▄ ▄▀▄ █▄▀ ▄█▄ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " ▀▄▀ █ █ █ ▀▄▀ █ █ ▄▄▀ █ █ ▀▄█ █ ▀▄▄ "
+ Fore.WHITE + Fore.WHITE
+ " ▀▄▀ █ █ █ ▀▄▀ █ █ ▄▄▀ █ █ ▀▄█ █ ▀▄▄ " + ""
+ Fore.WHITE )
+ "" print(
) Back.MAGENTA
print( + Fore.WHITE
Back.MAGENTA + Fore.WHITE + "│ │" + "│ │"
) )
left_spaces = (43 - len(self.version) - 1) // 2 left_spaces = (43 - len(self.version) - 1) // 2
right_spaces = left_spaces right_spaces = left_spaces
if left_spaces + len(self.version) + 1 + right_spaces < 43: if left_spaces + len(self.version) + 1 + right_spaces < 43:
right_spaces += 1 right_spaces += 1
print( print(
Back.MAGENTA Back.MAGENTA
+ Fore.WHITE + Fore.WHITE
+ "" + ""
+ Fore.WHITE + Fore.WHITE
+ f"{' '*left_spaces}v{self.version}{' '*right_spaces}" + f"{' '*left_spaces}v{self.version}{' '*right_spaces}"
+ Fore.WHITE + Fore.WHITE
+ "" + ""
) )
print( print(
Back.MAGENTA + Fore.WHITE + "│ │" Back.MAGENTA
) + Fore.WHITE
print( + "│ │"
Back.MAGENTA )
+ Fore.WHITE print(
+ "" Back.MAGENTA
+ Fore.WHITE + Fore.WHITE
+ " https://onionshare.org/ " + ""
+ Fore.WHITE + Fore.WHITE
+ "" + " https://onionshare.org/ "
) + Fore.WHITE
print( + ""
Back.MAGENTA + Fore.WHITE + "╰───────────────────────────────────────────╯" )
) print(
print() Back.MAGENTA
+ Fore.WHITE
+ "╰───────────────────────────────────────────╯"
)
print()
except:
# If anything fails, print a boring banner
print(f"OnionShare v{self.version}")
print("https://onionshare.org/")
print()
def load_settings(self, config=None): def load_settings(self, config=None):
""" """
@ -437,7 +446,7 @@ class Common:
Returns True if OnionShare is running in a Flatpak sandbox Returns True if OnionShare is running in a Flatpak sandbox
""" """
return os.environ.get("FLATPAK_ID") == "org.onionshare.OnionShare" return os.environ.get("FLATPAK_ID") == "org.onionshare.OnionShare"
def is_snapcraft(self): def is_snapcraft(self):
""" """
Returns True if OnionShare is running in a Flatpak sandbox Returns True if OnionShare is running in a Flatpak sandbox