Reviews: Various Changes

pull/125/head
BlockArchitech 3 years ago
parent e03f529888
commit 16664e010a
No known key found for this signature in database
GPG Key ID: B264EC928CE5983E

@ -32,7 +32,7 @@ password=os.getenv("REDDIT_PASSWORD")
console.log("[bold green]Checking environment variables...") console.log("[bold green]Checking environment variables...")
time.sleep(1) time.sleep(1)
if client_id == "" or client_secret == "" or username == "" or password == "": if not all(client_id, client_secret, username, password):
console.log("[red]Looks like you need to set your Reddit credentials in the .env file. Please follow the instructions in the README.md file to set them up.") console.log("[red]Looks like you need to set your Reddit credentials in the .env file. Please follow the instructions in the README.md file to set them up.")
time.sleep(0.5) time.sleep(0.5)

@ -12,8 +12,15 @@ from utils.console import print_step
from utils.console import print_substep from utils.console import print_substep
from rich.console import Console from rich.console import Console
from utils.loader import Loader from utils.loader import Loader
from os.path import exists
console = Console() console = Console()
setup_done = exists(".setup-done-before")
if setup_done == True:
console.log("[red]Setup was already completed! Please make sure you have to run this script again. If you have to, please delete the file .setup-done-before")
exit()
# These lines ensure the user: # These lines ensure the user:
# - knows they are in setup mode # - knows they are in setup mode
# - knows that they are about to erase any other setup files/data. # - knows that they are about to erase any other setup files/data.
@ -25,7 +32,7 @@ print_markdown(
) )
# This Input is used to ensure the user is sure they want to continue. # This Input is used to ensure the user is sure they want to continue.
ensureSetupIsRequired = input("Are you sure you want to continue? > ") ensureSetupIsRequired = input("Are you sure you want to continue? > ").casefold()
if ensureSetupIsRequired != "yes": if ensureSetupIsRequired != "yes":
console.print("[red]Exiting...") console.print("[red]Exiting...")
time.sleep(0.5) time.sleep(0.5)
@ -33,7 +40,7 @@ if ensureSetupIsRequired != "yes":
else: else:
# Again, let them know they are about to erase all other setup data. # Again, let them know they are about to erase all other setup data.
console.print("[bold red] This will overwrite your current settings. Are you sure you want to continue? [bold green]yes/no") console.print("[bold red] This will overwrite your current settings. Are you sure you want to continue? [bold green]yes/no")
overwriteSettings = input("Are you sure you want to continue? > ") overwriteSettings = input("Are you sure you want to continue? > ").casefold()
if overwriteSettings != "yes": if overwriteSettings != "yes":
console.print("[red]Abort mission! Exiting...") console.print("[red]Abort mission! Exiting...")
time.sleep(0.5) time.sleep(0.5)
@ -51,7 +58,7 @@ console.log("[bold green]Reddit Password")
time.sleep(0.5) time.sleep(0.5)
console.print("[green]If you don't have these, please follow the instructions in the README.md file to set them up.") console.print("[green]If you don't have these, please follow the instructions in the README.md file to set them up.")
console.print("[green]If you do have these, type yes to continue. If you dont, go ahead and grab those quickly and come back.") console.print("[green]If you do have these, type yes to continue. If you dont, go ahead and grab those quickly and come back.")
confirmUserHasCredentials = input("Are you sure you have the credentials? > ") confirmUserHasCredentials = input("Are you sure you have the credentials? > ").casefold()
if confirmUserHasCredentials != "yes": if confirmUserHasCredentials != "yes":
console.print("[red]I don't understand that.") console.print("[red]I don't understand that.")
console.print("[red]Exiting...") console.print("[red]Exiting...")
@ -88,6 +95,9 @@ with open('.env', 'a') as f:
time.sleep(0.5) time.sleep(0.5)
f.write(f'REDDIT_PASSWORD="{passw}"\n') f.write(f'REDDIT_PASSWORD="{passw}"\n')
with open('.setup-done-before', 'a') as f:
f.write("This file blocks the setup assistant from running again. Delete this file to run setup again.")
loader.stop() loader.stop()
console.log("[bold green]Setup Complete! Returning...") console.log("[bold green]Setup Complete! Returning...")

Loading…
Cancel
Save