import subprocess
import threading
import time
class terminal(threading.Thread):
def run(self):
self.prompt()
def prompt(self):
x = True
while x:
command = raw_input()
x = self.interpret(command)
def interpret(self,command):
if command == 'exit':
#_conf.cancel()
#_conf.allclear.wait()
return False
else:
print 'Invalid Command'
return True
command = 'java -jar ../bukkit/craftbukkit.jar'
#startcmd = 'java -Xmx' + str(self.config['start_heap']) + 'M -Xms' + str(self.config['max_heap']) + 'M -jar ' + str(path)
#stopcmd = 'screen -S ' + self.config['screen_bukkit'] + ' -p 0 -X stuff "`printf "stop\r"`"'
term = terminal()
term.start()
p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while (p.poll() == None):
line = p.stderr.readline()
if not line: break
print line.strip()
time.sleep(0.1)
这是我的简化代码。运行时没有错误但是当在终端类中键入raw_input()时,我提示的类型不会出现。怎么了?
答案 0 :(得分:0)
raw_input
将提示文本作为参数,默认为空字符串。尝试将其更改为raw_input("input: ")
或类似的内容。