本文整理汇总了Python中colors.color方法的典型用法代码示例。如果您正苦于以下问题:Python colors.color方法的具体用法?Python colors.color怎么用?Python colors.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类colors
的用法示例。
在下文中一共展示了colors.color方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clarify_expression_value
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def clarify_expression_value(expression_value, expression_type, color):
debug_print(3, 'clarify_value expression_value=', expression_value)
if expression_type == 'char':
m = re.match(r"^(-?\d+) '(.*)'$", expression_value)
if m:
ascii = int(m.group(1))
if (0 < ascii < 9) or (13 < ascii < 32) or (ascii == 127):
expression_value = '%d (non-printable ASCII character)' % ascii
elif ascii < 0 or ascii > 128:
expression_value = '%d (not valid ASCII)' % ascii
elif ascii == 0:
expression_value = "0 = '\\0'"
else:
expression_value = "%s = '%s'" % m.groups()
return clarify_values(expression_value, color)
# transform value into something a novice programmer more likely to understand
示例2: main
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def main():
node = Node(node_name="py@127.0.0.1", cookie="COOKIE")
event_loop = node.get_loop()
#
# 1. At the same time as P1 (they should not interfere) create a process P2
# Send a message to process example7 on the Erlang node with "test_monitor"
# command. This will spawn an Erlang process and tell us the pid.
# Reply from Erlang node will trigger next steps above in ExampleProcess6
#
proc = MonitorExample7()
LOG.info("Sending {example7, test_monitor, %s} to remote 'example7'" % proc.pid_)
remote_receiver_name = (Atom('erl@127.0.0.1'), Atom("example7"))
send_task = node.send(sender=proc.pid_,
receiver=remote_receiver_name,
message=(Atom("example7"),
Atom("test_monitor"),
proc.pid_))
sleep_sec = 5
LOG.info("Sleep %d sec" % sleep_sec)
#
# 3. End, sending a stop message
#
def stop_task():
LOG.info(color("Stopping remote loop", fg="red"))
node.send_nowait(sender=proc.pid_, receiver=remote_receiver_name,
message=(Atom("example7"), Atom("stop")))
def destroy_task():
LOG.error("Destroying")
node.destroy()
LOG.error("Done")
event_loop.create_task(send_task)
event_loop.call_later(sleep_sec, stop_task)
event_loop.call_later(2 * sleep_sec, destroy_task)
node.run()
示例3: main
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def main():
node = Node(node_name="py@127.0.0.1", cookie="COOKIE")
event_loop = node.get_loop()
#
# 1. Create a process P1
# Send a message to process example6 on the Erlang node with "test_link"
# command. This will spawn an Erlang process and tell us the pid.
# Reply from Erlang node will trigger next steps above in ExampleProcess6
#
p1 = LinkExample6()
LOG.info("Sending {example6, test_link, %s} to remote 'example6'" % p1.pid_)
remote_receiver_name = (Atom('erl@127.0.0.1'), Atom("example6"))
def send_task():
node.send_nowait(sender=p1.pid_,
receiver=remote_receiver_name,
message=(Atom("example6"), Atom("test_link"), p1.pid_))
sleep_sec = 5
LOG.info("Sleep %d sec" % sleep_sec)
#
# 3. End, sending a stop message
#
def task_sleep1():
LOG.info(color("Stopping remote loop", fg="red"))
node.send_nowait(sender=p1.pid_,
receiver=remote_receiver_name,
message=(Atom("example6"), Atom("stop")))
def task_sleep2():
node.destroy()
LOG.error("Done")
event_loop.call_soon(send_task)
event_loop.call_later(sleep_sec, task_sleep1)
event_loop.call_later(2 * sleep_sec, task_sleep2)
node.run()
示例4: exit
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def exit(self, reason=None):
LOG.info("TestMonitorProcess: Received EXIT(%s)" % reason)
node = self.get_node()
#
# 3. End, sending a stop message
#
LOG.info(color("Stopping erlang node", fg="red"))
node.send_nowait(sender=self.pid_, receiver=remote_receiver_name(),
message=(Atom("example5"), Atom("stop")))
LOG.error("Done")
super().exit(reason)
示例5: color_tag
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_tag(text):
return color(text, fg=231, bg=239, style='bold')
示例6: color_next
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_next(text):
return color(text, fg=231, bg=28, style='bold')
示例7: color_version
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_version(text):
return color(text, fg=255, bg=25, style='bold')
示例8: color_promoted
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_promoted(text):
return color(text, fg=255, bg=33, style='bold')
示例9: color_warn
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_warn(text):
return color(text, fg=214, style='bold')
示例10: bold
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def bold(text):
return color(text, style='bold')
示例11: tag
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def tag(self, text):
"""
Decorate the specified text with the TAG color class
"""
return self.__decorate(text, color_tag)
示例12: next
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def next(self, text):
"""
Decorate the specified text with the NEXT color class
"""
return self.__decorate(text, color_next)
示例13: ver
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def ver(self, text):
"""
Decorate the specified text with the VERSION color class
"""
return self.__decorate(text, color_version)
示例14: prom
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def prom(self, text):
"""
Decorate the specified text with the PROMOTED color class
"""
return self.__decorate(text, color_promoted)
示例15: watch_stdin_for_valgrind_errors
# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def watch_stdin_for_valgrind_errors():
colorize_output = sys.stderr.isatty() or os.environ.get('DCC_COLORIZE_OUTPUT', False)
if colorize_output:
color = colors.color
else:
color = lambda text, color_name: text
debug_level = int(os.environ.get('DCC_DEBUG', '0'))
while True:
line = sys.stdin.readline()
if not line:
break
if debug_level > 1: print('valgrind: ', line, file=sys.stderr)
if 'vgdb me' in line:
error = 'Runtime error: ' + color('uninitialized variable accessed', 'red') + '.'
os.environ['DCC_VALGRIND_ERROR'] = error
print('\n'+error, file=sys.stderr)
sys.stderr.flush()
start_gdb()
sys.exit(0)
elif 'loss record' in line:
line = sys.stdin.readline()
if 'malloc' in line:
line = sys.stdin.readline()
m = re.search(r'(\S+)\s*\((.+):(\d+)', line)
if m:
print('Error: free not called for memory allocated with malloc in function {} in {} at line {}.'.format(m.group(1),m.group(2),m.group(3)), file=sys.stderr)
else:
print('Error: free not called for memory allocated with malloc.', file=sys.stderr)
else:
print('Error: memory allocated not de-allocated.', file=sys.stderr)
sys.exit(0)