diff --git a/packages - Copy/builtin.py b/packages - Copy/builtin.py deleted file mode 100644 index aa96173..0000000 --- a/packages - Copy/builtin.py +++ /dev/null @@ -1,133 +0,0 @@ -#["builtin", "packages.builtin", ["echo", "ls", "rm", "clear", "cd", "ll"]] -import os -import stat - -if os.name != 'nt': - import pwd - import grp -import time - - - - -def echo(message: list) -> int: - try: - print(" ".join(message)) - except: - return - -def ls(args): - del args - - - pass - -def rm(files: list): - for file in files: - os.remove(file) - -def clear(args): - del args - os.system('cls' if os.name == 'nt' else 'clear') - - - -def cd(args): - if len(args) == 0 or args[0] == "~": - new_path = os.path.expanduser("~") # Get the home directory path - elif len(args) == 1: - new_path = os.path.abspath(args[0]) # Get the absolute path - else: - print("Usage: cd or cd ~") - return - - try: - os.chdir(new_path) # Change the current working directory - except FileNotFoundError: - print("Directory not found.") - except Exception as e: - print(f"An error occurred: {e}") - - - -def ls(args): - del args # You can remove this line if you're not using args - - blue_color = '\033[34m' - green_color = '\033[32m' - white_color = '\033[37m' - reset_color = '\033[0m' - - dir_path = os.getcwd() - try: - with os.scandir(dir_path) as entries: - for entry in entries: - if not entry.name.startswith('.'): - file_path = os.path.join(dir_path, entry.name) - file_stat = os.stat(file_path) - if stat.S_ISDIR(file_stat.st_mode): - print(blue_color + entry.name + '/' + reset_color, end=' ') - elif file_stat.st_mode & stat.S_IXUSR: - print(green_color + entry.name + '*' + reset_color, end=' ') - else: - print(white_color + entry.name + reset_color, end=' ') - print() # Newline after listing - except Exception as e: - print(f"An error occurred: {e}") - - -def ll(args): - if os.name != 'nt': - print("This command only works for linux") - return - dir_path = os.getcwd() - - green_color = '\033[32m' - blue_color = '\033[34m' - whiteColor = '\033[37m' - orange_color = '\033[33m' - reset_color = '\033[0m' - - try: - with os.scandir(dir_path) as entries: - for entry in entries: - file_stat = entry.stat() - file_name = entry.name - - if os.name != 'nt': - pw = pwd.getpwuid(file_stat.st_uid) - gr = grp.getgrgid(file_stat.st_gid) - - is_hidden = (file_name and file_name[0] == '.') - - time_str = time.ctime(file_stat.st_mtime) - if time_str.endswith('\n'): - time_str = time_str[:-1] # Remove newline character - - permission_str = ( - (green_color + "r" if file_stat.st_mode & stat.S_IRUSR else whiteColor + "-") + - (blue_color + "w" if file_stat.st_mode & stat.S_IWUSR else whiteColor + "-") + - ((orange_color if is_hidden else green_color) + "x" if file_stat.st_mode & stat.S_IXUSR else whiteColor + "-") + - (green_color + "r" if file_stat.st_mode & stat.S_IRGRP else whiteColor + "-") + - (blue_color + "w" if file_stat.st_mode & stat.S_IWGRP else whiteColor + "-") + - ((orange_color if is_hidden else green_color) + "x" if file_stat.st_mode & stat.S_IXGRP else whiteColor + "-") + - (green_color + "r" if file_stat.st_mode & stat.S_IROTH else whiteColor + "-") + - (blue_color + "w" if file_stat.st_mode & stat.S_IWOTH else whiteColor + "-") + - ((orange_color if is_hidden else green_color) + "x" if file_stat.st_mode & stat.S_IXOTH else whiteColor + "-") - ) - - print( - "{:<11}{:>4} {:<8} {:<8} {:>8} {} {}{}".format( - permission_str, - file_stat.st_nlink, - pw.pw_name, - gr.gr_name, - file_stat.st_size, - time_str, - (blue_color if entry.is_dir() else (orange_color if is_hidden else green_color) if file_stat.st_mode & stat.S_IXUSR else whiteColor), - file_name, - reset_color - ) - ) - except Exception as e: - print(f"An error occurred: {e}") diff --git a/packages - Copy/echo.py b/packages - Copy/echo.py deleted file mode 100644 index 7d025a5..0000000 --- a/packages - Copy/echo.py +++ /dev/null @@ -1,4 +0,0 @@ -#["echo", "packages.echo", ["out"]] - -def out(message): - print(" ".join(message)) \ No newline at end of file diff --git a/packages - Copy/nano.py b/packages - Copy/nano.py deleted file mode 100644 index 6fc84aa..0000000 --- a/packages - Copy/nano.py +++ /dev/null @@ -1,71 +0,0 @@ -#["nano", "packages.nano", ["nano"]] - -import os - -class TextEditor: - def __init__(self): - self.lines = [] - self.file = "" - - def load_file(self, filename): - try: - with open(filename, "r") as file: - self.lines = file.readlines() - except FileNotFoundError: - print(f"File '{filename}' not found.") - - def save_file(self, filename): - if filename == "": - filename = self.file - with open(filename, "w") as file: - file.writelines(self.lines) - - def edit(self): - while True: - os.system('cls' if os.name == 'nt' else 'clear') - self.display() - - action = input("\nCommands: [e]dit, [n]ewline, [s]ave, [q]uit: ").lower() - - if action == "e": - self.edit_lines() - elif action == "n": - self.newline() - elif action == "s": - filename = input("Enter filename to save: ") - self.save_file(filename) - print(f"File '{filename}' saved.") - elif action == "q": - print("Exiting the text editor.") - break - else: - print("Invalid command.") - - def display(self): - print("Editing: "+self.file) - for i, line in enumerate(self.lines): - print(f"{i + 1}: {line}", end="") - - def newline(self): - self.lines.append("\n") - - def edit_lines(self): - line_number = int(input("Enter line number to edit: ")) - 1 - if 0 <= line_number < len(self.lines): - new_line = input("Enter new text: ") - self.lines[line_number] = new_line + "\n" - else: - print("Invalid line number.") - - -def nano(args): - if len(args) != 1: - print("Usage: nano ") - else: - os.system('cls' if os.name == 'nt' else 'clear') - filename = args[0] - - editor = TextEditor() - editor.file = filename - editor.load_file(filename) - editor.edit() \ No newline at end of file diff --git a/packages - Copy/netget.py b/packages - Copy/netget.py deleted file mode 100644 index 0a1b32c..0000000 --- a/packages - Copy/netget.py +++ /dev/null @@ -1,24 +0,0 @@ -#["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") - - diff --git a/packages - Copy/pip.py b/packages - Copy/pip.py deleted file mode 100644 index c4f77fd..0000000 --- a/packages - Copy/pip.py +++ /dev/null @@ -1,21 +0,0 @@ -#["pip", "packages.pip", ["pip"]] -# Made By Blurple -import os, sys - -def pip(command: list): - - #print(command, len(command)) - if len(command) != 1: - print("comand requires [ package_name ] [ args (optional) ] ") - return - - package = command[0] - try: - print("Running pip from shell") - os.system(f"python -m pip install {package}") - except Exception as e: - print(e) - - - except: - print("cannot download") \ No newline at end of file diff --git a/packages - Copy/update.py b/packages - Copy/update.py deleted file mode 100644 index e4ff3c9..0000000 --- a/packages - Copy/update.py +++ /dev/null @@ -1,33 +0,0 @@ -#["upd", "packages.update", ["upd"]] -# Made By Blurple -import os, sys, requests, threading - -fileList = [ - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/builtin.py", - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/echo.py", - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/nano.py", - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/netget.py", - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/pip.py", - "https://raw.githubusercontent.com/OusmBlueNinja/TermPY/main/packages/upd.py" -] - -def download_and_save(url): - r = requests.get(url) - if 'Requests:' in r.text: - print(r.text) - print(r.headers['Content-Type']) - 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) - -def upd(command): - input(f"Settings: {fileList}, {os.path.dirname(os.path.realpath(__file__))}\nPress enter to continue") - - threads = [] - for url in fileList: - thread = threading.Thread(target=download_and_save, args=(url,)) - threads.append(thread) - thread.start() - - for thread in threads: - thread.join() diff --git a/packages/echo.py b/packages/echo.py deleted file mode 100644 index 7d025a5..0000000 --- a/packages/echo.py +++ /dev/null @@ -1,4 +0,0 @@ -#["echo", "packages.echo", ["out"]] - -def out(message): - print(" ".join(message)) \ No newline at end of file diff --git a/packages/update.py b/packages/update.py index 36adfa9..deae603 100644 --- a/packages/update.py +++ b/packages/update.py @@ -14,6 +14,8 @@ fileList = [ def download_and_save(url): r = requests.get(url) if 'Requests:' in r.text: + with open("./logs", "w") as f: + f.write(r.text) print(r.text) print(r.headers['Content-Type']) fileInstallingCreator = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.basename(url)) @@ -27,7 +29,7 @@ def upd(command): threads = [] for url in fileList: - thread = threading.Thread(target=download_and_save, args=(url,)) + thread = threading.Thread(target=download_and_save, args=(url)) threads.append(thread) thread.start() text = ""