本文整理汇总了Python中ui.UI.readLine方法的典型用法代码示例。如果您正苦于以下问题:Python UI.readLine方法的具体用法?Python UI.readLine怎么用?Python UI.readLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ui.UI
的用法示例。
在下文中一共展示了UI.readLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Debugger
# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import readLine [as 别名]
#.........这里部分代码省略.........
if len(candidates) == 1: return CommandInvoker(self, candidates[0][2], candidates[0][1], options, arguments)
if len(candidates) == 0: message = "Unknown command: %s" % name
else: message = "Ambiguous command. Candidates are: %s" % ", ".join([name0 for name0, realname0, command0 in candidates])
raise DebuggerError, message
def execute(self, lines, withCurrentSession=None, withCurrentRuntime=None):
currentSessionBefore = self.__currentSession
currentRuntimeBefore = currentSessionBefore and currentSessionBefore.getCurrentRuntime()
if withCurrentRuntime: withCurrentSession = withCurrentRuntime.getSession()
if withCurrentSession:
self.__currentSession = withCurrentSession
if withCurrentRuntime:
withCurrentSession.setCurrentRuntime(withCurrentRuntime)
try:
previousLines = self.__currentLines
self.__currentLines = lines[:]
while self.__currentLines:
line = self.__currentLines.pop(0)
if line:
output = self.getCommandInvoker(line)()
if output: self.getUI().writeln(*output)
finally:
self.__currentLines = previousLines
if withCurrentSession:
self.__currentSession = currentSessionBefore
if withCurrentRuntime and currentSessionBefore:
currentSessionBefore.setCurrentRuntime(currentRuntimeBefore)
def executeLater(self, lines, withCurrentSession=None, withCurrentRuntime=None):
self.__commandQueueLock.acquire()
try: self.__commandQueue.append((lines, withCurrentSession, withCurrentRuntime))
finally: self.__commandQueueLock.release()
def readLine(self, prompt):
if type(prompt) == type(""): prompt = lambda value=prompt: value
if self.__currentLines: return self.__currentLines.pop(0)
else: return self.__ui.readLine(prompt)
def isStopped(self):
return self.getCurrentThread() and self.getCurrentThread().getStatus() == ESThread.STATUS_STOPPED
def getPrompt(self):
try:
if not self.getCurrentSession(): return "(sessionless) "
elif not self.getCurrentThread(): return "(idle) "
elif self.getCurrentThread().getStatus() == ESThread.STATUS_STOPPED: return "(stopped) "
elif self.getCurrentThread().getStatus() == ESThread.STATUS_RUNNING: return "(running) "
else: return "(confused) "
except AttributeError:
return "(weird exception)"
def run(self, lines):
self.__socketmanager.start()
try: self.__ui.start("Opera ECMAScript debugger\n")
except:
logger.logException()
logger.logFatal("UI failure, exiting.")
else:
lastLine = None
withCurrentSession, withCurrentRuntime = None, None
while not self.__quit:
if not lines:
try:
line = self.__ui.readLine(self.getPrompt, TabCompleter(self))
if line is None:
self.__quit = True
break
if not line.strip():
if lastLine: line = lastLine
else: continue
else: lastLine = line.split(" ")[0]
lines = [line]
withCurrentSession, withCurrentRuntime = None, None
except:
logger.logException()
logger.logFatal("UI failure, exiting.")
break
try: self.execute(lines, withCurrentSession, withCurrentRuntime)
except CommandError, error: self.__ui.writeln(error[0])
except DebuggerError, error: self.__ui.writeln(error[0])
except:
logger.logException()
self.__ui.writeln("Internal debugger error.")
self.__commandQueueLock.acquire()
try:
if self.__commandQueue: lines, withCurrentSession, withCurrentRuntime = self.__commandQueue.pop(0)
else: lines, withCurrentSession, withCurrentRuntime = [], None, None
finally: self.__commandQueueLock.release()