#Dash Shell
import os
import datetime
class LocalComputer:
pass
def InitInformation():
Home = LocalComputer()
#Acquires user information
if (os.name == "nt"):
Home.ComputerName = os.getenv("COMPUTERNAME")
Home.Username = os.getenv("USERNAME")
Home.Homedir = os.getenv("HOMEPATH")
else:
Home.ComputerName = os.getenv("HOSTNAME")
Home.Username = os.getenv("USER")
Home.Homedir = os.getenv("HOME")
return Home
def MainShellLoop():
print ("--- Dash Shell ---")
Home = InitInformation()
userinput = None
currentdir = Home.Homedir
while (userinput != "exit"):
rightnow = datetime.datetime.now()
try:
userinput = input(str(Home.ComputerName) + "\\" + str(Home.Username) + ":" + str(rightnow.month) + "/" + str(rightnow.day) + "/" + str(rightnow.year) + "@" + str(currentdir))
except:
print("Invalid Command specified, please try again")
MainShellLoop()
input()
应该执行,并在更改了我不记得的内容后停止工作
它使用Windows 7在Python 3.1.2下编码,我知道Unix主机名全局变量是错误的
我知道userinput
什么都不做,我想在继续
由于
它什么都不输出
答案 0 :(得分:1)
您定义了一个类和两个函数,但您似乎无法在任何地方调用它们。你到底错过了对MainShellLoop()
的电话吗?
答案 1 :(得分:0)
我认为您需要拨打MainShellLoop
。