Multiprocessing
Settings fix
pull/1207/head
RapidStoned 3 years ago
parent 2d8c1f2811
commit b496b5906d

@ -1,5 +1,5 @@
from genericpath import isfile from genericpath import isfile
from main import main, shutdown, start from main import main, shutdown, generateVideo
from doctest import master from doctest import master
import tkinter import tkinter
@ -9,10 +9,12 @@ from tkinter import filedialog
import os import os
import toml import toml
import shutil import shutil
import multiprocessing
from utils.settings import check_toml from utils.settings import check_toml
from utils import settings from utils import settings
from pathlib import Path from pathlib import Path
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light" customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue" customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
@ -192,7 +194,7 @@ class App(customtkinter.CTk):
# 2fa option menu # 2fa option menu
self.user_2fa = customtkinter.CTkOptionMenu( self.user_2fa = customtkinter.CTkOptionMenu(
master=self.frame_bg_settings, master=self.frame_bg_settings,
values=["false", "true"] values=["False", "True"]
) )
self.user_2fa.grid(row=7, column=0, padx=15) self.user_2fa.grid(row=7, column=0, padx=15)
@ -216,7 +218,7 @@ class App(customtkinter.CTk):
# Random option menu # Random option menu
self.thread_random = customtkinter.CTkOptionMenu( self.thread_random = customtkinter.CTkOptionMenu(
master=self.frame_bg_settings, master=self.frame_bg_settings,
values=["false", "true"] values=["False", "True"]
) )
self.thread_random.grid(row=3, column=2, padx=15) self.thread_random.grid(row=3, column=2, padx=15)
@ -636,12 +638,18 @@ class App(customtkinter.CTk):
self.client_id.insert("0", config["reddit"]["creds"]["client_id"]) self.client_id.insert("0", config["reddit"]["creds"]["client_id"])
# 2fa # 2fa
self.user_2fa.set(str(config["reddit"]["creds"]["2fa"])) if config["reddit"]["creds"]["2fa"] == True:
self.user_2fa.set(str("True"))
else:
self.user_2fa.set(str("False"))
# Thread Settings # Thread Settings
# Random # Random
self.thread_random.set(str(config["reddit"]["thread"]["random"])) if config["reddit"]["thread"]["random"] == True:
self.thread_random.set(str("True"))
else:
self.thread_random.set(str("False"))
# Subreddit # Subreddit
if not config["reddit"]["thread"]["subreddit"] == "": if not config["reddit"]["thread"]["subreddit"] == "":
@ -664,7 +672,10 @@ class App(customtkinter.CTk):
# Misc Settings # Misc Settings
# Allow nsfw # Allow nsfw
self.misc_allow_nsfw.set(str(config["settings"]["allow_nsfw"])) if config["settings"]["allow_nsfw"] == True:
self.misc_allow_nsfw.set(str("True"))
else:
self.misc_allow_nsfw.set(str("False"))
# Theme # Theme
self.misc_theme.set(str(config["settings"]["theme"])) self.misc_theme.set(str(config["settings"]["theme"]))
@ -729,12 +740,18 @@ class App(customtkinter.CTk):
config["reddit"]["creds"]["client_id"] = self.client_id.get() config["reddit"]["creds"]["client_id"] = self.client_id.get()
# 2fa # 2fa
config["reddit"]["creds"]["2fa"] = self.user_2fa.get() if self.user_2fa.get() == "False":
config["reddit"]["creds"]["2fa"] = False
else:
config["reddit"]["creds"]["2fa"] = True
# Thread Settings # Thread Settings
# Random # Random
config["reddit"]["thread"]["random"] = self.thread_random.get() if self.thread_random.get() == "True":
config["reddit"]["thread"]["random"] = True
else:
config["reddit"]["thread"]["random"] = False
# Subreddit # Subreddit
config["reddit"]["thread"]["subreddit"] = self.thread_subreddit.get() config["reddit"]["thread"]["subreddit"] = self.thread_subreddit.get()
@ -754,7 +771,10 @@ class App(customtkinter.CTk):
# Misc Settings # Misc Settings
# Allow nsfw # Allow nsfw
config["settings"]["allow_nsfw"] = self.misc_allow_nsfw.get() if self.misc_allow_nsfw == "True":
config["settings"]["allow_nsfw"] = True
else:
config["settings"]["allow_nsfw"] = False
# Theme # Theme
config["settings"]["theme"] = self.misc_theme.get() config["settings"]["theme"] = self.misc_theme.get()
@ -883,7 +903,8 @@ class App(customtkinter.CTk):
# Start button event # Start button event
def btn_start(self): def btn_start(self):
self.saveSettings() self.saveSettings()
start() mpGen = multiprocessing.Process(target=generateVideo)
mpGen.start()
print("Start Pressed!") print("Start Pressed!")
# Appearance event # Appearance event

@ -74,14 +74,14 @@ def shutdown():
print("Exiting...") print("Exiting...")
exit() exit()
def generateVideo():
def start():
if __name__ == "__main__":
assert sys.version_info >= (3, 9), "Python 3.10 or higher is required"
config = settings.check_toml("utils/.config.template.toml", "config.toml") config = settings.check_toml("utils/.config.template.toml", "config.toml")
config is False and exit() config is False and exit()
try: try:
if len(config["reddit"]["thread"]["post_id"].split("+")) > 1: if config["settings"]["times_to_run"]:
run_many(config["settings"]["times_to_run"])
elif len(config["reddit"]["thread"]["post_id"].split("+")) > 1:
for index, post_id in enumerate(config["reddit"]["thread"]["post_id"].split("+")): for index, post_id in enumerate(config["reddit"]["thread"]["post_id"].split("+")):
index += 1 index += 1
print_step( print_step(
@ -89,8 +89,6 @@ def start():
) )
main(post_id) main(post_id)
Popen("cls" if name == "nt" else "clear", shell=True).wait() Popen("cls" if name == "nt" else "clear", shell=True).wait()
elif config["settings"]["times_to_run"]:
run_many(config["settings"]["times_to_run"])
else: else:
main() main()
except KeyboardInterrupt: except KeyboardInterrupt:

@ -31,5 +31,5 @@ random = false
subreddit = "" subreddit = ""
post_id = "" post_id = ""
max_comment_length = 50 max_comment_length = 50
post_lang = "" post_lang = "en"
min_comments = 20 min_comments = 20

Loading…
Cancel
Save