Python termcolor.colored() Examples
The following are 30
code examples of termcolor.colored().
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
termcolor
, or try the search function
.
Example #1
Source File: network.py From LiMEaide with GNU General Public License v3.0 | 9 votes |
def connect(self): """Call to set connection with remote client.""" try: self.paramiko_session = paramiko.SSHClient() self.paramiko_session.set_missing_host_key_policy( paramiko.AutoAddPolicy()) self.paramiko_session.connect( self.client.ip, username=self.client.user, password=self.client.pass_, key_filename=self.client.key, allow_agent=True, compress=self.client.compress) except (paramiko.AuthenticationException, paramiko.ssh_exception.NoValidConnectionsError) as e: self.logger.error(e) sys.exit(colored("> {}".format(e), 'red')) except paramiko.SSHException as e: self.logger.error(e) sys.exit(colored("> {}".format(e), 'red')) self.transfer = network.Network( self.paramiko_session, self.client.ip, self.client.port) self.transfer.open()
Example #2
Source File: std.py From sqliv with GNU General Public License v3.0 | 7 votes |
def stdin(message, params, upper=False, lower=False): """ask for option/input from user""" symbol = colored("[OPT]", "magenta") currentime = colored("[{}]".format(time.strftime("%H:%M:%S")), "green") option = raw_input("{} {} {}: ".format(symbol, currentime, message)) if upper: option = option.upper() elif lower: option = option.lower() while option not in params: option = raw_input("{} {} {}: ".format(symbol, currentime, message)) if upper: option = option.upper() elif lower: option = option.lower() return option
Example #3
Source File: logger.py From dataflow with Apache License 2.0 | 6 votes |
def format(self, record): date = colored('[%(asctime)s @%(filename)s:%(lineno)d]', 'green') msg = '%(message)s' if record.levelno == logging.WARNING: fmt = date + ' ' + colored('WRN', 'red', attrs=['blink']) + ' ' + msg elif record.levelno == logging.ERROR or record.levelno == logging.CRITICAL: fmt = date + ' ' + colored('ERR', 'red', attrs=['blink', 'underline']) + ' ' + msg elif record.levelno == logging.DEBUG: fmt = date + ' ' + colored('DBG', 'yellow', attrs=['blink']) + ' ' + msg else: fmt = date + ' ' + msg if hasattr(self, '_style'): # Python3 compatibility self._style._fmt = fmt self._fmt = fmt return super(_MyFormatter, self).format(record)
Example #4
Source File: color.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def formatException(exc_info): tb_lines = traceback.format_exception(*exc_info) tb_lines[0] = termcolor.colored(tb_lines[0], 'red', attrs=['bold']) for line_no, line in enumerate(tb_lines[1:], 1): search = re.search(r'File \"([^"]+)", line ([\d,]+), in', line) if search: new_line = line[:search.start(1)] new_line += termcolor.colored(search.group(1), 'yellow', attrs=['underline']) new_line += line[search.end(1):search.start(2)] new_line += termcolor.colored(search.group(2), 'white', attrs=['bold']) new_line += line[search.end(2):] tb_lines[line_no] = new_line line = tb_lines[-1] if line.find(':'): idx = line.find(':') line = termcolor.colored(line[:idx], 'red', attrs=['bold']) + line[idx:] if line.endswith(os.linesep): line = line[:-len(os.linesep)] tb_lines[-1] = line return ''.join(tb_lines)
Example #5
Source File: serving.py From lambda-packs with MIT License | 6 votes |
def log_request(self, code='-', size='-'): msg = self.requestline code = str(code) if termcolor: color = termcolor.colored if code[0] == '1': # 1xx - Informational msg = color(msg, attrs=['bold']) elif code[0] == '2': # 2xx - Success msg = color(msg, color='white') elif code == '304': # 304 - Resource Not Modified msg = color(msg, color='cyan') elif code[0] == '3': # 3xx - Redirection msg = color(msg, color='green') elif code == '404': # 404 - Resource Not Found msg = color(msg, color='yellow') elif code[0] == '4': # 4xx - Client Error msg = color(msg, color='red', attrs=['bold']) else: # 5xx, or any other response msg = color(msg, color='magenta', attrs=['bold']) self.log('info', '"%s" %s %s', msg, code, size)
Example #6
Source File: utils.py From appr with Apache License 2.0 | 6 votes |
def colorize(status): msg = {} if os.getenv("APPR_COLORIZE_OUTPUT", "true") == "true": msg = { 'ok': 'green', 'created': 'yellow', 'updated': 'cyan', 'replaced': 'yellow', 'absent': 'green', 'deleted': 'red', 'protected': 'magenta'} color = msg.get(status, None) if color: return colored(status, color) else: return status
Example #7
Source File: config.py From LiMEaide with GNU General Public License v3.0 | 6 votes |
def __download_lime__(self): """Download LiME from GitHub""" cprint("Downloading LiME", 'green') try: urllib.request.urlretrieve( "https://github.com/504ensicsLabs/LiME/archive/" + "v{}.zip".format( self.lime_version), filename="./tools/lime_master.zip") zip_lime = zipfile.ZipFile("./tools/lime_master.zip", 'r') zip_lime.extractall(self.tools_dir) zip_lime.close() shutil.move( './tools/LiME-{}'.format(self.lime_version), './tools/LiME/') except urllib.error.URLError: sys.exit(colored( "LiME failed to download. Check your internet connection" + " or place manually", 'red'))
Example #8
Source File: function.py From ScanQLi with GNU General Public License v3.0 | 6 votes |
def CheckPostBlind(url, blindlist, fields, html): datatrue = {} datafalse = {} for field in fields: datatrue.update({field:blindlist[0]}) for field in fields: datafalse.update({field:blindlist[1]}) blindtrue = PostData(url, datatrue) blindfalse = PostData(url, datafalse) if (blindtrue == html) and (blindtrue != blindfalse): printpayload = colored("{", "yellow") icomma = 1 for field in fields: printpayload = printpayload + colored(field + ":", "yellow") + colored(blindlist[1], "red", attrs=["bold"]) if icomma != len(fields): printpayload = printpayload + colored(", ", "yellow") icomma += 1 printpayload = printpayload + colored("}", "yellow") bar.printabove(colored("[POST] ", "yellow", attrs=["bold"]) + colored(url, "yellow") + colored(" [PARAM] ", "yellow", attrs=["bold"]) + printpayload) return [url, blindfalse] else: return False
Example #9
Source File: help.py From macro_pack with Apache License 2.0 | 6 votes |
def printAvailableFormats(banner): print(colored(banner, 'green')) print(" Supported Office formats:") for fileType in MSTypes.MS_OFFICE_FORMATS: print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType])) print(" Note: Ms Office file generation requires Windows OS with MS Office application installed.") print("\n Supported VB formats:") for fileType in MSTypes.VBSCRIPTS_FORMATS: print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType])) print("\n Supported shortcuts/miscellaneous formats:") for fileType in MSTypes.Shortcut_FORMATS: print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType])) print("\n WARNING: These formats are only supported in MacroPack Pro:") for fileType in MSTypes.ProMode_FORMATS: print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType])) print("\n To create a payload for a certain format just add extension to payload.\n Ex. -G payload.hta ") if MP_TYPE=="Pro": printAvailableFormatsPro()
Example #10
Source File: function.py From ScanQLi with GNU General Public License v3.0 | 6 votes |
def CheckGetVuln(url, vuln, html): global currenttested global reponsetime if currenttested == "blind": return CheckGetBlind(url, vuln, html) validproof = CheckValidProof(html) payloadedurl = url + vuln while True: starttime = time.time() page = GetHTML(payloadedurl) endtime = time.time() if (currenttested != "timebase") or (reponsetime * 3 + 2 > endtime - starttime): break for ivalidproof in validproof: if (ivalidproof in page) or (currenttested == "timebase" and (endtime - starttime) >= (reponsetime + 2)): bar.printabove(colored("[GET] ", "green", attrs=["bold"]) + colored(url, "green") + colored(vuln, "red", attrs=["bold"])) return payloadedurl return False
Example #11
Source File: help.py From macro_pack with Apache License 2.0 | 6 votes |
def printCommunityUsage(banner, currentApp, mpSession): print(colored(banner, 'green')) print(" Usage 1: echo <parameters> | %s -t <TEMPLATE> -G <OUTPUT_FILE> [options] " %currentApp) print(" Usage 2: %s -f input_file_path -G <OUTPUT_FILE> [options] " % currentApp) print(" Usage 3: more input_file_path | %s -G <OUTPUT_FILE> [options] " %currentApp) details = getCommunityUsage(currentApp) details +=" -h, --help Displays help and exit" details += \ r""" Notes: Have a look at README.md file for more details and usage! Home: www.github.com/sevagas && blog.sevagas.com """ print(details)
Example #12
Source File: common.py From docker-mkdocs with MIT License | 6 votes |
def _check_previous_installation(): """ Check if previous installation present Creates empty documentation if none detected :return: """ if not os.path.exists(docks_dir + '/mkdocs.yml'): print(colored( f'No documentation found in ({docks_dir}). Creating new one.', 'yellow')) if not os.path.exists(docks_dir): os.mkdir(docks_dir) print(colored(f'Starting fresh installation', 'green')) os.system(f'mkdocs new {docks_dir}/') else: print( colored(f'Detected previous installation in ({docks_dir}).', 'green'))
Example #13
Source File: help.py From macro_pack with Apache License 2.0 | 6 votes |
def printProUsage(banner, currentApp, mpSession): print(colored(banner, 'green')) print(" Usage 1: echo <parameters> | %s -t <TEMPLATE> -G <OUTPUT_FILE> [options] " %currentApp) print(" Usage 2: %s -f input_file_path -G <OUTPUT_FILE> [options] " % currentApp) print(" Usage 3: more input_file_path | %s -G <OUTPUT_FILE> [options] " %currentApp) details = """ %s %s %s %s %s %s """ % (getGenerationFunction(currentApp), getGenerationFunctionPro(), getAvBypassFunction(currentApp), getAvBypassFunctionPro(), getOtherFunction(currentApp), getOtherFunctionPro()) details +=" -h, --help Displays help and exit \n" print(details)
Example #14
Source File: appAux.py From appcompatprocessor with Apache License 2.0 | 5 votes |
def outputcolum(data): # Calculate terminal size maxStrLength = getTerminalWidth() if settings.rawOutput or stdout_redirect(): maxStrLength = 1000 # Calculate number of fields and maxStrLengthField # todo: grab max size per field to do a more intelligent distribution of available term realestate num_fields = len(data[len(data)-1][1]) maxStrLengthField = maxStrLength / num_fields # Truncate fields # todo: There has to be a better approach to this for ii in xrange(0, len(data)): tmpList = [] for i in xrange(0, len(data[ii][1])): tmpList.append(str(data[ii][1][i])[:maxStrLengthField] + (str(data[ii][1][i])[maxStrLengthField:] and '...')) t1 = [] t1.append(data[ii][0]) t1.append(tuple(tmpList)) data[ii] = t1 data[ii][1] = tuple(tmpList) widths = [max(map(len,map(str, col))) for col in zip(*[x[1] for x in data])] for row in data: if settings.rawOutput or stdout_redirect(): print (" ".join((str(val).ljust(width) for val, width in zip(row[1], widths)))) else: print colored(" ".join((str(val).ljust(width) for val, width in zip(row[1], widths))), row[0]) return data
Example #15
Source File: appAux.py From appcompatprocessor with Apache License 2.0 | 5 votes |
def colored(s1, s2): return s1
Example #16
Source File: utils.py From captcha-harvester with MIT License | 5 votes |
def error(self, text): print("{} {}".format(self.__timestamp(), colored(text, "red"))) return
Example #17
Source File: utils.py From captcha-harvester with MIT License | 5 votes |
def warn(self, text): print("{} {}".format(self.__timestamp(), colored(text, "yellow"))) return
Example #18
Source File: utils.py From captcha-harvester with MIT License | 5 votes |
def success(self, text): print("{} {}".format(self.__timestamp(), colored(text, "green"))) return
Example #19
Source File: utils.py From captcha-harvester with MIT License | 5 votes |
def status(self, text): print("{} {}".format(self.__timestamp(), colored(text, "magenta"))) return
Example #20
Source File: deploy.py From shamer with MIT License | 5 votes |
def prompt_with_condition(message, condition, error): done = False while not done: inp = prompt(message) if not condition(inp): print colored(error, 'red') else: done = True return inp
Example #21
Source File: std.py From sqliv with GNU General Public License v3.0 | 5 votes |
def stdout(message, end="\n"): """print a message for user in console""" symbol = colored("[MSG]", "yellow") currentime = colored("[{}]".format(time.strftime("%H:%M:%S")), "green") print("{} {} {}".format(symbol, currentime, message), end=end)
Example #22
Source File: deploy.py From shamer with MIT License | 5 votes |
def prompt_password(instructions): return getpass.getpass(colored(instructions + ": ", 'blue', attrs=['bold']))
Example #23
Source File: deploy.py From shamer with MIT License | 5 votes |
def prompt(instructions): return raw_input(colored(instructions + ": ", 'blue', attrs=['bold']))
Example #24
Source File: deploy.py From shamer with MIT License | 5 votes |
def open_or_print(url): print colored(url, 'cyan') if prompt_get_yes_no('Open this url in your browser'): for command in ['open', 'xdg-open', 'start']: if call_without_output([command, url]) == 0: return
Example #25
Source File: function.py From ScanQLi with GNU General Public License v3.0 | 5 votes |
def CheckGetBlind(url, blindlist, html): blindtrue = GetHTML(url + blindlist[0]) blindfalse = GetHTML(url + blindlist[1]) if (blindtrue == html) and (blindtrue != blindfalse): bar.printabove(colored("[GET] ", "yellow", attrs=["bold"]) + colored(url, "yellow") + colored(blindlist[1], "red", attrs=["bold"])) return url + blindlist[1] else: return False
Example #26
Source File: nlp.py From graphbrain with MIT License | 5 votes |
def with_color(text, color, colors=True): if colors: return colored(text, color) else: return text
Example #27
Source File: deploy.py From shamer with MIT License | 5 votes |
def exit_with_error(error): sys.exit(colored(error, 'red'))
Example #28
Source File: deploy.py From shamer with MIT License | 5 votes |
def colored(msg, color, **kwargs): return msg
Example #29
Source File: function.py From ScanQLi with GNU General Public License v3.0 | 5 votes |
def PrintError(command, errormsg): print(colored("ERROR: ", "red", attrs=["bold"]) + colored(command, attrs=["bold"]) + " : " + errormsg)
Example #30
Source File: function.py From ScanQLi with GNU General Public License v3.0 | 5 votes |
def CheckPostVuln(url, vuln, fields, html): global currenttested global reponsetime if currenttested == "blind": return CheckPostBlind(url, vuln, fields, html) validproof = CheckValidProof(url) payloadeddata = {} for field in fields: payloadeddata.update({field:vuln}) while True: starttime = time.time() page = PostData(url, payloadeddata) endtime = time.time() if (currenttested != "timebase") or (reponsetime * 3 + 2 > endtime - starttime): break for ivalidproof in validproof: if (ivalidproof in page) or (currenttested == "timebase" and (endtime - starttime) >= (reponsetime + 2)): printpayload = colored("{", "green") icomma = 1 for field in fields: printpayload = printpayload + colored(field + ":", "green") + colored(vuln, "red", attrs=["bold"]) if icomma != len(fields): printpayload = printpayload + colored(", ", "green") icomma += 1 printpayload = printpayload + colored("}", "green") bar.printabove(colored("[POST] ", "green", attrs=["bold"]) + colored(url, "green") + colored(" [PARAM] ", "green", attrs=["bold"]) + printpayload) return [url, payloadeddata] return False