""" The shell for PyNVOS Version: 0.1.0-main1 """ import importlib import os import cmd # from ..sys.krnl import Kernel print(__name__) class shell(cmd.Cmd): intro = "Shell started, PyNVOS 0.1.1-main1" prompt = "shell-0.1.0$ " file = None krnl = importlib.import_module(".jail_mgr", "vfs.sys") kernel = krnl.Kernel() print(str(kernel) + " " + str(type(kernel))) def do_cd(self, args): """Changes directory""" args = shell.kernel.fs(args) os.chdir(args) def do_exec(self, args): """Allows you to execute a file""" # Apps in /bin should be allowed to launch without first adding /bin/ or ./, just the name of the executable # So for ledit it should be just 'ledit' and not /bin/ledit.py or ./ledit.py bins_in_bin = os.listdir(shell.kernel.fs("/bin")) apps_strip = [] for apps in bins_in_bin: if apps.endswith(".py"): apps_strip.append(apps.strip(".py")) if args in apps_strip: shell.kernel.run_program(f"/bin/{args}.py") else: shell.kernel.run_program(args) def do_ls(self, none): """Lists the content of a directory""" os.listdir(os.getcwd()) def postloop(self): pass if __name__ == '': shell().cmdloop() if __name__ == '__main__': print("The shell can't be ran as a standalone program and must be ran in conjunction with the kernel.") input("Press Enter to continue...") exit(-1)