TermPY/packages/update.py

58 lines
1.5 KiB
Python
Raw Normal View History

2023-08-27 03:51:11 +00:00
#["upd", "packages.update", ["upd"]]
2023-08-27 02:52:17 +00:00
# Made By Blurple
2023-08-27 04:05:43 +00:00
import os, sys, requests, threading, time
2023-08-27 02:52:17 +00:00
2023-11-29 04:43:32 +00:00
url = "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/"
filenames = [
"builtin.py",
"calc.py",
"filemanager.py",
"filemanip.py",
"hangman.py",
"nano.py",
"netget.py",
"notebook.py",
"pip.py",
"randomquote.py",
"reminder.py",
"system_info.py",
"test.py",
"top.py",
"update.py",
"vault.py"
2023-08-27 03:51:11 +00:00
]
2023-08-27 02:52:17 +00:00
2023-11-29 04:43:32 +00:00
fileList = [f"{url}{filename}" for filename in filenames]
def download_and_save(url):
r = requests.get(url)
2023-08-27 04:19:57 +00:00
#print(r.text)
fileInstallingCreator = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.basename(url))
with open(fileInstallingCreator, "w") as newFile:
newFile.write(r.text)
2023-11-29 04:43:32 +00:00
print("\n")
2023-08-27 03:51:11 +00:00
def upd(command):
2023-11-29 04:43:32 +00:00
print("Programs to download:")
for prg in fileList:
print(prg)
print(f"To path: {os.path.dirname(os.path.realpath(__file__))}\nPress enter to continue")
input()
2023-08-27 04:05:17 +00:00
print("Downloading and saving files:")
threads = []
2023-08-27 03:51:11 +00:00
for url in fileList:
2023-08-27 04:12:40 +00:00
thread = threading.Thread(target=download_and_save, args=(url,))
threads.append(thread)
thread.start()
2023-08-27 04:07:40 +00:00
text = ""
2023-08-27 04:05:17 +00:00
# Display loading animation
while any(thread.is_alive() for thread in threads):
for _ in range(len(threads)):
2023-08-27 04:07:40 +00:00
text += "."
print(text+"\r", end="", flush=True)
2023-08-27 04:05:17 +00:00
time.sleep(0.5)
print("\nAll files downloaded and saved!")