added remote pull for packages

This commit is contained in:
OusmBlueNinja 2023-08-26 23:24:51 -05:00
parent b8448dea16
commit 9d034a79de
2 changed files with 43 additions and 2 deletions

21
main.py
View File

@ -10,6 +10,7 @@ if os.name != "nt":
import readline
import threading
import signal
import requests
def handler(signum, frame):
return
@ -142,7 +143,15 @@ class packagemanager:
with open(("./packages/"+name+".py"), "r") as f:
f.close()
except FileNotFoundError:
raise Exception("Package could not be found, make sure package source is in [ packages ] folder.")
try:
url = f"https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/{name}.py"
r = requests.get(url)
#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)
except Exception as e:
raise Exception("Package could not be found, make sure package source is in [ packages ] folder.")
try:
@ -246,5 +255,13 @@ def main():
print(f"{color.red}ERROR{color.white}:{color.red} {error[1]}{color.white}")
def start():
try:
main()
except KeyboardInterrupt:
start()
if __name__ == '__main__':
main()
start()

24
packages/test.py Normal file
View File

@ -0,0 +1,24 @@
#["netget", "packages.netget", ["netget"]]
# Made By OusmeBlueNinja
import os, sys
def netget(command: list):
print(command, len(command))
if len(command) != 2:
print("comand requires [ url ] [ path ]")
return
url = command[0]
location = command[1]
try:
import wget
wget.download(url, location)
except ImportError:
os.system(f"wget {url} -O {location}")
except:
print("cannot download")