pull/280/head
iaacornus 3 years ago
parent 7235d2075b
commit 297c614c04
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -1,21 +1,18 @@
import os import os
from os.path import exists from os.path import exists
from rich.console import Console from utils.console import print_markdown, print_substep
from utils.console import print_markdown
def setup(): def setup():
console = Console()
if exists(".setup-done-before"): if exists(".setup-done-before"):
console.log( print_substep(
"[bold red]Setup was already done before! Please make" "Setup was already done before! Please make sure you have "
+ " sure you have to run this script again.[/bold red]" + "to run this script again.", style_="bold red"
) )
# to run the setup script again, but in better and more convenient manner. # to run the setup script again, but in better and more convenient manner.
if input("\033[1mRun the script again? [y/N] > \033[0m") not in ["y", "Y"]: if str(input("\033[1mRun the script again? [y/N] > \033[0m")).strip() not in ["y", "Y"]:
print_substep("Permission denied!", style_="bold red")
raise SystemExit() raise SystemExit()
print_markdown( print_markdown(
@ -25,7 +22,7 @@ def setup():
# 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.
# 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( print_substep(
"Ensure you have the following ready to enter:\n" "Ensure you have the following ready to enter:\n"
+ "[bold green]Reddit Client ID\n" + "[bold green]Reddit Client ID\n"
+ "Reddit Client Secret\n" + "Reddit Client Secret\n"
@ -35,9 +32,9 @@ def setup():
+ "Opacity (range of 0-1, decimals are accepted.)\n" + "Opacity (range of 0-1, decimals are accepted.)\n"
+ "Subreddit (without r/ or /r/)\n" + "Subreddit (without r/ or /r/)\n"
+ "Theme (light or dark)[/bold green]" + "Theme (light or dark)[/bold green]"
+ "[bold]If you don't have these, please follow the instructions in the README.md file to" + "[bold]If you don't have these, please follow the instructions in the README.md "
+ " set them up.\nIf you do have these, type y or Y to continue. If you don't, go ahead and" + "set them up.\nIf you do have these, type y or Y to continue. If you don't, "
+ " grab those quickly and come back.[/bold]" + "go ahead and grab those quickly and come back.[/bold]"
) )
# Begin the setup process. # Begin the setup process.
@ -51,9 +48,9 @@ def setup():
subreddit = input("Subreddit (without r/) > ") subreddit = input("Subreddit (without r/) > ")
theme = input("Theme? (light or dark) > ") theme = input("Theme? (light or dark) > ")
# you can also put a while loop here, e.g. while VideoIsBeingMade == True: ... if exists(".env"):
console.log("Saving credentials...") os.remove(".env")
os.remove(".env")
with open(".env", "a", encoding="utf-8") as f: with open(".env", "a", encoding="utf-8") as f:
f.write( f.write(
f'REDDIT_CLIENT_ID="{cliID}"\n' f'REDDIT_CLIENT_ID="{cliID}"\n'
@ -67,8 +64,6 @@ def setup():
) )
with open(".setup-done-before", "a", encoding="utf-8") as f: with open(".setup-done-before", "a", encoding="utf-8") as f:
f.write( f.write("This file will stop the setup assistant from running again.")
"This file will stop the setup assistant from running again."
)
console.print("[bold green]Setup Complete![/bold green]") print_substep("[bold green]Setup Complete![/bold green]")

Loading…
Cancel
Save