1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#!/usr/bin/env python
import os
import configshell_fb as configshell
class MySystemRoot(configshell.node.ConfigNode):
def __init__(self, shell):
configshell.node.ConfigNode.__init__(self, '/', shell=shell)
Interpreters(self)
System(self)
for level in range(1,20):
configshell.node.ConfigNode("level%d" % level, self)
class Interpreters(configshell.node.ConfigNode):
def __init__(self, parent):
configshell.node.ConfigNode.__init__(self, 'interpreters', parent)
def ui_command_python(self):
'''
python - an interpreted object-oriented programming language
'''
os.system("python")
def ui_command_ipython(self):
'''
ipython - An Enhanced Interactive Python
'''
os.system("ipython")
def ui_command_bash(self):
'''
bash - GNU Bourne-Again SHell
'''
os.system("bash")
class System(configshell.node.ConfigNode):
def __init__(self, parent):
configshell.node.ConfigNode.__init__(self, 'system', parent)
Processes(self)
Storage(self)
def ui_command_uname(self):
'''
Displays the system uname information.
'''
os.system("uname -a")
def ui_command_lsmod(self):
'''
lsmod - program to show the status of modules in the Linux Kernel
'''
os.system("lsmod")
def ui_command_lspci(self):
'''
lspci - list all PCI devices
'''
os.system("lspci")
def ui_command_lsusb(self):
'''
lsusb - list USB devices
'''
os.system("lsusb")
def ui_command_lscpu(self):
'''
lscpu - CPU architecture information helper
'''
os.system("lscpu")
def ui_command_uptime(self):
'''
uptime - Tell how long the system has been running.
'''
os.system("uptime")
class Storage(configshell.node.ConfigNode):
def __init__(self, parent):
configshell.node.ConfigNode.__init__(self, 'storage', parent)
def ui_command_lsscsi(self):
'''
lsscsi - list SCSI devices (or hosts) and their attributes
'''
os.system("lsscsi")
def ui_command_du(self):
'''
du - estimate file space usage
'''
os.system("du -hs /")
def ui_command_df(self):
'''
df - report file system disk space usage
'''
os.system("df -h")
def ui_command_uuidgen(self):
'''
uuidgen - command-line utility to create a new UUID value.
'''
os.system("uuidgen")
class Processes(configshell.node.ConfigNode):
def __init__(self, parent):
configshell.node.ConfigNode.__init__(self, 'processes', parent)
def ui_command_top(self):
'''
top - display Linux tasks
'''
os.system("top")
def ui_command_ps(self):
'''
ps - report a snapshot of the current processes.
'''
os.system("ps aux")
def ui_command_pstree(self):
'''
pstree - display a tree of processes
'''
os.system("pstree")
class Users(configshell.node.ConfigNode):
def __init__(self, parent):
configshell.node.ConfigNode.__init__(self, 'users', parent)
def ui_command_who(self):
'''
who - show who is logged on
'''
os.system("who")
def ui_command_whoami(self):
'''
whoami - print effective userid
'''
os.system("whoami")
def ui_command_users(self):
'''
users - print the user names of users currently logged in.
'''
os.system("users")
def main():
shell = configshell.shell.ConfigShell('~/.cfgshell')
root_node = MySystemRoot(shell)
shell.run_interactive()
if __name__ == "__main__":
main()
|