From d3e22d4f0c58ab5b81749d61eff09fa0166ff845 Mon Sep 17 00:00:00 2001 From: JaydenMW Date: Sun, 14 Feb 2021 20:15:47 +0100 Subject: [PATCH] Update 'shell.py' --- shell.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/shell.py b/shell.py index 35abb78..30e361d 100644 --- a/shell.py +++ b/shell.py @@ -1,5 +1,4 @@ -"""pclish: a simple shell written in Python""" - +# Import Modules import os import subprocess import psutil @@ -7,13 +6,13 @@ import platform import socket import getpass -# Get System Information +# Get System Information RAM = psutil.virtual_memory() CPU = platform.processor() -# Command Interpretation -- This is the core of the shell +# Command Interpretation -- This is the core of the shell def execute_command(command): - """execute commands and handle piping""" + # execute commands and handle piping# try: if "|" in command: s_in, s_out = (0, 0) @@ -49,9 +48,9 @@ def execute_command(command): print("pclish: command not found: {}".format(command)) -# Commands - Commands are defined here. +# Commands - Commands are defined here. def pclish_cd(path): - """convert to absolute path and change directory""" + # convert to absolute path and change directory# try: os.chdir(os.path.abspath(path)) except Exception: @@ -62,17 +61,17 @@ def pclish_echo(): print(txt) def pclish_help(): - print("""pclish: here are the commands available + print("pclish: here are the commands available help: shows this page cd: change directory ver: displays shell version - ls: lists files in current dir""") + ls: lists files in current dir") def pclish_ls(): - print("""pclish: this feature is not yet supported""") + print("pclish: this feature is not yet supported") def pclish_ver(): - print("""pclish: version 0.0.2a.""") + print("pclish: version 0.0.2a.") def pclish_mkdir(): value = input("What would you like to name this new directory:\n") @@ -80,7 +79,7 @@ def pclish_mkdir(): os.mkdir(dir) def pclish_system(): - print("""System: XCU Python Based Shell Env""") + print("System: XCU Python Based Shell Env") print("RAM:") print(RAM) print("CPU:") @@ -91,7 +90,7 @@ def pclish_shtdwnsubsys(): print("Shutting Down XCU Python Based Shell Env") exit() -# Shell Prompt Customization and step 2 of command interpritation +# Shell Prompt Customization and step 2 of command interpritation def main(): while True: inp = input(f"{getpass.getuser()}@{platform.node()}>> ") @@ -117,6 +116,6 @@ def main(): execute_command(inp) -# Main +# Main if '__main__' == __name__: main()