added remote pull for packages
This commit is contained in:
parent
b8448dea16
commit
9d034a79de
21
main.py
21
main.py
@ -10,6 +10,7 @@ if os.name != "nt":
|
|||||||
import readline
|
import readline
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
|
import requests
|
||||||
|
|
||||||
def handler(signum, frame):
|
def handler(signum, frame):
|
||||||
return
|
return
|
||||||
@ -142,7 +143,15 @@ class packagemanager:
|
|||||||
with open(("./packages/"+name+".py"), "r") as f:
|
with open(("./packages/"+name+".py"), "r") as f:
|
||||||
f.close()
|
f.close()
|
||||||
except FileNotFoundError:
|
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:
|
try:
|
||||||
|
|
||||||
@ -244,7 +253,15 @@ def main():
|
|||||||
if error[0]==1:
|
if error[0]==1:
|
||||||
|
|
||||||
print(f"{color.red}ERROR{color.white}:{color.red} {error[1]}{color.white}")
|
print(f"{color.red}ERROR{color.white}:{color.red} {error[1]}{color.white}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
start()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
start()
|
24
packages/test.py
Normal file
24
packages/test.py
Normal 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")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user