Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if get_env("PYCHARM_HOSTED"): # in PyCharm disable convert/strip
colorama.init(convert=False, strip=False)
else:
colorama.init()
color = True
else:
color = False
return color
class Color(object):
""" Wrapper around colorama colors that are undefined in importing
"""
RED = Fore.RED # @UndefinedVariable
WHITE = Fore.WHITE # @UndefinedVariable
CYAN = Fore.CYAN # @UndefinedVariable
GREEN = Fore.GREEN # @UndefinedVariable
MAGENTA = Fore.MAGENTA # @UndefinedVariable
BLUE = Fore.BLUE # @UndefinedVariable
YELLOW = Fore.YELLOW # @UndefinedVariable
BLACK = Fore.BLACK # @UndefinedVariable
BRIGHT_RED = Style.BRIGHT + Fore.RED # @UndefinedVariable
BRIGHT_BLUE = Style.BRIGHT + Fore.BLUE # @UndefinedVariable
BRIGHT_YELLOW = Style.BRIGHT + Fore.YELLOW # @UndefinedVariable
BRIGHT_GREEN = Style.BRIGHT + Fore.GREEN # @UndefinedVariable
BRIGHT_CYAN = Style.BRIGHT + Fore.CYAN # @UndefinedVariable
BRIGHT_WHITE = Style.BRIGHT + Fore.WHITE # @UndefinedVariable
BRIGHT_MAGENTA = Style.BRIGHT + Fore.MAGENTA # @UndefinedVariable
if get_env("CONAN_COLOR_DARK", 0):
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
# Demonstrate the difference between colorama intialized with wrapping on and off.
# The point of the demonstration is to show how the ANSI wrapping on Windows can be disabled.
# The unwrapped cases will be interpreted with ANSI on Unix, but not on Windows.
from __future__ import print_function
import sys
import fixpath
from colorama import AnsiToWin32, init, Fore
init()
print('%sWrapped yellow going to stdout, via the default print function.' % Fore.YELLOW)
init(wrap=False)
print('%sUnwrapped CYAN going to stdout, via the default print function.' % Fore.CYAN)
print('%sUnwrapped CYAN, using the file parameter to write via colorama the AnsiToWin32 function.' % Fore.CYAN, file=AnsiToWin32(sys.stdout))
print('%sUnwrapped RED going to stdout, via the default print function.' % Fore.RED)
init()
print('%sWrapped RED going to stdout, via the default print function.' % Fore.RED)
import colorama
from colorama import Fore, Back, Style
from random import randint, choice
from string import printable
# Fore, Back and Style are convenience classes for the constant ANSI strings that set
# the foreground, background and style. The don't have any magic of their own.
FORES = [ Fore.BLACK, Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE ]
BACKS = [ Back.BLACK, Back.RED, Back.GREEN, Back.YELLOW, Back.BLUE, Back.MAGENTA, Back.CYAN, Back.WHITE ]
STYLES = [ Style.DIM, Style.NORMAL, Style.BRIGHT ]
# This assumes your terminal is 80x24. Ansi minimum coordinate is (1,1).
MINY, MAXY = 1, 24
MINX, MAXX = 1, 80
# set of printable ASCII characters, including a space.
CHARS = ' ' + printable.strip()
PASSES = 1000
def main():
colorama.init()
# gratuitous use of lambda.
pos = lambda y, x: '\x1b[%d;%dH' % (y, x)
def mainConsole():
global nextId, prevId
exit = False
while not exit:
try:
print(Fore.CYAN + Style.BRIGHT + _domain + '\\' + _username + '> ' + Fore.WHITE , end='')
command = input()
comSpl = command.split()
if comSpl[0] != 'exit':
r = executeCommand(comSpl[0])
if r == -1:
if (len(comSpl) >= 2 and comSpl[1] != 'help') or (len(comSpl) < 2):
nextId = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
filePath = baseWritePath + prevId
if _classes[len(_classes)-1].executeCommand(comSpl[0:], prevId, nextId, filePath):
content = waitAndReadFile(baseReadPath + nextId)
if "ERR:" in content['Output']:
content['Output'] = content['Output'].replace("ERR:","")
print(Fore.RED + content['Output'])
def remove_color():
Fore.GREEN = ''
Fore.CYAN = ''
Fore.RED = ''
Fore.YELLOW = ''
Fore.MAGENTA = ''
Fore.BLUE = ''
Fore.WHITE = ''
Style.BRIGHT = ''
Back.BLUE = ''
return
def _print_idx(self, idx):
color = colorama.Fore.CYAN
if self.args.noColor:
color = colorama.Style.RESET_ALL
print(color + idx, end=" ")
def show_status(login,failed,succ1,fail1):
clear()
banner()
screen_buffer = colorama.Fore.LIGHTBLACK_EX+"[!] Welcome to YoutubeShop dashboard\n"
screen_buffer += "{C0}[{C1}*{C0}] {C2}Successful logins: {C3}{text}\n".format(
C0=colorama.Fore.BLUE,
C1=colorama.Fore.RED,
C2=colorama.Fore.WHITE,
C3=colorama.Fore.CYAN,
text=login
)
screen_buffer += "{C0}[{C1}*{C0}] {C2}Failed logins: {C3}{text}\n".format(
C0=colorama.Fore.BLUE,
C1=colorama.Fore.RED,
C2=colorama.Fore.WHITE,
C3=colorama.Fore.CYAN,
text=failed
)
screen_buffer += "{C0}[{C1}*{C0}] {C2}Successful actions: {C3}{text}\n".format(
C0=colorama.Fore.BLUE,
C1=colorama.Fore.RED,
C2=colorama.Fore.WHITE,
C3=colorama.Fore.CYAN,
text=succ1
)
def description(self, text):
"""Display some descriptive text. Usually this is text from the demo
document itself.
"""
self.display(text, colorama.Fore.CYAN)
def __call__(self, jarvis, s):
jarvis.say("Welcome To The Plugin Joke Of Day!", Fore.CYAN)
jarvis.say("Jokes provided by jokes.one API", Fore.CYAN, False)
print()
joke_fetch = self.get_joke(jarvis)
if joke_fetch is not None:
self.joke(jarvis, joke_fetch)
''' Provides a stream handler for the Python logging framework that uses
colors to distinguish severity levels.
'''
from logging import StreamHandler, DEBUG, getLogger, Filter
try:
from colorama import Fore, Back, init, Style
class ColorStreamHandler(StreamHandler):
""" A colorized output SteamHandler """
# Some basic colour scheme defaults
colours = {
'DEBUG' : Fore.CYAN,
'INFO' : Fore.GREEN,
'WARN' : Fore.YELLOW,
'WARNING' : Fore.YELLOW,
'ERROR' : Fore.RED,
'CRIT' : Back.RED + Fore.WHITE,
'CRITICAL' : Back.RED + Fore.WHITE
}
@property
def is_tty(self):
""" Check if we are using a "real" TTY. If we are not using a TTY it means that
the colour output should be disabled.
:return: Using a TTY status
:rtype: bool
"""