-
Notifications
You must be signed in to change notification settings - Fork 0
/
Command.py
33 lines (24 loc) · 1.01 KB
/
Command.py
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
import os
import re
import datetime
class Command_Moduler:
def __init__(self):
self.print_info()
def print_info(self):
print('FACOS starts ', datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
def get_command_list(self, user, path): # , cwd, file_list):
output_list = []
try:
# commands = input(cwd + '$ ').split(';') # cwd就是当前路径,在真正的操作系统中会显示在命令行输入的开头
commands_list = input('\033[1;36m' + user + '\033[0m' + ':' + '\033[34m' + path + '\033[0m' + '$ ').split(
';') # command用分号隔开各指令
except BaseException:
commands_list = []
for command in commands_list:
output_list.append(command.split()) # 中间多空格的情况可省略
return output_list
if __name__ == '__main__':
command_dealer = Command_Moduler()
while True:
command = command_dealer.get_command_list('hello', 'root/')
print(command)