diff --git a/main.py b/main.py index 792aa3f..c94abfa 100644 --- a/main.py +++ b/main.py @@ -43,7 +43,7 @@ def boot(self): else: self.user_commands[command]() else: - self.unknown_function() + self.try_exec_script(command) def banner(self): print("______________________________________________") @@ -65,7 +65,7 @@ def welcome(self): def help(self): print(self.name+ " Version "+self.version+" user commands:\n") - print("\t`ls` - list files\n\t`cat filename` - print file\n\t`info filename` - info about selected file\n\t`rm filename` - remove file\n\t`ed filename` - text editor\n\t`banner` - system banner\n\t`cls` - clear screen\n\t`mhz` 160 - set CPU speed (80-160) in MHz\n\t`stats` - hardware and software information") + print("\t`ls` - list files\n\t`cat filename` - print file\n\t`info filename` - info about selected file\n\t`rm filename` - remove file\n\t`ed filename` - text editor\n\t`banner` - system banner\n\t`cls` - clear screen\n\t`mhz` 160 - set CPU speed (80-160) in MHz\n\t`stats` - hardware and software information\n\tYou can also run any Python script by typing its filename without `.py`") print("\nSystem created by Krzysztof Krystian Jankowski") print("Code available at github and smol.p1x.in/os/") @@ -78,6 +78,13 @@ def print_msg(self, message): def unknown_function(self): self.print_err("unknown function. Try 'help'.") + def try_exec_script(self,command): + if command+'.py' in uos.listdir(): + command = "import " + command + exec(command) + else: + self.unknown_function() + def set_cpu_mhz(self,freq="80"): freq = int(freq) if freq >= 80 and freq <= 160: