当前位置: 首页>>代码示例>>Python>>正文


Python colors.color方法代码示例

本文整理汇总了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 
开发者ID:COMP1511UNSW,项目名称:dcc,代码行数:20,代码来源:drive_gdb.py

示例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() 
开发者ID:Pyrlang,项目名称:Pyrlang,代码行数:42,代码来源:e07_py_monitor_erlang.py

示例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() 
开发者ID:Pyrlang,项目名称:Pyrlang,代码行数:42,代码来源:e06_py_link_erlang.py

示例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) 
开发者ID:Pyrlang,项目名称:Pyrlang,代码行数:13,代码来源:e05_erl_link_monitor_python.py

示例5: color_tag

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_tag(text):
        return color(text, fg=231, bg=239, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例6: color_next

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_next(text):
        return color(text, fg=231, bg=28, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例7: color_version

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_version(text):
        return color(text, fg=255, bg=25, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例8: color_promoted

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_promoted(text):
        return color(text, fg=255, bg=33, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例9: color_warn

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def color_warn(text):
        return color(text, fg=214, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例10: bold

# 需要导入模块: import colors [as 别名]
# 或者: from colors import color [as 别名]
def bold(text):
        return color(text, style='bold') 
开发者ID:manuelbua,项目名称:gitver,代码行数:4,代码来源:termcolors.py

示例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) 
开发者ID:manuelbua,项目名称:gitver,代码行数:7,代码来源:termcolors.py

示例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) 
开发者ID:manuelbua,项目名称:gitver,代码行数:7,代码来源:termcolors.py

示例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) 
开发者ID:manuelbua,项目名称:gitver,代码行数:7,代码来源:termcolors.py

示例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) 
开发者ID:manuelbua,项目名称:gitver,代码行数:7,代码来源:termcolors.py

示例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) 
开发者ID:COMP1511UNSW,项目名称:dcc,代码行数:33,代码来源:start_gdb.py


注:本文中的colors.color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。