include returns for evaluation in cli.py

pull/280/head
iaacornus 3 years ago
parent cce278ab83
commit 11450e4896
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -2,7 +2,6 @@ import os
import shutil import shutil
from dotenv import load_dotenv from dotenv import load_dotenv
from rich.console import Console
from reddit.subreddit import get_subreddit_threads from reddit.subreddit import get_subreddit_threads
from video_creation.background import download_background, chop_background_video from video_creation.background import download_background, chop_background_video
@ -20,8 +19,6 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None):
required variables are set. If not, print a warning and launch the required variables are set. If not, print a warning and launch the
setup wizard. setup wizard.
""" """
console = Console()
load_dotenv() load_dotenv()
REQUIRED_VALUES = [ REQUIRED_VALUES = [
@ -40,11 +37,9 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None):
if not os.path.exists(".env"): if not os.path.exists(".env"):
shutil.copy(".env.template", ".env") shutil.copy(".env.template", ".env")
console.print( print_substep("The .env file is invalid. Creating .env file.", style_="bold red")
"[bold red] The .env file is invalid. Creating .env file.[/bold red]"
)
console.print("[bold]Checking environment variables...[/bold]") print_substep("Checking environment variables ...", style_="bold")
configured = True configured = True
for val in REQUIRED_VALUES: for val in REQUIRED_VALUES:
@ -55,7 +50,7 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None):
configured = False configured = False
if configured: if configured:
console.print("[bold green]Enviroment Variables are set! Continuing...[/bold green]") print_substep("Enviroment Variables are set! Continuing ...", style_="bold green")
reddit_object = get_subreddit_threads(subreddit_, thread_link_) reddit_object = get_subreddit_threads(subreddit_, thread_link_)
length, number_of_comments = save_text_to_mp3(reddit_object) length, number_of_comments = save_text_to_mp3(reddit_object)
@ -67,11 +62,13 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None):
download_background(background) download_background(background)
chop_background_video(length) chop_background_video(length)
make_final_video(number_of_comments, filename) make_final_video(number_of_comments, filename)
else: return True
console.print(
"[bold red]Looks like you need to set your Reddit credentials in the .env file. " print_substep(
+ "Please follow the instructions in the README.md file to set them up.[/bold 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.", style_="bold red"
setup_ask = input("\033[1mLaunch setup wizard? [y/N] > \033[0m") )
if setup_ask in ["y", "Y"]: if input("\033[1mLaunch setup wizard? [y/N] > \033[0m").strip() in ["y", "Y"]:
setup() setup()
return False

Loading…
Cancel
Save