From 9d034a79de140d3bad4f00b76e5d0cdd022205b6 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja Date: Sat, 26 Aug 2023 23:24:51 -0500 Subject: [PATCH] added remote pull for packages --- main.py | 21 +++++++++++++++++++-- packages/test.py | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 packages/test.py diff --git a/main.py b/main.py index cb9caf6..e803a81 100644 --- a/main.py +++ b/main.py @@ -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: @@ -244,7 +253,15 @@ def main(): if error[0]==1: print(f"{color.red}ERROR{color.white}:{color.red} {error[1]}{color.white}") + + + +def start(): + try: + main() + except KeyboardInterrupt: + start() if __name__ == '__main__': - main() \ No newline at end of file + start() \ No newline at end of file diff --git a/packages/test.py b/packages/test.py new file mode 100644 index 0000000..0a1b32c --- /dev/null +++ b/packages/test.py @@ -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") + +