Merge pull request #1334 from micahflee/ascii_art

Prettier ASCII art
This commit is contained in:
Saptak Sengupta 2021-04-29 19:19:52 +05:30 committed by GitHub
commit 34554414e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 251 additions and 56 deletions

View File

@ -43,57 +43,7 @@ def main(cwd=None):
onionshare uses.
"""
common = Common()
# Display OnionShare banner
print(f"OnionShare {common.version} | https://onionshare.org/")
reset = "\033[0m"
purple = "\33[95m"
print(purple)
print(" @@@@@@@@@ ")
print(" @@@@@@@@@@@@@@@@@@@ ")
print(" @@@@@@@@@@@@@@@@@@@@@@@@@ ")
print(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ")
print(
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ___ _ "
)
print(
" @@@@@@ @@@@@@@@@@@@@ / _ \\ (_) "
)
print(
" @@@@ @ @@@@@@@@@@@ | | | |_ __ _ ___ _ __ "
)
print(
" @@@@@@@@ @@@@@@@@@@ | | | | '_ \\| |/ _ \\| '_ \\ "
)
print(
" @@@@@@@@@@@@ @@@@@@@@@@ \\ \\_/ / | | | | (_) | | | | "
)
print(
" @@@@@@@@@@@@@@@@ @@@@@@@@@ \\___/|_| |_|_|\\___/|_| |_| "
)
print(
" @@@@@@@@@ @@@@@@@@@@@@@@@@ _____ _ "
)
print(
" @@@@@@@@@@ @@@@@@@@@@@@ / ___| | "
)
print(
" @@@@@@@@@@ @@@@@@@@ \\ `--.| |__ __ _ _ __ ___ "
)
print(
" @@@@@@@@@@@ @ @@@@ `--. \\ '_ \\ / _` | '__/ _ \\"
)
print(
" @@@@@@@@@@@@@ @@@@@@ /\\__/ / | | | (_| | | | __/"
)
print(
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \\____/|_| |_|\\__,_|_| \\___|"
)
print(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ")
print(" @@@@@@@@@@@@@@@@@@@@@@@@@ ")
print(" @@@@@@@@@@@@@@@@@@@ ")
print(" @@@@@@@@@ ")
print(reset)
common.display_banner()
# OnionShare CLI in OSX needs to change current working directory (#132)
if common.platform == "Darwin":

View File

@ -44,8 +44,13 @@ class Common:
"""
C_RESET = "\033[0m"
C_BG_PURPLE = "\033[45m"
C_BOLD = "\033[01m"
C_WHITE = "\033[97m"
C_LIGHTGRAY = "\033[37m"
C_DARKGRAY = "\033[90m"
C_LIGHTPURPLE = "\033[95m"
C_DARKPURPLE = "\033[35m"
def __init__(self, verbose=False):
self.verbose = verbose
@ -59,6 +64,248 @@ class Common:
with open(self.get_resource_path("version.txt")) as f:
self.version = f.read().strip()
def display_banner(self):
"""
Raw ASCII art example:
* *
*
*
-+-
* *
*
-+- *
v2.3.1
https://onionshare.org/
"""
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ "╭───────────────────────────────────────────╮"
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_WHITE
+ "▄▄█████▄▄"
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▄████▀▀▀████▄"
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▀▀█▀ ▀██▄ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_WHITE
+ "▄█▄ ▀██▄ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▄█████▄ ███"
+ self.C_LIGHTPURPLE
+ " -+- "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ███ ▀█████▀ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▀██▄ ▀█▀ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_WHITE
+ "▀██▄ ▄█▄▄"
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTPURPLE
+ " * "
+ self.C_WHITE
+ "▀████▄▄▄████▀ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▀▀█████▀▀ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTPURPLE
+ " -+- * "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▄▀▄ ▄▀▀ █ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " █ █ ▀ ▀▄ █ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " █ █ █▀▄ █ ▄▀▄ █▀▄ ▀▄ █▀▄ ▄▀▄ █▄▀ ▄█▄ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_WHITE
+ " ▀▄▀ █ █ █ ▀▄▀ █ █ ▄▄▀ █ █ ▀▄█ █ ▀▄▄ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ "│ │"
+ self.C_RESET
)
left_spaces = (43 - len(self.version) - 1) // 2
right_spaces = left_spaces
if left_spaces + len(self.version) + right_spaces < 43:
right_spaces += 1
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTGRAY
+ f"{' '*left_spaces}v{self.version}{' '*right_spaces}"
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ "│ │"
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ ""
+ self.C_LIGHTGRAY
+ " https://onionshare.org/ "
+ self.C_LIGHTGRAY
+ ""
+ self.C_RESET
)
print(
self.C_BG_PURPLE
+ self.C_LIGHTGRAY
+ "╰───────────────────────────────────────────╯"
+ self.C_RESET
)
print()
def load_settings(self, config=None):
"""
Loading settings, optionally from a custom config json file.
@ -130,7 +377,7 @@ class Common:
try:
appdata = os.environ["APPDATA"]
onionshare_data_dir = f"{appdata}\\OnionShare"
except:
except Exception:
# If for some reason we don't have the 'APPDATA' environment variable
# (like running tests in Linux while pretending to be in Windows)
try:
@ -265,7 +512,7 @@ class Common:
try:
tmpsock.bind(("127.0.0.1", random.randint(min_port, max_port)))
break
except OSError as e:
except OSError:
pass
_, port = tmpsock.getsockname()
return port

View File

@ -75,14 +75,12 @@ def main():
The main() function implements all of the logic that the GUI version of onionshare uses.
"""
common = Common()
common.display_banner()
# Required for macOS Big Sur: https://stackoverflow.com/a/64878899
if common.platform == "Darwin":
os.environ["QT_MAC_WANTS_LAYER"] = "1"
# Display OnionShare banner
print(f"OnionShare {common.version} | https://onionshare.org/")
# Start the Qt app
global qtapp
qtapp = Application(common)