本文整理汇总了Python中readline.redisplay函数的典型用法代码示例。如果您正苦于以下问题:Python redisplay函数的具体用法?Python redisplay怎么用?Python redisplay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redisplay函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _run_printer
def _run_printer(self):
"""A thread to print messages to the command line."""
while(True):
# See if we have anything to print
loop = True
printed = False
self.output_lock.acquire()
while(loop):
try:
msg = self.print_queue.get_nowait()
print msg
printed = True
except Queue.Empty:
loop = False
if printed:
readline.redisplay()
self.output_lock.release()
# Reprint the prompt and the user's current input if necessary
if printed:
self.readline_lock.acquire()
readline.redisplay()
self.readline_lock.release()
# See if we need to terminate
if self.print_terminate.isSet():
return
# Wait until we have something to print again
self.print_event.wait()
self.print_event.clear()
开发者ID:smbz,项目名称:vns,代码行数:34,代码来源:ti2.py
示例2: display
def display(self, msg, modifier=None):
if not type(msg) is unicode:
# force output unicode string to output
# Python will hopefully handle output printing
msg=obj2utf8(msg)
if msg:
if modifier=="error":
self.stdout.write(PupyCmd.format_error(msg))
elif modifier=="success":
self.stdout.write(PupyCmd.format_success(msg))
elif modifier=="info":
self.stdout.write(PupyCmd.format_info(msg))
elif modifier=="srvinfo":
buf_bkp=readline.get_line_buffer()
#nG move cursor to column n
#nE move cursor ro the beginning of n lines down
#nK Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.
self.stdout.write("\x1b[0G"+PupyCmd.format_srvinfo(msg)+"\x1b[0E")
self.stdout.write("\x1b[2K")#clear line
self.stdout.write(self.raw_prompt+buf_bkp)#"\x1b[2K")
try:
readline.redisplay()
except Exception:
pass
elif modifier=="warning":
self.stdout.write(PupyCmd.format_warning(msg))
else:
self.stdout.write(PupyCmd.format_log(msg))
开发者ID:kai5263499,项目名称:pupy,代码行数:28,代码来源:PupyCmd.py
示例3: pre_input_hook
def pre_input_hook():
readline.insert_text(display.display(
thing, shortid=False, colored=False))
readline.redisplay()
# Unset the hook again
readline.set_pre_input_hook(None)
开发者ID:thomasvs,项目名称:mushin,代码行数:7,代码来源:main.py
示例4: newEmitFn
def newEmitFn(*args, **kwargs):
oldEmitFn(*args, **kwargs)
global _previousReadlineBufferContents
b = readline.get_line_buffer()
if b != _previousReadlineBufferContents:
readline.redisplay()
_previousReadlineBufferContents = b
开发者ID:bsparacino,项目名称:xbee-homeautomation,代码行数:7,代码来源:setuputil.py
示例5: display_hook
def display_hook(prompt, session, context, matches, longest_match_len):
# type: (str, ShellSession, BundleContext, List[str], int) -> None
"""
Displays the available services matches and the service details
:param prompt: Shell prompt string
:param session: Current shell session (for display)
:param context: BundleContext of the shell
:param matches: List of words matching the substitution
:param longest_match_len: Length of the largest match
"""
# Prepare a line pattern for each match (-1 for the trailing space)
match_pattern = "{{0: <{}}} from {{1}}".format(longest_match_len - 1)
# Sort matching names
matches = sorted(match for match in matches)
# Print the match and the associated name
session.write_line()
with use_ipopo(context) as ipopo:
for factory_name in matches:
# Remove the spaces added for the completion
factory_name = factory_name.strip()
bnd = ipopo.get_factory_bundle(factory_name)
session.write_line(
match_pattern, factory_name, bnd.get_symbolic_name()
)
# Print the prompt, then current line
session.write(prompt)
session.write_line_no_feed(readline.get_line_buffer())
readline.redisplay()
开发者ID:tcalmant,项目名称:ipopo,代码行数:32,代码来源:ipopo.py
示例6: redisplay
def redisplay ( self ):
if util.isPlatformWindows ():
import pyreadline
Readline ().redisplay ()
else:
import readline
readline.redisplay ()
开发者ID:Juniper,项目名称:OpenClos,代码行数:7,代码来源:cli.py
示例7: recv
def recv(h):
while True:
msg = yield h.recv()
if msg.frm and msg.body:
# msg.frm.partition('/')[0]
print '< %s'%(msg.body.cdata,)
if readline:
readline.redisplay()
开发者ID:ikatson,项目名称:p2p-sip,代码行数:8,代码来源:gchat.py
示例8: printf
def printf(self, string):
#readline.set_startup_hook(lambda: readline.insert_text("{0}".format(str)) or readline.redisplay())
self.stdout.write(str("\n{0}\n".format(string))+"\n")
self.stdout.flush()
#readline.parse_and_bind('\C-M')
readline.insert_text("oi\n")
#readline.parse_and_bind('\\n')
readline.redisplay()
开发者ID:iacchus,项目名称:vosh,代码行数:8,代码来源:Shell.py
示例9: sighandler
def sighandler(signum, frame):
'''Clean and tidy shutdown when killed.'''
if po.opts.debug: ps_lib.msg('debug', 'Signal %s received.' % signum)
#print 'removing:', readline.remove_history_item(readline.get_current_history_length()-1)
# how to clear the line buffer? there doesn't seem to be a function to do it.
print
readline.redisplay()
if signum == signal.SIGINT: sigintreceived = True
开发者ID:Recaiden,项目名称:pysh,代码行数:8,代码来源:ps_init.py
示例10: pre_input_hook
def pre_input_hook(self):
"""If a line buffer has been filled then inject it into the readline
buffer for the user to edit."""
if self.line_buffer:
readline.insert_text(
self.line_buffer.decode(ex_config.FILE_ENCODING).rstrip('\n'))
readline.redisplay()
self.line_buffer = None
开发者ID:DerekMarshall,项目名称:py-ex,代码行数:8,代码来源:ex.py
示例11: match_display_hook
def match_display_hook(substitution, matches, longest_match_length):
## Unused args are ok. pylint: disable=W0613
""" Cleaner display for line completion """
print '\n--- possible matches ---'
for match in matches:
print match
#print self.prompt.rstrip(),
print '------------------------'
print readline.get_line_buffer(),
readline.redisplay()
开发者ID:Michael-F-Ellis,项目名称:TransLily,代码行数:10,代码来源:rl_interface.py
示例12: color_print
def color_print(message, printed_color="\033[37m"):
"""Formats a message with a specific color (as Display.color)"""
line_buffer = readline.get_line_buffer()
preface = len(line_buffer) * "\b \b"
print(
"{0}{1}{2}{3}\n{4}".format(preface, printed_color, message, Display.color.end, line_buffer),
end="",
flush=True,
)
readline.redisplay()
开发者ID:etkirsch,项目名称:pyna-colada,代码行数:10,代码来源:Display.py
示例13: main
def main():
global server
global commandLine
host = None
port = None
if len(sys.argv[1:]) == 1:
host = socket.gethostname()
port = sys.argv[1]
if len(sys.argv[1:]) == 2:
host = sys.argv[1]
port = sys.argv[2]
if host and port:
print 'Starting Crossfire client on ' + host + ':' + port
client = CrossfireClient(host, int(port))
commandLine = CommandLine()
try:
client.start()
commandLine.start()
print "Sending version command...\n"
command = Command("", "version")
client.sendPacket(command)
print "Listing contexts...\n"
command = Command("", "listcontexts")
client.sendPacket(command)
while True:
packet = client.getPacket()
if packet:
print
json.dump(packet, sys.stdout, sort_keys=True, indent=2)
print "\n" + COMMAND_PROMPT,
readline.redisplay()
if 'event' in packet and packet['event'] == "closed":
client.restart()
command = commandLine.getCommand()
if command:
print "\nSending command => " + command.command
client.sendPacket(command)
except (KeyboardInterrupt):
pass
else:
print 'No host and/or port specified.'
print 'Usage: $> python crossfire_test_client.py [<host>] <port>'
quit()
开发者ID:king122909,项目名称:Firebug,代码行数:55,代码来源:crossfire_test_client.py
示例14: complete
def complete(self, text, state):
if not text:
readline.insert_text(' ')
if TabCompleter.uses_editline:
# It won't move the cursor for us, apparently
sys.stdout.write('\x1b[4C')
readline.redisplay()
sys.stdout.flush()
return None
else:
return rlcompleter.Completer.complete(self, text, state)
开发者ID:tipabu,项目名称:dot-files,代码行数:11,代码来源:startup.py
示例15: readline_display_matches_hook
def readline_display_matches_hook(self, substitution, matches, longest_match_length):
self.logger.debug('Readline display matches hook:\n substitution=%s, matches=%s longtest_match_length=%s' % \
(substitution, matches, longest_match_length))
print
for match in matches:
print match
print "%s%s" % (self.prompt, readline.get_line_buffer()),
readline.redisplay()
开发者ID:lpther,项目名称:SysadminToolkit,代码行数:11,代码来源:cmdprompt.py
示例16: complete
def complete(self, text, state):
readline.redisplay()
if state == 0:
if text:
self.matches = [s for s in self.options
if s and s.lower().startswith(text.lower())]
else:
self.matches = self.options[:]
try:
return self.matches[state]
except IndexError:
return None
开发者ID:flywire,项目名称:qifqif,代码行数:12,代码来源:ui.py
示例17: completer
def completer(text, state):
try:
options = _getPyCompletions(text)
except Exception as e:
print("\n%s" % e)
sys.stdout.write("> %s" % text)
sys.stdout.flush()
readline.redisplay()
return None
if state < len(options):
return options[state]
else:
return None
开发者ID:BMXE,项目名称:music-player,代码行数:13,代码来源:shell.py
示例18: poll
def poll(self):
milliseconds = self.timeout * 1000
for fd, _ in self._poller.poll(milliseconds):
if fd == self.conn_fd:
data = self.sock.recv(1024*1024)
sys.stdout.write(data.decode('utf8'))
sys.stdout.flush()
readline.redisplay()
elif fd == self.read_fd:
data = os.read(self.read_fd, 1024)
self.sock.sendall(data)
else:
raise RuntimeError("Unknown FD %s" % fd)
开发者ID:ionelmc,项目名称:python-manhole,代码行数:13,代码来源:cli.py
示例19: handler
def handler(signum, frame):
cli = get_cli()
if cli != None:
if cli.executing_command() == True:
return
try:
bcli_exit()
except NameError:
# If there is no a bcli_exit function
# defined, end execution
# The core lib include a bcli_exit at restrictedmodes.py
sys.exit()
get_cli().redisplay()
readline.redisplay()
else:
sys.exit()
开发者ID:aleasoluciones,项目名称:boscli-oss-core,代码行数:17,代码来源:boscli.py
示例20: __exec_line__
def __exec_line__(self, line):
r"""Execute the input line.
emptyline: no-op
unknown command: print error message
known command: invoke the corresponding method
The parser method, parse_line(), can be overriden in subclasses to
apply different parsing rules. Please refer to the doc string of
parse_line() for complete information.
Arguments:
line: A string, representing a line of input from the shell. This
string is preprocessed by cmdloop() to convert the EOF character
to '\x04', i.e., 'D' - 64, if the EOF character is the only
character from the shell.
"""
# Ignoe empty lines and lines starting with a pound sign.
if not line or line.rstrip().startswith('#'):
return
cmd, args = ( '', [] )
toks = shlex.split(line)
if not toks:
return
if line == _ShellBase.EOF:
# This is a hack to allow the EOF character to behave exactly like
# typing the 'exit' command.
readline.insert_text('exit\n')
readline.redisplay()
cmd = 'exit'
elif toks and toks[0] in self._cmd_map_internal.keys():
cmd = toks[0]
args = toks[1:] if len(toks) > 1 else []
else:
cmd, args = self.parse_line(line)
if not cmd in self._cmd_map_all.keys():
self.stderr.write("{}: command not found\n".format(cmd))
return
func_name = self._cmd_map_all[cmd]
func = getattr(self, func_name)
return func(cmd, args)
开发者ID:qzmfranklin,项目名称:easyshell,代码行数:46,代码来源:base.py
注:本文中的readline.redisplay函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论