Skip to content

Commit

Permalink
Made some ecosystem changes and updated version identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
noahzeisberg committed May 15, 2023
1 parent b86103f commit 68deee1
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pytube import YouTube

init(convert=True)
CURRENT_FYUTILS_VERSION = "1.7.6"
CURRENT_FYUTILS_VERSION = "1.8.0"
SUPPORTED_FUEL_VERSION = 1


Expand All @@ -41,10 +41,14 @@ def prefix(level: str, protocol: str = "FyUTILS"):
return false_color() + "PREFIX TYPE NOT SUPPORTED. SEE https://github.com/NoahOnFyre/FyUTILS#prefix"


def exec(command):
def execute(command):
subprocess.call(command, shell=True)


def exec_code(command):
return subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)


def version_is_newer(current, value):
split = str(current).split(".")
major = split[0]
Expand All @@ -66,7 +70,7 @@ def version_is_newer(current, value):


def update_status(status):
exec("title FyUTILS " + version + " - " + username + "@" + device + " - " + status)
execute("title FyUTILS " + version + " - " + username + "@" + device + " - " + status)
try:
rpc.update(
state=status, details=username + "@" + device, small_image="python",
Expand All @@ -80,7 +84,7 @@ def update_status(status):


def update_ssh_status(status):
exec("title FyUTILS " + version + " - " + user + "@" + server + " - " + status)
execute("title FyUTILS " + version + " - " + user + "@" + server + " - " + status)
try:
rpc.update(
state="[REMOTE] " + status, details=user + "@" + server, small_image="ssh",
Expand Down Expand Up @@ -196,11 +200,11 @@ def crash_log():

temp.write(data.encode())
temp.close()
exec("explorer.exe /select,\"" + main_dir + "crash.log" + "\"")
execute("explorer.exe /select,\"" + main_dir + "crash.log" + "\"")


def menu():
exec("cls")
execute("cls")
print(color() + " __________ _____ __ ________ ________ ______ ________")
print(color() + " ___ ____/ _____ __ __ / / / ___ __/ ____ _/ ___ / __ ___/")
print(color() + " __ /_ __ / / / _ / / / __ / __ / __ / _____ \\ ")
Expand All @@ -221,7 +225,7 @@ def menu():


# INIT PHASE
exec("title FyUTILS")
execute("title FyUTILS")

# Color initialisation
src_color = Fore.LIGHTBLUE_EX
Expand Down Expand Up @@ -387,7 +391,7 @@ def menu():
elif os.getcwd() == appdata_dir:
cwd_abbreviation = "@"
else:
cwd_abbreviation = os.getcwd().replace("C:\\", "/").replace("\\", "/").lower()
cwd_abbreviation = os.getcwd()
request_raw = input(accent_color() + "╔═══[" + color() + username + accent_color() + "@" + text_color() + device + accent_color() + "]══(" + color() + "FyUTILS" + accent_color() + "/" + text_color() + version + accent_color() + ")══[" + text_color() + cwd_abbreviation + accent_color() + "]\n" +
accent_color() + "╚═══> " + text_color())
request = request_raw.split(" ")
Expand Down Expand Up @@ -697,7 +701,7 @@ def menu():

try:
open(download_content_dir + "\\" + filename, mode="xb").write(fetch_content)
exec("start explorer.exe " + download_content_dir)
execute("start explorer.exe " + download_content_dir)
except Exception as e:
print("\n" + prefix("ERROR") + "Could not save content to file.")
print(prefix("ERROR") + str(e))
Expand Down Expand Up @@ -730,7 +734,7 @@ def menu():
print(prefix("INFO") + "Download started!")
youtube.streams.filter(file_extension="mp4").order_by('resolution').desc().first().download(download_content_dir)
print(prefix("INFO") + f"Download finished in {time.time() - activity_start: 0.2f} seconds!")
exec("start explorer.exe " + download_content_dir)
execute("start explorer.exe " + download_content_dir)
except KeyboardInterrupt:
print()
print("\n" + prefix("INFO") + "Canceling Action...")
Expand All @@ -742,7 +746,7 @@ def menu():
print()

case "log":
exec("explorer.exe /select,\"" + main_dir + "crash.log" + "\"")
execute("explorer.exe /select,\"" + main_dir + "crash.log" + "\"")

case "streamhunter":
activity_start = time.time()
Expand Down Expand Up @@ -881,7 +885,7 @@ def menu():
print(prefix("INFO", "Updater") + "Restarting FyUTILS...")
temp.close()
time.sleep(1)
exec("start " + current_dir + "\\main.py")
execute("start " + current_dir + "\\main.py")
sys.exit(512)
else:
print(prefix("INFO", "Updater") + "You're running the latest version of FyUTILS!")
Expand Down Expand Up @@ -979,7 +983,7 @@ def menu():
case "shell":
update_status("Executing system command \"" + request_raw.removeprefix("shell ") + "\"")

exec(request_raw.removeprefix("shell "))
execute(request_raw.removeprefix("shell "))

case "exit":
update_status("Shutting down...")
Expand Down Expand Up @@ -1036,7 +1040,7 @@ def menu():

case "help":
update_status("Viewing help...")
exec("start https://github.com/NoahOnFyre/FyUTILS#commands")
execute("start https://github.com/NoahOnFyre/FyUTILS#commands")
pause("INFO", "Help")

case "raise":
Expand All @@ -1045,12 +1049,12 @@ def menu():

case "clear" | "rl" | "reload":
update_status("Reloading...")
exec("cls")
execute("cls")
menu()

case "restart" | "rs":
print("logout")
exec("start " + current_dir + "\\main.py")
execute("start " + current_dir + "\\main.py")
print("login")
sys.exit(0)

Expand All @@ -1072,11 +1076,14 @@ def menu():
update_status(json_fuel_file["head"]["status"])

if json_fuel_file["body"]["enabled"]:
exec("\n".join(list(json_fuel_file["body"]["content"])))
execute("\n".join(list(json_fuel_file["body"]["content"])))
else:
print(prefix("ERROR") + "The command \"" + cmd + "\" isn't a FyUTILS specific command.")
if exec_code(request_raw) == 1:
print(prefix("ERROR") + "Invalid command: \"" + cmd + "\".")
else:
execute(request_raw)
except Exception as e:
exec("title FyUTILS Crash Handler - Crash Log")
execute("title FyUTILS Crash Handler - Crash Log")
print(prefix("ERROR", "Crash") + "FyUTILS CRASH LOG @ " + datetime.datetime.now().strftime("%H:%M:%S"))
print(prefix("ERROR", "Crash") + "Error: " + str(e))
print(prefix("ERROR", "Crash") + "The full crash log has been saved to: " + main_dir + "crash.log")
Expand Down

0 comments on commit 68deee1

Please sign in to comment.