Python console.set_color() Examples

The following are 11 code examples of console.set_color(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module console , or try the search function .
Example #1
Source File: system.py    From blackmamba with MIT License 6 votes vote down vote up
def catch_exceptions(func):
    """Decorator catching all exceptions and printing info to the console.

    Use this decorator for functions handling keyboard shortcuts,
    keyboard events, ... to avoid Pythonista crash.

    Args:
        func: Function to decorate

    Returns:
        Return value of decorated function.
    """
    @functools.wraps(func)
    def new_func(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception:
            if console:
                console.set_color(1, 0, 0)
            print(traceback.format_exc())
            print('Please, file an issue at {}'.format('https://github.com/zrzka/blackmamba/issues'))
            if console:
                console.set_color()

    return new_func 
Example #2
Source File: print_objc.py    From pythonista-scripts with MIT License 6 votes vote down vote up
def print_methods(clsname,print_private=False):
   cls=ObjCClass(clsname)
   console.set_color(1,0,0)
   print clsname
   print 'Class Methods______'
   console.set_color(0,0,0)
   m=get_class_methods(cls)
   print '\n'.join([(k[1]+' ' +k[0]+'( '+', '.join(k[2])+' )') for k in m if not k[0].startswith('_')])
   if print_private:
         print '\n'.join([(k[1]+' ' +k[0]+'( '+', '.join(k[2])+' )') for k in m if k[0].startswith('_')])
   console.set_color(1,0,0)
   print '_______Instance Methods______'
   console.set_color(0,0,0)
   m=get_methods(cls)
   print '\n'.join([(k[1]+'\t' +k[0]+'( '+', '.join(k[2])+' )') for k in m if not k[0].startswith('_')])
   if print_private:
         print '\n'.join([(k[1]+'\t' +k[0]+'( '+', '.join(k[2])+' )') for k in m if k[0].startswith('_')]) 
Example #3
Source File: krack.py    From networking with GNU General Public License v3.0 5 votes vote down vote up
def green():
	console.set_color(0.3,0.7,0) 
Example #4
Source File: krack.py    From networking with GNU General Public License v3.0 5 votes vote down vote up
def yellow():
	console.set_color(0.7,0.6,0) 
Example #5
Source File: krack.py    From networking with GNU General Public License v3.0 5 votes vote down vote up
def noc():
	console.set_color() 
Example #6
Source File: elpscrk.py    From elpscrk with GNU General Public License v3.0 5 votes vote down vote up
def set_color(r=False,g=False,b=False,c=False):
			if b:
				sys.stdout.write("\xb1[34m")
			else:
				sys.stdout.write("\xb1[0m") 
Example #7
Source File: elpscrk.py    From elpscrk with GNU General Public License v3.0 5 votes vote down vote up
def terminal(text=False,inp=False):
	console.set_color(0.0,0.3,0.8)
	sys.stdout.write("root@elliot:$ ")
	console.set_color()
	if text == False:
		return raw_input()
	else:
		if inp:
			return raw_input(text)
		else:
			print text 
Example #8
Source File: diff.py    From stash with MIT License 5 votes vote down vote up
def diff(lhs,rhs):
    if not os.path.isfile(lhs):
        sys.stderr.write('%s not a file\n'%lhs)
        sys.exit(1)
    if os.path.isdir(rhs):
        rhs = '%s/%s'%(rhs,os.path.basename(lhs))
    if not os.path.isfile(rhs):
        sys.stderr.write('%s not a file\n'%rhs)
        sys.exit(1)
        
    flhs = open(lhs).readlines()
    frhs = open(rhs).readlines()
    
    diffs = unified_diff(
        flhs,
        frhs,
        fromfile=lhs,
        tofile=rhs,
        fromfiledate=modified(lhs),
        tofiledate=modified(rhs)
    )
    for line in diffs:
        if line.startswith('+'):
            console.set_color(0,1,0)
        if line.startswith('-'):
            console.set_color(0,0,1)
            sys.stdout.write(line)
        console.set_color(1,1,1)
    return

#_____________________________________________________ 
Example #9
Source File: log.py    From blackmamba with MIT License 5 votes vote down vote up
def _log(level, *args, **kwargs):
    if _level > level:
        return

    color = _COLORS.get(level, None)
    if console and color:
        console.set_color(*color)

    print(*args, **kwargs)

    if console and color:
        console.set_color() 
Example #10
Source File: AestheticAssembly.py    From networking with GNU General Public License v3.0 4 votes vote down vote up
def spectre():
	time.sleep(1)
	console.set_font("Menlo",10)
	console.set_color(0.9,0,0)
	print "\n"
	print logo
	print
	time.sleep(2.5)
	console.set_color()
	console.set_font("Menlo",7)
	pr = pointer(47839215)
	lc = False
	for _ in range(500*2):
		if lc:
			console.set_color()
			lc = False
		if not random.randint(0,35):
			console.set_color(1,0,0)
			lc = True
		o1 = pr.next()+"  "+seg1()+" "+seg2()
		o2 = pr.next()+" "*25+seg2()
		o3 = pr.next()
		print random.choice([o1,o1,o1,o2,o2,o3])
		if lc:
			time.sleep(0.02)
		time.sleep(0.01)
	
	console.set_font("Menlo",8.62)
	console.set_color(0.9,0,0)
	print "\n"
	for _ in melt.split("\n"):
		print _
		time.sleep(0.01)
	time.sleep(2.5)
	console.set_color()
	console.set_font("Menlo",14)
	typeit("Leaking Memory "+"."*18+" [  OK  ]")
	pr = pointer(47839215)
	print
	for _ in range(5000):
		sys.stdout.write("\rMemory Address "+"."*12+" [ "+pr.next()+" ]")
		time.sleep(0.01) 
Example #11
Source File: printer.py    From bili2.0 with MIT License 4 votes vote down vote up
def print_danmu(self, danmu_msg: dict):
        if not self.danmu_control:
            return
        danmu_msg_info = danmu_msg['info']

        list_msg = []
        list_color = []
        if danmu_msg_info[7] == 3:
            # print('舰', end=' ')
            list_msg.append('⚓️ ')
            list_color.append([])
        else:
            if danmu_msg_info[2][3] == 1:
                if danmu_msg_info[2][4] == 0:
                    list_msg.append('爷 ')
                    list_color.append(self.dic_color['others']['vip'])
                else:
                    list_msg.append('爷 ')
                    list_color.append(self.dic_color['others']['svip'])
            if danmu_msg_info[2][2] == 1:
                list_msg.append('房管 ')
                list_color.append(self.dic_color['others']['admin'])

            # 勋章
            if danmu_msg_info[3]:
                list_color.append(self.dic_color['fans-level'][f'fl{danmu_msg_info[3][0]}'])
                list_msg.append(f'{danmu_msg_info[3][1]}|{danmu_msg_info[3][0]} ')
            # 等级
            if not danmu_msg_info[5]:
                list_color.append(self.dic_color['user-level'][f'ul{danmu_msg_info[4][0]}'])
                list_msg.append(f'UL{danmu_msg_info[4][0]} ')

        list_msg.append(danmu_msg_info[2][1] + ':')
        try:
            if danmu_msg_info[2][7]:
                list_color.append(self.hex_to_rgb_percent(danmu_msg_info[2][7]))
            else:
                list_color.append(self.dic_color['others']['default_name'])
        except IndexError:
            print("# 小电视降临本直播间")
            list_color.append(self.dic_color['others']['default_name'])
            
        list_msg.append(danmu_msg_info[1])
        list_color.append([])
        for i, j in zip(list_msg, list_color):
            console.set_color(*j)
            print(i, end='')
        print()
        console.set_color()