How to use colored - 10 common examples

To help you get started, we’ve selected a few colored examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nk412 / corella / hnossa.py View on Github external
def draw_row(cells):
	for n_cell, cell in enumerate(cells):
		val = int((float(cell)+1) // (2/(len(GRADIENT)-1)))
		print('{color}{c}{c}{c}{c}{reset}'.format(
			color=fg(GRADIENT_COLORS[val]),
			c=GRADIENT[val],
			reset=attr('reset')
			), end='')
github gwen001 / pentest-tools / openredirect.py View on Github external
t_payloads.append( args.payloads )
    n_payloads = len(t_payloads)
    sys.stdout.write( '%s[+] %d payloads found: %s%s\n' % (fg('green'),n_payloads,args.payloads,attr(0)) )
else:
    n_payloads = 0

t_path = [ '' ]
if args.path:
    if os.path.isfile(args.path):
        fp = open( args.path, 'r' )
        t_path = fp.read().strip().split("\n")
        fp.close()
    else:
        t_path.append( args.path )
n_path = len(t_path)
sys.stdout.write( '%s[+] %d path found: %s%s\n' % (fg('green'),n_path,args.path,attr(0)) )

if args.verbose:
    _verbose = int(args.verbose)
else:
    _verbose = 1

if args.threads:
    _threads = int(args.threads)
else:
    _threads = 10

if args.redirect:
    t_redirect_domain = [ args.redirect.lower() ]
else:
    t_redirect_domain = [ 'google.com', 'www.google.com', '216.58.214.206' ]
github gwen001 / pentest-tools / quickhits.py View on Github external
def saveFile( d_output, t_urlparse, r ):
    # filename = t_urlparse.path.strip('/')
    filename = t_urlparse.path
    filename = re.sub( '[^0-9a-zA-Z_\-\.]', '_', filename )
    d_output = d_output +  '/' + t_urlparse.netloc
    f_output = d_output + '/' + filename
    # print(f_output)
    
    if not os.path.isdir(d_output):
        try:
            os.makedirs( d_output )
        except Exception as e:
            sys.stdout.write( "%s[-] error occurred: %s%s\n" % (fg('red'),e,attr(0)) )
            return
    
    s_headers = 'HTTP/1.1 ' + str(r.status_code) + ' ' + r.reason + "\n"
    for k,v in r.headers.items():
        s_headers = s_headers + k + ': ' + v + "\n"

    # print(s_headers)
    content = s_headers + "\n" + r.text
    fp = open( f_output, 'w' )
    fp.write( content )
    fp.close()
github mike820324 / microProxy / tests / viewer / test_console.py View on Github external
def test_fg_and_bg(self):
        self.assertEqual(fg("blue") + bg("blue") + "fg bg test" + attr("reset"),
                         str(ColorText("fg bg test", fg_color="blue", bg_color="blue")))
github gwen001 / pentest-tools / gitpillage.py View on Github external
sys.stdout.write( "%s[-] %s%s\n" % (fg('dark_gray'),u,attr(0)) )
        return False

    if not r.status_code == 200:
        if t_multiproc['verbose']:
            sys.stdout.write( "%s[-] %s (%d)%s\n" % (fg('dark_gray'),u,r.status_code,attr(0)) )
        return False

    filename = saveObject( output_dir, object_id, r.content )
    real_filename = output_dir + '/' + real_filename

    try:
        cmd = 'cd ' + output_dir + '; git checkout ' + tmp[1]
        output = subprocess.check_output( cmd, stderr=subprocess.STDOUT, shell=True ).decode('utf-8')
        t_multiproc['n_success'] = t_multiproc['n_success'] + 1
        display = "[+] %s (%d) %s-> %s (%d)%s\n" % (u,r.status_code,fg('cyan'),real_filename,len(r.content),attr(0))
    except Exception as e:
        if t_multiproc['verbose']:
            display = "[-] %s (%d) %s-> %s%s\n" % (u,r.status_code,fg('yellow'),e,attr(0))
        return False
    
    sys.stdout.write( display )
github osrg / gobgp / test / lib / base.py View on Github external
def yellow(s):
    return fg('yellow') + str(s) + attr('reset')